From 8a6777628a91451f1199334e2af1815cceca68cd Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 12 Aug 2019 18:36:03 +1000 Subject: [PATCH 01/91] First pass at use core local env. --- bin/configure-local-env.js | 100 +++++++++++++++++++++++++++++ package-lock.json | 126 ++++++++++++++++++------------------- package.json | 7 ++- phpunit.xml.dist | 2 +- 4 files changed, 168 insertions(+), 67 deletions(-) create mode 100644 bin/configure-local-env.js diff --git a/bin/configure-local-env.js b/bin/configure-local-env.js new file mode 100644 index 0000000000000..4d22d80744329 --- /dev/null +++ b/bin/configure-local-env.js @@ -0,0 +1,100 @@ +/** + * External dependencies + */ +const yaml = require( 'js-yaml' ); + +/** + * Node dependencies. + */ +const { existsSync, readFileSync, writeFileSync } = require( 'fs' ); +const { normalize } = require( 'path' ); +const { cwd, env } = require( 'process' ); +const { execSync } = require( 'child_process' ); + +/* eslint-disable no-console */ + +if ( ! env.WP_DEVELOP_DIR ) { + console.log( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); + return; +} + +const composeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.override.yml` ); +let compose = {}; +if ( existsSync( composeFile ) ) { + try { + compose = yaml.safeLoad( readFileSync( composeFile, 'utf8' ) ); + } catch ( e ) { + console.log( 'There was an error loading your docker-compose.override.yml file. Please fix or delete it, and try again.' ); + console.log( e ); + return; + } +} + +console.log( 'Updating docker-compose.override.yml...' ); + +compose.version = '3.7'; + +if ( ! compose.services ) { + compose.services = {}; +} + +const services = [ 'wordpress-develop', 'php', 'cli', 'phpunit' ]; + +services.forEach( ( service ) => { + if ( ! compose.services[ service ] ) { + compose.services[ service ] = {}; + } + + if ( ! compose.services[ service ].volumes ) { + compose.services[ service ].volumes = []; + } + + const index = compose.services[ service ].volumes.findIndex( ( volume ) => { + return volume.endsWith( '/plugins/gutenberg' ); + } ); + + const gutenbergVolume = ( service === 'phpunit' ) ? + normalize( cwd() ) + ':/wordpress-develop/${LOCAL_DIR-src}/wp-content/plugins/gutenberg' : + normalize( cwd() ) + ':/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg'; + + if ( index > -1 ) { + compose.services[ service ].volumes[ index ] = gutenbergVolume; + } else { + compose.services[ service ].volumes.append( gutenbergVolume ); + } + + if ( service === 'wordpress-develop' || service === 'php' ) { + const testPluginsIndex = compose.services[ service ].volumes.findIndex( ( volume ) => { + return volume.endsWith( '/plugins/gutenberg-test-plugins' ); + } ); + + const testPluginsVolume = normalize( cwd() + '/packages/e2e-tests/plugins' ) + ':/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins'; + + if ( testPluginsIndex > -1 ) { + compose.services[ service ].volumes[ testPluginsIndex ] = testPluginsVolume; + } else { + compose.services[ service ].volumes.append( testPluginsVolume ); + } + + const muPluginsIndex = compose.services[ service ].volumes.findIndex( ( volume ) => { + return volume.endsWith( '/mu-plugins' ); + } ); + + const muPluginsVolume = normalize( cwd() + '/packages/e2e-tests/mu-plugins' ) + ':/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins'; + + if ( muPluginsIndex > -1 ) { + compose.services[ service ].volumes[ muPluginsIndex ] = muPluginsVolume; + } else { + compose.services[ service ].volumes.append( muPluginsVolume ); + } + } +} ); + +writeFileSync( composeFile, yaml.safeDump( compose, { lineWidth: -1 } ) ); + +console.log( 'Restarting the WordPress environment...' ); + +execSync( 'npm run env:stop', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + +/* eslint-enable no-console */ diff --git a/package-lock.json b/package-lock.json index b7f5355b393f6..d9a9cac611968 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5520,7 +5520,7 @@ }, "ansi-escapes": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", "dev": true }, @@ -5709,7 +5709,7 @@ }, "array-equal": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", "dev": true }, @@ -5903,7 +5903,7 @@ }, "util": { "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -6730,7 +6730,7 @@ }, "bindings": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", + "resolved": "http://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=", "dev": true }, @@ -6963,7 +6963,7 @@ }, "browserify-aes": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { @@ -7000,7 +7000,7 @@ }, "browserify-rsa": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { @@ -7083,7 +7083,7 @@ }, "buffer": { "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "dev": true, "requires": { @@ -7154,7 +7154,7 @@ }, "cacache": { "version": "10.0.4", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", + "resolved": "http://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", "dev": true, "requires": { @@ -8132,7 +8132,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -8297,7 +8297,7 @@ }, "colors": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/colors/-/colors-0.5.1.tgz", "integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q=", "dev": true }, @@ -8319,7 +8319,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -8484,7 +8484,7 @@ "dependencies": { "ansi-regex": { "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", + "resolved": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", "dev": true }, @@ -8496,7 +8496,7 @@ }, "chalk": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", "dev": true, "requires": { @@ -8517,7 +8517,7 @@ }, "commander": { "version": "2.6.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.6.0.tgz", "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", "dev": true }, @@ -8538,7 +8538,7 @@ }, "strip-ansi": { "version": "0.3.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", "dev": true, "requires": { @@ -9254,7 +9254,7 @@ }, "create-hash": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { @@ -9267,7 +9267,7 @@ }, "create-hmac": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { @@ -9362,7 +9362,7 @@ }, "css-color-names": { "version": "0.0.4", - "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", + "resolved": "http://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", "integrity": "sha1-gIrcLnnPhHOAabZGyyDsJ762KeA=", "dev": true }, @@ -9462,7 +9462,7 @@ }, "css-select": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", "dev": true, "requires": { @@ -10036,7 +10036,7 @@ }, "diffie-hellman": { "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { @@ -10092,7 +10092,7 @@ "dependencies": { "domelementtype": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", "dev": true } @@ -10167,7 +10167,7 @@ }, "duplexer": { "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, @@ -10609,7 +10609,7 @@ }, "es6-promisify": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "resolved": "http://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", "dev": true, "requires": { @@ -11790,7 +11790,7 @@ "dependencies": { "core-js": { "version": "1.2.7", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "resolved": "http://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" } } @@ -11907,7 +11907,7 @@ }, "finalhandler": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", "dev": true, "requires": { @@ -12075,13 +12075,13 @@ "dependencies": { "colors": { "version": "0.6.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", + "resolved": "http://registry.npmjs.org/colors/-/colors-0.6.2.tgz", "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", "dev": true }, "commander": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.1.0.tgz", "integrity": "sha1-0SG7roYNmZKj1Re6lvVliOR8Z4E=", "dev": true } @@ -12666,7 +12666,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": false, + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true @@ -12900,7 +12900,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -12956,7 +12956,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -12981,7 +12981,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -13038,7 +13038,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "get-value": { @@ -13058,7 +13058,7 @@ }, "gettext-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz", + "resolved": "http://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz", "integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==", "requires": { "encoding": "^0.1.12", @@ -13444,7 +13444,7 @@ "dependencies": { "minimist": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz", "integrity": "sha1-O+39kaktOQFvz6ocaB6Pqhoe/ag=", "dev": true } @@ -14237,7 +14237,7 @@ }, "is-builtin-module": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { @@ -14429,7 +14429,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -16197,7 +16197,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, @@ -16564,7 +16564,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -17310,7 +17310,7 @@ }, "media-typer": { "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "dev": true }, @@ -18471,7 +18471,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -18723,7 +18723,7 @@ "dependencies": { "semver": { "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "resolved": "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true } @@ -18880,7 +18880,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -18890,7 +18890,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -18956,7 +18956,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -19039,7 +19039,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -19718,7 +19718,7 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, @@ -19744,7 +19744,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -19780,7 +19780,7 @@ }, "p-is-promise": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", "dev": true }, @@ -20318,7 +20318,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, @@ -20377,7 +20377,7 @@ }, "pegjs": { "version": "0.10.0", - "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", + "resolved": "http://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", "integrity": "sha1-z4uvrm7d/0tafvsYUmnqr0YQ3b0=" }, "pend": { @@ -20405,7 +20405,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -22983,7 +22983,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } @@ -23376,7 +23376,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { @@ -23517,7 +23517,7 @@ }, "os-locale": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "dev": true, "requires": { @@ -23537,7 +23537,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -23666,7 +23666,7 @@ "dependencies": { "source-map": { "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { @@ -23805,7 +23805,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { @@ -24601,7 +24601,7 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" }, "strip-indent": { @@ -25497,7 +25497,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -26529,7 +26529,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -26551,7 +26551,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -27091,7 +27091,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "requires": { "string-width": "^1.0.1", @@ -27123,7 +27123,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" diff --git a/package.json b/package.json index df3d6103b44bd..c57608863cdcd 100644 --- a/package.json +++ b/package.json @@ -112,6 +112,7 @@ "is-equal-shallow": "0.1.3", "jest-junit": "6.4.0", "jest-serializer-enzyme": "1.0.0", + "js-yaml": "3.13.1", "jsdom": "11.12.0", "lerna": "3.16.4", "lint-staged": "8.1.5", @@ -206,7 +207,6 @@ "publish:dev": "npm run build:packages && lerna publish --npm-tag next", "publish:prod": "npm run build:packages && lerna publish", "test": "npm run lint && npm run test-unit", - "pretest-e2e": "cross-env SCRIPT_DEBUG=false ./bin/reset-local-e2e-tests.sh", "test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js", "test-e2e:watch": "npm run test-e2e -- --watch", "test-performance": "wp-scripts test-e2e --config packages/e2e-tests/jest.performance.config.js", @@ -214,12 +214,13 @@ "test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.js", "test-unit:update": "npm run test-unit -- --updateSnapshot", "test-unit:watch": "npm run test-unit -- --watch", - "test-unit-php": "docker-compose run --rm wordpress_phpunit phpunit", + "test-unit-php": "cd $WP_DEVELOP_DIR && npm run test:php -- -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", "test-unit-php-multisite": "docker-compose run -e WP_MULTISITE=1 --rm wordpress_phpunit phpunit", "test-unit:native": "cd test/native/ && cross-env NODE_ENV=test jest --config ./jest.config.js", "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", - "playground:start": "concurrently \"npm run dev:packages\" \"parcel playground/src/index.html -d playground/dist\"" + "playground:start": "concurrently \"npm run dev:packages\" \"parcel playground/src/index.html -d playground/dist\"", + "env:config": "node bin/configure-local-env.js" }, "lint-staged": { "packages/*/package.json": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2eb5f4eae3c4b..e799a44754caf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,7 +7,7 @@ convertWarningsToExceptions="true" > - + ./phpunit/ From ef8e1c3ac011516251cf9579cc6440cbd7b33558 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 12:36:32 +1000 Subject: [PATCH 02/91] Delete all the files this setup will replace. (Many of them are not yet replaced, let's see what explodes!) --- .gitignore | 1 - bin/bootstrap-env.sh | 12 --- bin/includes.sh | 134 ---------------------------------- bin/install-docker.sh | 33 --------- bin/install-node-nvm.sh | 91 ----------------------- bin/install-php-phpunit.sh | 123 ------------------------------- bin/install-wordpress.sh | 110 ---------------------------- bin/install-wp-tests.sh | 129 -------------------------------- bin/patches/README.md | 2 - bin/patches/node.patch | 51 ------------- bin/patches/openssl.patch | 52 ------------- bin/reset-local-e2e-tests.sh | 7 -- bin/run-wp-unit-tests.sh | 60 --------------- bin/setup-local-env.sh | 52 ------------- bin/setup-travis-e2e-tests.sh | 29 -------- docker-compose-localdev.yml | 12 --- docker-compose.yml | 88 ---------------------- 17 files changed, 986 deletions(-) delete mode 100755 bin/bootstrap-env.sh delete mode 100755 bin/includes.sh delete mode 100755 bin/install-docker.sh delete mode 100755 bin/install-node-nvm.sh delete mode 100755 bin/install-php-phpunit.sh delete mode 100755 bin/install-wordpress.sh delete mode 100755 bin/install-wp-tests.sh delete mode 100644 bin/patches/README.md delete mode 100644 bin/patches/node.patch delete mode 100644 bin/patches/openssl.patch delete mode 100755 bin/reset-local-e2e-tests.sh delete mode 100755 bin/run-wp-unit-tests.sh delete mode 100755 bin/setup-local-env.sh delete mode 100755 bin/setup-travis-e2e-tests.sh delete mode 100644 docker-compose-localdev.yml delete mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 5e48a472bc5cb..96f49190bf8b5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ gutenberg.zip *.log phpcs.xml yarn.lock -docker-compose.override.yml /wordpress playground/dist diff --git a/bin/bootstrap-env.sh b/bin/bootstrap-env.sh deleted file mode 100755 index 3055a49b5138e..0000000000000 --- a/bin/bootstrap-env.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -WP_VERSION=${WP_VERSION-latest} -WP_DEBUG=${WP_DEBUG-true} -SCRIPT_DEBUG=${SCRIPT_DEBUG-true} -DOCKER=${DOCKER-false} -DOCKER_ENV=${DOCKER_ENV-ci} -DOCKER_COMPOSE_FILE_OPTIONS="-f docker-compose.yml" - -if [ "$DOCKER_ENV" == "localwpdev" ]; then - DOCKER_COMPOSE_FILE_OPTIONS="${DOCKER_COMPOSE_FILE_OPTIONS} -f docker-compose-localdev.yml" -fi diff --git a/bin/includes.sh b/bin/includes.sh deleted file mode 100755 index d0028a1c66575..0000000000000 --- a/bin/includes.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash - -## -# Ask a Yes/No question, and way for a reply. -# -# This is a general-purpose function to ask Yes/No questions in Bash, either with or without a default -# answer. It keeps repeating the question until it gets a valid answer. -# -# @param {string} prompt The question to ask the user. -# @param {string} [default] Optional. "Y" or "N", for the default option to use if none is entered. -# @param {int} [timeout] Optional. The number of seconds to wait before using the default option. -# -# @returns {bool} true if the user replies Yes, false if the user replies No. -## -ask() { - # Source: https://djm.me/ask - local timeout endtime timediff prompt default reply - - while true; do - - timeout="${3:-}" - - if [ "${2:-}" = "Y" ]; then - prompt="Y/n" - default=Y - elif [ "${2:-}" = "N" ]; then - prompt="y/N" - default=N - else - prompt="y/n" - default= - timeout= - fi - - if [ -z "$timeout" ]; then - # Ask the question (not using "read -p" as it uses stderr not stdout) - echo -en "$1 [$prompt] " - - # Read the answer (use /dev/tty in case stdin is redirected from somewhere else) - read reply /dev/null 2>&1 -} diff --git a/bin/install-docker.sh b/bin/install-docker.sh deleted file mode 100755 index f485753b9cc4c..0000000000000 --- a/bin/install-docker.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# Exit if any command fails. -set -e - -. "$(dirname "$0")/bootstrap-env.sh" - -# Include useful functions. -. "$(dirname "$0")/includes.sh" - -# Check that Docker is installed. -if ! command_exists "docker"; then - echo -e $(error_message "Docker doesn't seem to be installed. Please head on over to the Docker site to download it: $(action_format "https://www.docker.com/products/docker-desktop")") - exit 1 -fi - -# Check that Docker is running. -if ! docker info >/dev/null 2>&1; then - echo -e $(error_message "Docker isn't running. Please check that you've started your Docker app, and see it in your system tray.") - exit 1 -fi - -# Stop existing containers. -echo -e $(status_message "Stopping Docker containers...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS down --remove-orphans >/dev/null 2>&1 - -# Download image updates. -echo -e $(status_message "Downloading Docker image updates...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS pull - -# Launch the containers. -echo -e $(status_message "Starting Docker containers...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS up -d >/dev/null diff --git a/bin/install-node-nvm.sh b/bin/install-node-nvm.sh deleted file mode 100755 index d9cd1a6faf510..0000000000000 --- a/bin/install-node-nvm.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -NVM_VERSION=`curl -Ls -w %{url_effective} -o /dev/null https://github.com/creationix/nvm/releases/latest | rev | cut -d '/' -f 1 | rev` - -# Exit if any command fails -set -e - -# Include useful functions -. "$(dirname "$0")/includes.sh" - -# Load NVM -if [ -n "$NVM_DIR" ]; then - # The --no-use option ensures loading NVM doesn't switch the current version. - if [ -f "$NVM_DIR/nvm.sh" ]; then - . "$NVM_DIR/nvm.sh" --no-use - elif command_exists "brew" && [ -f "$(brew --prefix nvm)/nvm.sh" ]; then - # use homebrew if that's how nvm was installed - . "$(brew --prefix nvm)/nvm.sh" --no-use - fi -fi - -# Change to the expected directory -cd "$(dirname "$0")/.." - -# Check if nvm is installed -if [ "$TRAVIS" != "true" ] && ! command_exists "nvm"; then - if ask "$(error_message "NVM isn't installed, would you like to download and install it automatically?")" Y; then - # The .bash_profile file needs to exist for NVM to install - if [ ! -e ~/.bash_profile ]; then - touch ~/.bash_profile - fi - - echo -en $(status_message "Installing NVM..." ) - download "https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh" | bash >/dev/null 2>&1 - echo ' done!' - - echo -e $(warning_message "NVM was updated, please run this command to reload it:" ) - echo -e $(warning_message "$(action_format ". \$HOME/.nvm/nvm.sh")" ) - echo -e $(warning_message "After that, re-run the setup script to continue." ) - else - echo -e $(error_message "") - echo -e $(error_message "Please install NVM manually, then re-run the setup script to continue.") - echo -e $(error_message "NVM installation instructions can be found here: $(action_format "https://github.com/creationix/nvm")") - fi - - exit 1 -fi - -# Check if the current nvm version is up to date. -if [ "$TRAVIS" != "true" ] && [ $NVM_VERSION != "v$(nvm --version)" ]; then - echo -en $(status_message "Updating NVM..." ) - download "https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh" | bash >/dev/null 2>&1 - echo ' done!' - - echo -e $(warning_message "NVM was updated, please run this command to reload it:" ) - echo -e $(warning_message "$(action_format ". \$HOME/.nvm/nvm.sh")" ) - echo -e $(warning_message "After that, re-run the setup script to continue." ) - exit 1 -fi - -# Check if the current node version is up to date. -if [ "$TRAVIS" != "true" ] && [ "$(nvm current)" != "$(nvm version-remote --lts)" ]; then - echo -e $(warning_message "Node version does not match the latest long term support version. Please run this command to install and use it:" ) - echo -e $(warning_message "$(action_format "nvm install")" ) - echo -e $(warning_message "After that, re-run the setup script to continue." ) - exit 1 -fi - -# Install/update packages -echo -e $(status_message "Installing and updating NPM packages..." ) -npm install - -# There was a bug in NPM that caused changes in package-lock.json. Handle that. -if [ "$TRAVIS" != "true" ] && ! git diff --no-ext-diff --exit-code package-lock.json >/dev/null; then - if ask "$(warning_message "Your package-lock.json changed, which may mean there's an issue with your NPM cache. Would you like to try and automatically clean it up?" )" N 10; then - rm -rf node_modules/ - npm cache clean --force >/dev/null 2>&1 - git checkout package-lock.json - - echo -e $(status_message "Reinstalling NPM packages..." ) - npm install - - # Check that it's cleaned up now. - if git diff --no-ext-diff --exit-code package-lock.json >/dev/null; then - echo -e $(warning_message "Confirmed that the NPM cache is cleaned up." ) - else - echo -e $(error_message "We were unable to clean the NPM cache, please manually review the changes to package-lock.json. Continuing with the setup process..." ) - fi - else - echo -e $(warning_message "Please manually review the changes to package-lock.json. Continuing with the setup process..." ) - fi -fi diff --git a/bin/install-php-phpunit.sh b/bin/install-php-phpunit.sh deleted file mode 100755 index 09b9137b1fc71..0000000000000 --- a/bin/install-php-phpunit.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash - -# Uses phpbrew to install older php versions on modern(ish) distros. -# Installs the correct version of phpunit for the requested php -# version. ~/.phpbrew is expected to be cached so we only have -# to build php the first time. - -# we have to save and restore the original working directory, because -# phpbrew can mess up if we don't run it from the home directory -ORIG_DIR=`pwd`; -THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PHP52_PATH=$HOME/.phpbrew/php/php-5.2.17 - -# install phpunit - -mkdir -p $HOME/phpunit-bin - -if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]]; then - # use the phpunit in the PHP5.2 installation - ln -s ${PHP52_PATH}/lib/php/phpunit/phpunit.php $HOME/phpunit-bin/phpunit -elif [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]] || [[ ${SWITCH_TO_PHP:0:2} == "5." ]]; then - wget -O $HOME/phpunit-bin/phpunit https://phar.phpunit.de/phpunit-4.8.phar - chmod +x $HOME/phpunit-bin/phpunit -else - composer global require "phpunit/phpunit=6.*" -fi - -export PATH=$HOME/phpunit-bin/:$PATH - -if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]] || [[ ${SWITCH_TO_PHP:0:3} == "5.3" ]]; then - PHPBREW_BUILT_CHECK=$HOME/.phpbrew/bashrc - - # directory to install phpbrew into - mkdir -p $HOME/php-utils-bin - - # install phpbrew - curl -L -o $HOME/php-utils-bin/phpbrew https://github.com/phpbrew/phpbrew/raw/f6a422e1ba49293ee73bc4c317795c021bc57020/phpbrew - chmod +x $HOME/php-utils-bin/phpbrew - - # needs to be on the path for switching php versions to work - export PATH=$HOME/php-utils-bin:$PATH - - # php and phpunit3.6 installs should be cached, only build if they're not there. - if [ ! -f $PHPBREW_BUILT_CHECK ]; then - - # init with known --old to get 5.2 and 5.3 - $HOME/php-utils-bin/phpbrew init - $HOME/php-utils-bin/phpbrew known --old - - # fetch the build tarballs manually - mkdir -p $HOME/.phpbrew/distfiles - curl -L -o $HOME/.phpbrew/distfiles/php-5.2.17.tar.bz2 https://museum.php.net/php5/php-5.2.17.tar.bz2 - curl -L -o $HOME/.phpbrew/distfiles/php-5.3.29.tar.bz2 https://museum.php.net/php5/php-5.3.29.tar.bz2 - - # build PHP5.2 - echo 'Installing PHP 5.2...' - $HOME/php-utils-bin/phpbrew install --patch ${THIS_DIR}/patches/node.patch --patch ${THIS_DIR}/patches/openssl.patch 5.2.17 +default +mysql +pdo \ - +gettext +phar +openssl -- --with-openssl-dir=/usr/include/openssl --enable-spl --with-mysql --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr - - # build PHP5.3 - echo 'Installing PHP 5.3...' - $HOME/php-utils-bin/phpbrew install --patch ${THIS_DIR}/patches/node.patch --patch ${THIS_DIR}/patches/openssl.patch 5.3.29 +default +mysql +pdo \ - +gettext +phar +openssl -- --with-openssl-dir=/usr/include/openssl --enable-spl --with-mysql --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr - - # install PHPUnit 3.6. The only install method available is from source, using git branches old - # enough that they don't rely on any PHP5.3+ features. This clones each needed dependency - # and then we add the paths to the include_path by setting up an extra .ini file - cd ${PHP52_PATH}/lib/php - - # dependencies - git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/dbunit.git - git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/php-code-coverage.git - git clone --depth=1 --branch=1.3.2 git://github.com/sebastianbergmann/php-file-iterator.git - git clone --depth=1 --branch=1.1.1 git://github.com/sebastianbergmann/php-invoker.git - git clone --depth=1 --branch=1.1.2 git://github.com/sebastianbergmann/php-text-template.git - git clone --depth=1 --branch=1.0.3 git://github.com/sebastianbergmann/php-timer.git - git clone --depth=1 --branch=1.1.4 git://github.com/sebastianbergmann/php-token-stream.git - git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/phpunit-mock-objects.git - git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/phpunit-selenium.git - git clone --depth=1 --branch=1.0.0 git://github.com/sebastianbergmann/phpunit-story.git - - # and the version of phpunit that we expect to run with php 5.2 - git clone --depth=1 --branch=3.6 git://github.com/sebastianbergmann/phpunit.git - - # fix up the version number of phpunit - sed -i 's/@package_version@/3.6-git/g' phpunit/PHPUnit/Runner/Version.php - - # now set up an ini file that adds all of the above to include_path for the PHP5.2 install - mkdir -p ${PHP52_PATH}/var/db - echo "include_path=.:${PHP52_PATH}/lib/php:${PHP52_PATH}/lib/php/dbunit:${PHP52_PATH}/lib/php/php-code-coverage:${PHP52_PATH}/lib/php/php-file-iterator:${PHP52_PATH}/lib/php/php-invoker:${PHP52_PATH}/lib/php/php-text-template:${PHP52_PATH}/lib/php/php-timer:${PHP52_PATH}/lib/php/php-token-stream:${PHP52_PATH}/lib/php/phpunit-mock-objects:${PHP52_PATH}/lib/php/phpunit-selenium:${PHP52_PATH}/lib/php/phpunit-story:${PHP52_PATH}/lib/php/phpunit" > ${PHP52_PATH}/var/db/path.ini - - # one more PHPUnit dependency that we need to install using pear under PHP5.2 - cd $HOME - export PHPBREW_RC_ENABLE=1 - source $HOME/.phpbrew/bashrc - phpbrew use 5.2.17 - - # manually go back to the system php, we can't use `phpbrew switch-off` - # because we're running a version of php that phpbrew doesn't work with at this point - unset PHPBREW_PHP - unset PHPBREW_PATH - __phpbrew_set_path - __phpbrew_reinit - eval `$BIN env` - - # clean up build directory - rm -rf $HOME/.phpbrew/build/* - fi - - # all needed php versions and phpunit versions are installed, either from the above - # install script, or from travis cache, so switch to using them - cd $HOME - export PHPBREW_RC_ENABLE=1 - source $HOME/.phpbrew/bashrc - - if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]]; then - phpbrew use 5.2.17 - else - phpbrew use 5.3.29 - fi -fi - -cd $ORIG_DIR diff --git a/bin/install-wordpress.sh b/bin/install-wordpress.sh deleted file mode 100755 index 551e8bd0dc77e..0000000000000 --- a/bin/install-wordpress.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash - -# Exit if any command fails. -set -e - -# Gutenberg script includes. -. "$(dirname "$0")/includes.sh" - -# Set up environment variables -. "$(dirname "$0")/bootstrap-env.sh" - -# These are the containers and values for the development site. -CLI='cli' -CONTAINER='wordpress' -SITE_TITLE='Gutenberg Dev' - -# If we're installing/re-installing the test site, change the containers used. -if [ "$1" == '--e2e_tests' ]; then - CLI="${CLI}_e2e_tests" - CONTAINER='wordpress_e2e_tests' - SITE_TITLE='Gutenberg Testing' - - if ! docker ps | grep -q $CONTAINER; then - echo -e $(error_message "WordPress e2e tests run in their own Docker container, but that container wasn't found.") - echo "Please restart your Docker containers by running 'docker-compose $DOCKER_COMPOSE_FILE_OPTIONS down && docker-compose $DOCKER_COMPOSE_FILE_OPTIONS up -d' or" - echo "by running './bin/setup-local-env.sh' again." - echo "" - exit 1 - fi -fi - -# Get the host port for the WordPress container. -HOST_PORT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS port $CONTAINER 80 | awk -F : '{printf $2}') - -# Wait until the Docker containers are running and the WordPress site is -# responding to requests. -echo -en $(status_message "Attempting to connect to WordPress...") -until $(curl -L http://localhost:$HOST_PORT -so - 2>&1 | grep -q "WordPress"); do - echo -n '.' - sleep 5 -done -echo '' - -# If this is the test site, we reset the database so no posts/comments/etc. -# dirty up the tests. -if [ "$1" == '--e2e_tests' ]; then - echo -e $(status_message "Resetting test database...") - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI db reset --yes --quiet -fi - -# Install WordPress. -echo -e $(status_message "Installing WordPress...") -# The `-u 33` flag tells Docker to run the command as a particular user and -# prevents permissions errors. See: https://github.com/WordPress/gutenberg/pull/8427#issuecomment-410232369 -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core install --title="$SITE_TITLE" --admin_user=admin --admin_password=password --admin_email=test@test.com --skip-email --url=http://localhost:$HOST_PORT --quiet - -if [ "$E2E_ROLE" = "author" ]; then - echo -e $(status_message "Creating an additional author user for testing...") - # Create an additional author user for testing. - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI user create author author@example.com --role=author --user_pass=authpass --quiet - # Assign the existing Hello World post to the author. - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI post update 1 --post_author=2 --quiet -fi - -# Make sure the uploads and upgrade folders exist and we have permissions to add files. -echo -e $(status_message "Ensuring that files can be uploaded...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER mkdir -p /var/www/html/wp-content/uploads /var/www/html/wp-content/upgrade -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER chmod 767 /var/www/html/wp-content/plugins /var/www/html/wp-config.php /var/www/html/wp-settings.php /var/www/html/wp-content/uploads /var/www/html/wp-content/upgrade - -CURRENT_WP_VERSION=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm $CLI core version) -echo -e $(status_message "Current WordPress version: $CURRENT_WP_VERSION...") - -if [ "$WP_VERSION" == "latest" ]; then - # Check for WordPress updates, to make sure we're running the very latest version. - echo -e $(status_message "Updating WordPress to the latest version...") - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core update --quiet - echo -e $(status_message "Updating The WordPress Database...") - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core update-db --quiet -fi - -# If the 'wordpress' volume wasn't during the down/up earlier, but the post port has changed, we need to update it. -echo -e $(status_message "Checking the site's url...") -CURRENT_URL=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm $CLI option get siteurl) -if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI option update home "http://localhost:$HOST_PORT" --quiet - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI option update siteurl "http://localhost:$HOST_PORT" --quiet -fi - -# Activate Gutenberg. -echo -e $(status_message "Activating Gutenberg...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI plugin activate gutenberg --quiet - -# Install a dummy favicon to avoid 404 errors. -echo -e $(status_message "Installing a dummy favicon...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER touch /var/www/html/favicon.ico - -# Configure site constants. -echo -e $(status_message "Configuring site constants...") -WP_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) -if [ $WP_DEBUG != $WP_DEBUG_CURRENT ]; then - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG $WP_DEBUG --raw --type=constant --quiet - WP_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) - echo -e $(status_message "WP_DEBUG: $WP_DEBUG_RESULT...") -fi -SCRIPT_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) -if [ $SCRIPT_DEBUG != $SCRIPT_DEBUG_CURRENT ]; then - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set SCRIPT_DEBUG $SCRIPT_DEBUG --raw --type=constant --quiet - SCRIPT_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) - echo -e $(status_message "SCRIPT_DEBUG: $SCRIPT_DEBUG_RESULT...") -fi diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh deleted file mode 100755 index 17dc681629034..0000000000000 --- a/bin/install-wp-tests.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env bash - -# Include useful functions -. "$(dirname "$0")/includes.sh" - -if [ $# -lt 3 ]; then - echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" - exit 1 -fi - -DB_NAME=$1 -DB_USER=$2 -DB_PASS=$3 -DB_HOST=${4-localhost} -WP_VERSION=${5-latest} -SKIP_DB_CREATE=${6-false} - -WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} -WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} - -if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then - WP_TESTS_TAG="tags/$WP_VERSION" -elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then - WP_TESTS_TAG="trunk" -else - # http serves a single offer, whereas https serves multiple. we only want one - download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json - grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json - LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') - if [[ -z "$LATEST_VERSION" ]]; then - echo "Latest WordPress version could not be found" - exit 1 - fi - WP_TESTS_TAG="tags/$LATEST_VERSION" -fi - -set -ex - -install_wp() { - - if [ -d $WP_CORE_DIR ]; then - return; - fi - - mkdir -p $WP_CORE_DIR - - if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then - mkdir -p /tmp/wordpress-nightly - download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip - unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/ - mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR - else - if [ $WP_VERSION == 'latest' ]; then - local ARCHIVE_NAME='latest' - else - local ARCHIVE_NAME="wordpress-$WP_VERSION" - fi - download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz - tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR - fi - - download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php -} - -install_test_suite() { - # portable in-place argument for both GNU sed and Mac OSX sed - if [[ $(uname -s) == 'Darwin' ]]; then - local ioption='-i .bak' - else - local ioption='-i' - fi - - # set up testing suite if it doesn't yet exist - if [ ! -d $WP_TESTS_DIR ]; then - # set up testing suite - mkdir -p $WP_TESTS_DIR - svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes - svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data - fi - - if [ ! -f wp-tests-config.php ]; then - download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php - # remove all forward slashes in the end - WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") - sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php - fi - -} - -install_db() { - - if [ ${SKIP_DB_CREATE} = "true" ]; then - return 0 - fi - - # parse DB_HOST for port or socket references - local PARTS=(${DB_HOST//\:/ }) - local DB_HOSTNAME=${PARTS[0]}; - local DB_SOCK_OR_PORT=${PARTS[1]}; - local EXTRA="" - - if ! [ -z $DB_HOSTNAME ] ; then - if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then - EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" - elif ! [ -z $DB_SOCK_OR_PORT ] ; then - EXTRA=" --socket=$DB_SOCK_OR_PORT" - elif ! [ -z $DB_HOSTNAME ] ; then - EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" - fi - fi - - # create database - mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute "CREATE DATABASE IF NOT EXISTS $DB_NAME;" -} - -# Wait for MySQL availability before proceeding with installation -echo -en $(status_message "Attempting to connect to MySQL...") -while ! mysqladmin ping -h"$DB_HOST" --silent; do - echo -n '.' - sleep 2 -done - -install_wp -install_test_suite -install_db diff --git a/bin/patches/README.md b/bin/patches/README.md deleted file mode 100644 index 8ea482c4e6e63..0000000000000 --- a/bin/patches/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains patches required to build -older versions of PHP on trusty. \ No newline at end of file diff --git a/bin/patches/node.patch b/bin/patches/node.patch deleted file mode 100644 index e5dbab7972b6b..0000000000000 --- a/bin/patches/node.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800 -+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800 -@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA - RETVAL_FALSE; - } else { - if (mode == 0) { -+#ifdef LIBXML2_NEW_BUFFER -+ ret = xmlOutputBufferGetSize(buf); -+#else - ret = buf->buffer->use; -+#endif - if (ret > 0) { -+#ifdef LIBXML2_NEW_BUFFER -+ RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1); -+#else - RETVAL_STRINGL((char *) buf->buffer->content, ret, 1); -+#endif - } else { - RETVAL_EMPTY_STRING(); - } ---- ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800 -+++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800 -@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea - if (buff != NULL) { - xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL); - xmlOutputBufferFlush(buff); -+ -+#ifdef LIBXML2_NEW_BUFFER -+ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff), -+ xmlOutputBufferGetSize(buff), 1); -+#else - ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1); -+#endif - (void)xmlOutputBufferClose(buff); - return SUCCESS; - } ---- ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800 -+++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800 -@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML) - - xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding); - xmlOutputBufferFlush(outbuf); -+#ifdef LIBXML2_NEW_BUFFER -+ RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), -+ xmlOutputBufferGetSize(outbuf), 1); -+#else - RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1); -+#endif - xmlOutputBufferClose(outbuf); - } - } else { diff --git a/bin/patches/openssl.patch b/bin/patches/openssl.patch deleted file mode 100644 index 3b0e010b1fd1f..0000000000000 --- a/bin/patches/openssl.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- ext/openssl/xp_ssl.c -+++ ext/openssl/xp_ssl.c -@@ -328,10 +328,12 @@ static inline int php_openssl_setup_cryp - sslsock->is_client = 1; - method = SSLv23_client_method(); - break; -+#ifndef OPENSSL_NO_SSL2 - case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: - sslsock->is_client = 1; - method = SSLv2_client_method(); - break; -+#endif - case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: - sslsock->is_client = 1; - method = SSLv3_client_method(); -@@ -348,10 +350,12 @@ static inline int php_openssl_setup_cryp - sslsock->is_client = 0; - method = SSLv3_server_method(); - break; -+#ifndef OPENSSL_NO_SSL2 - case STREAM_CRYPTO_METHOD_SSLv2_SERVER: - sslsock->is_client = 0; - method = SSLv2_server_method(); - break; -+#endif - case STREAM_CRYPTO_METHOD_TLS_SERVER: - sslsock->is_client = 0; - method = TLSv1_server_method(); -@@ -629,9 +633,11 @@ static inline int php_openssl_tcp_sockop - case STREAM_CRYPTO_METHOD_SSLv23_CLIENT: - sock->method = STREAM_CRYPTO_METHOD_SSLv23_SERVER; - break; -+#ifndef OPENSSL_NO_SSL2 - case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: - sock->method = STREAM_CRYPTO_METHOD_SSLv2_SERVER; - break; -+#endif - case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: - sock->method = STREAM_CRYPTO_METHOD_SSLv3_SERVER; - break; -@@ -911,9 +917,11 @@ php_stream *php_openssl_ssl_socket_facto - if (strncmp(proto, "ssl", protolen) == 0) { - sslsock->enable_on_connect = 1; - sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT; -+#ifndef OPENSSL_NO_SSL2 - } else if (strncmp(proto, "sslv2", protolen) == 0) { - sslsock->enable_on_connect = 1; - sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT; -+#endif - } else if (strncmp(proto, "sslv3", protolen) == 0) { - sslsock->enable_on_connect = 1; - sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT; diff --git a/bin/reset-local-e2e-tests.sh b/bin/reset-local-e2e-tests.sh deleted file mode 100755 index fb1e080f9da04..0000000000000 --- a/bin/reset-local-e2e-tests.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Exit if any command fails. -set -e - -# Set up WordPress site used for end-to-end (e2e) tests. -. "$(dirname "$0")/install-wordpress.sh" --e2e_tests diff --git a/bin/run-wp-unit-tests.sh b/bin/run-wp-unit-tests.sh deleted file mode 100755 index 2e5dc5b080914..0000000000000 --- a/bin/run-wp-unit-tests.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash - -# Exit if any command fails -set -e - -npm ci - -npm run build - -# Set up environment variables -. "$(dirname "$0")/bootstrap-env.sh" - -# Include useful functions -. "$(dirname "$0")/includes.sh" - -cd "$(dirname "$0")/../" - -export PATH="$HOME/.composer/vendor/bin:$PATH" -if [[ $DOCKER = "true" ]]; then - # Download image updates. - echo -e $(status_message "Downloading Docker image updates...") - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS pull composer mysql wordpress_phpunit - - # Launch the containers. - echo -e $(status_message "Starting Docker containers...") - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS up -d composer mysql wordpress_phpunit >/dev/null - - # Install the PHPUnit test scaffolding. - echo -e $(status_message "Installing PHPUnit test scaffolding...") - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm wordpress_phpunit /app/bin/install-wp-tests.sh wordpress_test root example mysql $WP_VERSION false > /dev/null - - # Install Composer. This is only used to run WordPress Coding Standards checks. - echo -e $(status_message "Installing and updating Composer modules...") - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm composer install -else - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION - source bin/install-php-phpunit.sh - - # Run the build because otherwise there will be a bunch of warnings about - # failed `stat` calls from `filemtime()`. - composer install -fi - -echo Running with the following versions: -if [[ $DOCKER = "true" ]]; then - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm wordpress_phpunit php -v - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm wordpress_phpunit phpunit --version -else - php -v - phpunit --version -fi - -# Run PHPUnit tests -if [[ $DOCKER = "true" ]]; then - npm run test-php - npm run test-unit-php-multisite -else - phpunit - WP_MULTISITE=1 phpunit -fi diff --git a/bin/setup-local-env.sh b/bin/setup-local-env.sh deleted file mode 100755 index f618780e2d8c1..0000000000000 --- a/bin/setup-local-env.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# Exit if any command fails -set -e - -# Set up environment variables -. "$(dirname "$0")/bootstrap-env.sh" - -# Include useful functions -. "$(dirname "$0")/includes.sh" - -# Change to the expected directory -cd "$(dirname "$0")/.." - -# Check Node and NVM are installed -. "$(dirname "$0")/install-node-nvm.sh" - -# Check Docker is installed and running -. "$(dirname "$0")/install-docker.sh" - -# Set up WordPress Development site. -# Note: we don't bother installing the test site right now, because that's -# done on every time `npm run test-e2e` is run. -. "$(dirname "$0")/install-wordpress.sh" - -# Install the PHPUnit test scaffolding. -echo -e $(status_message "Installing PHPUnit test scaffolding...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm wordpress_phpunit /app/bin/install-wp-tests.sh wordpress_test root example mysql $WP_VERSION false > /dev/null - -# Install Composer. This is only used to run WordPress Coding Standards checks. -echo -e $(status_message "Installing and updating Composer modules...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm composer install - -! read -d '' GUTENBERG <<"EOT" -,⁻⁻⁻· . | -| ،⁓’. . |--- ,---. ,---. |---. ,---. ,---. ,---. -| | | | | |---' | | | | |---' | | | -`---' `---' `---’ `---’ ' ` `---' `---’ ` `---| - `---' -EOT - -CURRENT_URL=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm cli option get siteurl) - -echo -e "\nWelcome to...\n" -echo -e "\033[95m$GUTENBERG\033[0m" - -# Give the user more context to what they should do next: Build Gutenberg and start testing! -echo -e "\nRun $(action_format "npm run dev") to build the latest Gutenberg packages," -echo -e "then open $(action_format "$CURRENT_URL") to get started!" - -echo -e "\n\nAccess the above install using the following credentials:" -echo -e "Default username: $(action_format "admin"), password: $(action_format "password")" diff --git a/bin/setup-travis-e2e-tests.sh b/bin/setup-travis-e2e-tests.sh deleted file mode 100755 index 0594f4724b2e5..0000000000000 --- a/bin/setup-travis-e2e-tests.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Exit if any command fails -set -e - -npm ci - -# Force reduced motion in e2e tests -FORCE_REDUCED_MOTION=true npm run build - -# Set up environment variables -. "$(dirname "$0")/bootstrap-env.sh" - -# Include useful functions -. "$(dirname "$0")/includes.sh" - -# Change to the expected directory -cd "$(dirname "$0")/.." - -# Download image updates. -echo -e $(status_message "Downloading Docker image updates...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS pull mysql wordpress_e2e_tests cli_e2e_tests - -# Launch the containers. -echo -e $(status_message "Starting Docker containers...") -docker-compose $DOCKER_COMPOSE_FILE_OPTIONS up -d --remove-orphans mysql wordpress_e2e_tests cli_e2e_tests >/dev/null - -# Set up WordPress Development site. -. "$(dirname "$0")/install-wordpress.sh" --e2e_tests diff --git a/docker-compose-localdev.yml b/docker-compose-localdev.yml deleted file mode 100644 index 4d58031eaa74b..0000000000000 --- a/docker-compose-localdev.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3.1' - -services: - - wordpress: - volumes: - - ./wordpress:/var/www/html - - cli: - image: wordpress:cli - volumes: - - ./wordpress:/var/www/html diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 723578cce7465..0000000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,88 +0,0 @@ -version: '3.1' - -services: - - wordpress: - image: wordpress - ports: - - 8888:80 - environment: - WORDPRESS_DB_HOST: mysql - WORDPRESS_DB_PASSWORD: example - ABSPATH: /usr/src/wordpress/ - WORDPRESS_DEBUG: 1 - WORDPRESS_CONFIG_EXTRA: | - define( 'SCRIPT_DEBUG', true ); - volumes: - - wordpress_data:/var/www/html - - .:/var/www/html/wp-content/plugins/gutenberg - - ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins - - ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins - depends_on: - - mysql - - cli: - image: wordpress:cli - user: xfs - volumes: - - wordpress_data:/var/www/html - - .:/var/www/html/wp-content/plugins/gutenberg - depends_on: - - mysql - - wordpress - - mysql: - image: mysql:5.7 - environment: - MYSQL_ROOT_PASSWORD: example - MYSQL_DATABASE: wordpress_test - - wordpress_phpunit: - image: chriszarate/wordpress-phpunit - environment: - PHPUNIT_DB_HOST: mysql - volumes: - - .:/app - - testsuite:/tmp - depends_on: - - mysql - - composer: - image: composer - volumes: - - .:/app - - wordpress_e2e_tests: - image: wordpress - ports: - - 8889:80 - environment: - WORDPRESS_DB_HOST: mysql - WORDPRESS_DB_NAME: wordpress_e2e_tests - WORDPRESS_DB_PASSWORD: example - ABSPATH: /usr/src/wordpress/ - WORDPRESS_DEBUG: 1 - WORDPRESS_CONFIG_EXTRA: | - define( 'SCRIPT_DEBUG', true ); - volumes: - - wordpress_e2e_tests_data:/var/www/html - - .:/var/www/html/wp-content/plugins/gutenberg - - ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins - - ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins - depends_on: - - mysql - - cli_e2e_tests: - image: wordpress:cli - user: xfs - volumes: - - wordpress_e2e_tests_data:/var/www/html - - .:/var/www/html/wp-content/plugins/gutenberg - depends_on: - - mysql - - wordpress_e2e_tests - -volumes: - testsuite: - wordpress_data: - wordpress_e2e_tests_data: From 95b671d6080a0c911fb03dee7637e78f47a47e30 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 12:48:08 +1000 Subject: [PATCH 03/91] Retrieve the compose file version from Core's docker-compose.yml, to ensure the override version matches. --- bin/configure-local-env.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/configure-local-env.js b/bin/configure-local-env.js index 4d22d80744329..39bd76fe03964 100644 --- a/bin/configure-local-env.js +++ b/bin/configure-local-env.js @@ -30,9 +30,24 @@ if ( existsSync( composeFile ) ) { } } +const coreComposeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.yml` ); +if ( ! existsSync( coreComposeFile ) ) { + console.log( "docker-compose.yml doesn't seem to exist. Are you sure WP_DEVELOP_DIR is a WordPress source directory?" ); + return; +} + +let coreCompose = {}; +try { + coreCompose = yaml.safeLoad( readFileSync( coreComposeFile, 'utf8' ) ); +} catch ( e ) { + console.log( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.' ); + console.log( e ); + return; +} + console.log( 'Updating docker-compose.override.yml...' ); -compose.version = '3.7'; +compose.version = coreCompose.version; if ( ! compose.services ) { compose.services = {}; From 37ed924805ede413a7a7922ff02690aa9ce16c47 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 13:12:16 +1000 Subject: [PATCH 04/91] Change NPM scripts to use the Core Docker environment. --- bin/docker.js | 18 ++++++++++++++++++ package.json | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 bin/docker.js diff --git a/bin/docker.js b/bin/docker.js new file mode 100644 index 0000000000000..85d1f25e9aef3 --- /dev/null +++ b/bin/docker.js @@ -0,0 +1,18 @@ +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env } = require( 'process' ); +const { normalize } = require( 'path' ); + +/* eslint-disable no-console */ + +if ( ! env.WP_DEVELOP_DIR ) { + console.log( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); + return; +} + +// Execute any docker-compose command passed to this script, in the WordPress Docker environment. +execSync( 'docker-compose ' + process.argv.slice( 2 ).join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + +/* eslint-enable no-console */ diff --git a/package.json b/package.json index c57608863cdcd..f37967071feb7 100644 --- a/package.json +++ b/package.json @@ -189,13 +189,13 @@ "dev:packages": "node ./bin/packages/watch.js", "docs:build": "node ./docs/tool/index.js && node ./bin/update-readmes.js", "fixtures:clean": "rimraf \"packages/e2e-tests/fixtures/blocks/*.+(json|serialized.html)\"", - "fixtures:server-registered": "docker-compose run -w /var/www/html/wp-content/plugins/gutenberg --rm wordpress ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json", + "fixtures:server-registered": "node bin/docker.js run -w /var/www/src/wp-content/plugins/gutenberg --rm php ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json", "fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit", "fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate", "lint": "concurrently \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\" \"npm run lint-types\"", "lint-js": "wp-scripts lint-js", "lint-js:fix": "npm run lint-js -- --fix", - "lint-php": "docker-compose run --rm composer run-script lint", + "lint-php": "node bin/docker.js run --rm composer run-script lint", "lint-pkg-json": "wp-scripts lint-pkg-json ./packages", "lint-css": "wp-scripts lint-style '**/*.scss'", "lint-css:fix": "npm run lint-css -- --fix", @@ -214,8 +214,8 @@ "test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.js", "test-unit:update": "npm run test-unit -- --updateSnapshot", "test-unit:watch": "npm run test-unit -- --watch", - "test-unit-php": "cd $WP_DEVELOP_DIR && npm run test:php -- -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", - "test-unit-php-multisite": "docker-compose run -e WP_MULTISITE=1 --rm wordpress_phpunit phpunit", + "test-unit-php": "node bin/docker.js run --rm phpunit phpunit -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", + "test-unit-php-multisite": "node bin/docker.js run --rm phpunit phpunit run -e WP_MULTISITE=1 --rm phpunit phpunit -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", "test-unit:native": "cd test/native/ && cross-env NODE_ENV=test jest --config ./jest.config.js", "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", From 94be79d61f080f8ea92da29f6583436820971c4b Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 13:22:39 +1000 Subject: [PATCH 05/91] Use local-env in Travis. --- .travis.yml | 76 +++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e16c463eb6ed..e8749455b8440 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,17 @@ branches: before_install: - nvm install + - | + if [[ "$WORDPRESS" = "true" ]]; then + git clone git://develop.git.wordpress.org/ wordpress + cd wordpress + npm run env:start + npm run env:build + npm run env:install + cd .. + export WP_DEVELOP_DIR=./wordpress + npm run env:config + fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true @@ -71,106 +82,67 @@ jobs: - npx lerna run build - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - - name: PHP unit tests (Docker) - env: WP_VERSION=latest DOCKER=true + - name: PHP unit tests + env: WORDPRESS=true script: - - ./bin/run-wp-unit-tests.sh + - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - language: php - php: 5.6 - env: WP_VERSION=latest + env: WORDPRESS=true LOCAL_PHP=5.6-fpm script: - - ./bin/run-wp-unit-tests.sh + - npm run test-php && npm run test-unit-php-multisite if: branch = master and type != "pull_request" - - name: PHP unit tests (PHP 5.3) - env: WP_VERSION=latest SWITCH_TO_PHP=5.3 - script: - - ./bin/run-wp-unit-tests.sh - if: branch = master and type != "pull_request" - - - name: PHP unit tests (PHP 5.2) - env: WP_VERSION=latest SWITCH_TO_PHP=5.2 - script: - - ./bin/run-wp-unit-tests.sh - - name: E2E tests (Admin) (1/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (2/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (3/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (4/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= - install: - - ./bin/setup-travis-e2e-tests.sh + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) allow_failures: - name: JavaScript native mobile tests - - name: PHP unit tests (PHP 5.3) - env: WP_VERSION=latest SWITCH_TO_PHP=5.3 - script: - - ./bin/run-wp-unit-tests.sh - if: branch = master and type != "pull_request" - - - name: PHP unit tests (PHP 5.2) - env: WP_VERSION=latest SWITCH_TO_PHP=5.2 - script: - - ./bin/run-wp-unit-tests.sh before_deploy: - npm install From 04984283ddd8462a6d8974c4b0cc6d30a11f9ef4 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 13:27:28 +1000 Subject: [PATCH 06/91] Run composer locally, instead of in Docker. --- .travis.yml | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8749455b8440..b35fae009ab0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,9 @@ env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true jobs: include: - name: Lint + before_install: + - composer --version + - travis_retry composer install install: - npm ci script: diff --git a/package.json b/package.json index f37967071feb7..e670f73e29979 100644 --- a/package.json +++ b/package.json @@ -195,7 +195,7 @@ "lint": "concurrently \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\" \"npm run lint-types\"", "lint-js": "wp-scripts lint-js", "lint-js:fix": "npm run lint-js -- --fix", - "lint-php": "node bin/docker.js run --rm composer run-script lint", + "lint-php": "composer run-script lint", "lint-pkg-json": "wp-scripts lint-pkg-json ./packages", "lint-css": "wp-scripts lint-style '**/*.scss'", "lint-css:fix": "npm run lint-css -- --fix", From a39012e7d321a6d95553e36dbba4791d4aba41e4 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 13:28:39 +1000 Subject: [PATCH 07/91] Run `npm install` for WordPress in Travis. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b35fae009ab0c..816fba040e509 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ before_install: if [[ "$WORDPRESS" = "true" ]]; then git clone git://develop.git.wordpress.org/ wordpress cd wordpress + npm install npm run env:start npm run env:build npm run env:install From 5a9e154015ff498d8b16c7f0f2eb24fc6152ce00 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 13:43:00 +1000 Subject: [PATCH 08/91] Upgrade Docker on Travis --- .travis.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 816fba040e509..ff74a9c8570d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,13 +26,24 @@ before_install: - nvm install - | if [[ "$WORDPRESS" = "true" ]]; then + # upgrade docker-compose + sudo rm /usr/local/bin/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + + # Check out WordPress git clone git://develop.git.wordpress.org/ wordpress cd wordpress + + # Install WordPress npm install npm run env:start npm run env:build npm run env:install cd .. + + # Add Gutenberg to the WordPress local environment export WP_DEVELOP_DIR=./wordpress npm run env:config fi @@ -42,10 +53,9 @@ env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true jobs: include: - name: Lint - before_install: + install: - composer --version - travis_retry composer install - install: - npm ci script: - npm run lint From 5242cd8b1e9cb954b09ca3a75d94355d8bc58a60 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 14:14:43 +1000 Subject: [PATCH 09/91] Use the right build script name. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff74a9c8570d0..c2e72db82499a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_install: # Install WordPress npm install npm run env:start - npm run env:build + npm run build:dev npm run env:install cd .. From 1cdd12af3777f918ac93751041552aab3f2cce7b Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 14:23:46 +1000 Subject: [PATCH 10/91] Travis needs to `npm ci` for all jobs now. --- .travis.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c2e72db82499a..9033ec4ff4bd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,12 +37,17 @@ before_install: cd wordpress # Install WordPress - npm install + npm ci npm run env:start npm run build:dev npm run env:install cd .. + fi +install: + - npm ci + - | + if [[ "$WORDPRESS" = "true" ]]; then # Add Gutenberg to the WordPress local environment export WP_DEVELOP_DIR=./wordpress npm run env:config @@ -71,14 +76,10 @@ jobs: - npm run check-local-changes - name: License compatibility - install: - - npm ci script: - npm run check-licenses - name: JavaScript unit tests - install: - - npm ci script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -87,8 +88,6 @@ jobs: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests - install: - - npm ci script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom From 32070c174c9ec601e95e534f73e065cc60ee945a Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 14:32:17 +1000 Subject: [PATCH 11/91] push !== append --- bin/configure-local-env.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/configure-local-env.js b/bin/configure-local-env.js index 39bd76fe03964..69920d2e56857 100644 --- a/bin/configure-local-env.js +++ b/bin/configure-local-env.js @@ -75,7 +75,7 @@ services.forEach( ( service ) => { if ( index > -1 ) { compose.services[ service ].volumes[ index ] = gutenbergVolume; } else { - compose.services[ service ].volumes.append( gutenbergVolume ); + compose.services[ service ].volumes.push( gutenbergVolume ); } if ( service === 'wordpress-develop' || service === 'php' ) { @@ -88,7 +88,7 @@ services.forEach( ( service ) => { if ( testPluginsIndex > -1 ) { compose.services[ service ].volumes[ testPluginsIndex ] = testPluginsVolume; } else { - compose.services[ service ].volumes.append( testPluginsVolume ); + compose.services[ service ].volumes.push( testPluginsVolume ); } const muPluginsIndex = compose.services[ service ].volumes.findIndex( ( volume ) => { @@ -100,7 +100,7 @@ services.forEach( ( service ) => { if ( muPluginsIndex > -1 ) { compose.services[ service ].volumes[ muPluginsIndex ] = muPluginsVolume; } else { - compose.services[ service ].volumes.append( muPluginsVolume ); + compose.services[ service ].volumes.push( muPluginsVolume ); } } } ); From edb7b6a6fa2e82281a3bcea3ab70d5e6a8390802 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 14:41:42 +1000 Subject: [PATCH 12/91] Run `composer install` in the PHP Unit Test jobs. --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9033ec4ff4bd4..38009a5f7f185 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,16 +52,18 @@ install: export WP_DEVELOP_DIR=./wordpress npm run env:config fi + - | + if [[ "$COMPOSER" = "true" ]]; then + composer --version + travis_retry composer install + fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true jobs: include: - name: Lint - install: - - composer --version - - travis_retry composer install - - npm ci + env: COMPOSER=true script: - npm run lint @@ -96,12 +98,12 @@ jobs: - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: PHP unit tests - env: WORDPRESS=true + env: WORDPRESS=true COMPOSER=true script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - env: WORDPRESS=true LOCAL_PHP=5.6-fpm + env: WORDPRESS=true COMPOSER=true LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite if: branch = master and type != "pull_request" From 94e456ddb33aecbcf40bcf574645b4ded5675c64 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 14:47:02 +1000 Subject: [PATCH 13/91] Add debugging --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38009a5f7f185..b05c6f3ec2308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ before_install: git clone git://develop.git.wordpress.org/ wordpress cd wordpress - # Install WordPress + # Configure WordPress npm ci npm run env:start npm run build:dev @@ -46,17 +46,19 @@ before_install: install: - npm ci + - | + if [[ "$COMPOSER" = "true" ]]; then + composer --version + pwd + ls -lah + travis_retry composer install + fi - | if [[ "$WORDPRESS" = "true" ]]; then # Add Gutenberg to the WordPress local environment export WP_DEVELOP_DIR=./wordpress npm run env:config fi - - | - if [[ "$COMPOSER" = "true" ]]; then - composer --version - travis_retry composer install - fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true From 1342f4def969f3504c4f6ef19167093340bcc212 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 14:50:53 +1000 Subject: [PATCH 14/91] Change the COMPOSER env var to COMPOSER_INSTALL. The former is used by composer itself. --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b05c6f3ec2308..9537c6033067f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,10 +47,8 @@ before_install: install: - npm ci - | - if [[ "$COMPOSER" = "true" ]]; then + if [[ "$COMPOSER_INSTALL" = "true" ]]; then composer --version - pwd - ls -lah travis_retry composer install fi - | @@ -65,7 +63,7 @@ env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true jobs: include: - name: Lint - env: COMPOSER=true + env: COMPOSER_INSTALL=true script: - npm run lint @@ -100,12 +98,12 @@ jobs: - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: PHP unit tests - env: WORDPRESS=true COMPOSER=true + env: WORDPRESS=true COMPOSER_INSTALL=true script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - env: WORDPRESS=true COMPOSER=true LOCAL_PHP=5.6-fpm + env: WORDPRESS=true COMPOSER_INSTALL=true LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite if: branch = master and type != "pull_request" From c3c2d7ca82df8375f732c41589ec8ddf0e646b62 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 15:05:48 +1000 Subject: [PATCH 15/91] Build Gutenberg before running it. --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9537c6033067f..bb084832c4bfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,7 @@ before_install: install: - npm ci + - npm run build - | if [[ "$COMPOSER_INSTALL" = "true" ]]; then composer --version @@ -109,49 +110,49 @@ jobs: if: branch = master and type != "pull_request" - name: E2E tests (Admin) (1/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (2/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (3/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (4/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) From a679ae99f44848ec65ddfff9a8b5eaca8d056742 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 15:30:47 +1000 Subject: [PATCH 16/91] Fix the PHPUnit multisite test command. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e670f73e29979..e36eba5f78a73 100644 --- a/package.json +++ b/package.json @@ -215,7 +215,7 @@ "test-unit:update": "npm run test-unit -- --updateSnapshot", "test-unit:watch": "npm run test-unit -- --watch", "test-unit-php": "node bin/docker.js run --rm phpunit phpunit -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", - "test-unit-php-multisite": "node bin/docker.js run --rm phpunit phpunit run -e WP_MULTISITE=1 --rm phpunit phpunit -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", + "test-unit-php-multisite": "node bin/docker.js run --rm -e WP_MULTISITE=1 phpunit phpunit -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", "test-unit:native": "cd test/native/ && cross-env NODE_ENV=test jest --config ./jest.config.js", "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", From bd92a8df915a250cde68cb5376d0c5adffb113cf Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 16:16:04 +1000 Subject: [PATCH 17/91] Activate the Gutenberg plugin after installing it. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index bb084832c4bfc..5eb271f153b21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,6 +57,8 @@ install: # Add Gutenberg to the WordPress local environment export WP_DEVELOP_DIR=./wordpress npm run env:config + + node bin/docker.js run --rm cli plugin activate gutenberg fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true From 020f721cde8e05281ca61fbcb85ff4a0448dbf2c Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 17:10:36 +1000 Subject: [PATCH 18/91] Run e2e tests against the build dir. --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5eb271f153b21..03725739d0d68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -112,49 +112,49 @@ jobs: if: branch = master and type != "pull_request" - name: E2E tests (Admin) (1/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (2/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (3/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (4/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) From cfd0933d56d44a8eb1b1fd8a4329523d8c0f2ec7 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 13 Aug 2019 17:19:10 +1000 Subject: [PATCH 19/91] Build to the build dir --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 03725739d0d68..cc5cafa2b3c66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_install: # Configure WordPress npm ci npm run env:start - npm run build:dev + npm run build npm run env:install cd .. fi From 88bb0b836e050fe7b6e88f8b14aa1bfc9544b2a4 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 10:46:31 +1000 Subject: [PATCH 20/91] Gutenberg is in the build directory on Travis. --- .travis.yml | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc5cafa2b3c66..6096c10492092 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ install: export WP_DEVELOP_DIR=./wordpress npm run env:config - node bin/docker.js run --rm cli plugin activate gutenberg + node bin/docker.js run --rm cli plugin activate gutenberg --path=build fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true diff --git a/package.json b/package.json index e36eba5f78a73..9ebc69d69eab8 100644 --- a/package.json +++ b/package.json @@ -214,8 +214,8 @@ "test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.js", "test-unit:update": "npm run test-unit -- --updateSnapshot", "test-unit:watch": "npm run test-unit -- --watch", - "test-unit-php": "node bin/docker.js run --rm phpunit phpunit -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", - "test-unit-php-multisite": "node bin/docker.js run --rm -e WP_MULTISITE=1 phpunit phpunit -c /wordpress-develop/src/wp-content/plugins/gutenberg/phpunit.xml.dist", + "test-unit-php": "node bin/docker.js run --rm phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", + "test-unit-php-multisite": "node bin/docker.js run --rm -e WP_MULTISITE=1 phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", "test-unit:native": "cd test/native/ && cross-env NODE_ENV=test jest --config ./jest.config.js", "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", From 96af4a17f96e16becffd592f0b6828b2ce7a3027 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 10:55:40 +1000 Subject: [PATCH 21/91] Travis debugging. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6096c10492092..abf5edd1c4f43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,6 +57,7 @@ install: # Add Gutenberg to the WordPress local environment export WP_DEVELOP_DIR=./wordpress npm run env:config + cat wordpress/docker-compose.override.yml node bin/docker.js run --rm cli plugin activate gutenberg --path=build fi From dbfe7ad097df634a5a608124fbf3cfad8d3cf38d Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 10:58:52 +1000 Subject: [PATCH 22/91] Run PHP unit tests in the build dir. --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index abf5edd1c4f43..38245b17454b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,15 +102,14 @@ jobs: - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: PHP unit tests - env: WORDPRESS=true COMPOSER_INSTALL=true + env: WORDPRESS=true LOCAL_DIR=build COMPOSER_INSTALL=true script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - env: WORDPRESS=true COMPOSER_INSTALL=true LOCAL_PHP=5.6-fpm + env: WORDPRESS=true LOCAL_DIR=build COMPOSER_INSTALL=true LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite - if: branch = master and type != "pull_request" - name: E2E tests (Admin) (1/4) env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= From 4cbd9785713d173fb37d4ed3cbb85694de2330b2 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 11:08:26 +1000 Subject: [PATCH 23/91] Configure WordPress to load from the build directory. --- .travis.yml | 1 - phpunit.xml.dist | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38245b17454b6..7b087723c72bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,7 +57,6 @@ install: # Add Gutenberg to the WordPress local environment export WP_DEVELOP_DIR=./wordpress npm run env:config - cat wordpress/docker-compose.override.yml node bin/docker.js run --rm cli plugin activate gutenberg --path=build fi diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e799a44754caf..b0d33bcc286f7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,4 +11,7 @@ ./phpunit/ + + + From c99524cba16fc71b3709876f171967fa1bf6ecba Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 11:12:34 +1000 Subject: [PATCH 24/91] Run author e2e tests as an author. --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b087723c72bd..80b19b6f4177e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,11 @@ install: node bin/docker.js run --rm cli plugin activate gutenberg --path=build fi + - | + if [[ "$E2E_ROLE" = "author" ]]; then + node bin/docker.js run --rm cli user create author author@example.com --role=author --user_pass=authpass --path=build + node bin/docker.js run --rm -u 33 $CLI post update 1 --post_author=2 + fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true @@ -135,25 +140,25 @@ jobs: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) From d372e1f04144998dec2246df83aed1cd1f144fb7 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 11:20:07 +1000 Subject: [PATCH 25/91] Fix the command for setting up the author user. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 80b19b6f4177e..1d93baade313b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,7 @@ install: - | if [[ "$E2E_ROLE" = "author" ]]; then node bin/docker.js run --rm cli user create author author@example.com --role=author --user_pass=authpass --path=build - node bin/docker.js run --rm -u 33 $CLI post update 1 --post_author=2 + node bin/docker.js run --rm cli post update 1 --post_author=2 --path=build fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true From c8dd498ae1d60d01bb4395daf48675942645ba57 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 11:59:32 +1000 Subject: [PATCH 26/91] Travis: create the uploads directory. --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1d93baade313b..0f31cff2f5f6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ before_install: # Check out WordPress git clone git://develop.git.wordpress.org/ wordpress + cd wordpress # Configure WordPress @@ -41,6 +42,10 @@ before_install: npm run env:start npm run build npm run env:install + + mkdir -p build/wp-content/uploads + chmod 767 build/wp-content/uploads + cd .. fi From f8f64606ca632dad6bf7c0f41577210b72d8483e Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 12:35:04 +1000 Subject: [PATCH 27/91] Travis: Don't need to disable SCRIPT_DEBUG for e2e tests. --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f31cff2f5f6d..c33aa9efce81a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -121,49 +121,49 @@ jobs: - npm run test-php && npm run test-unit-php-multisite - name: E2E tests (Admin) (1/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (2/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (3/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (4/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - env: WORDPRESS=true LOCAL_SCRIPT_DEBUG=false E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) From f10a38aade44fad8685b9f3bc276f167a8b453c9 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Aug 2019 09:42:05 +1000 Subject: [PATCH 28/91] Move the env scripts to wp-scripts. --- .travis.yml | 4 +-- package-lock.json | 1 + package.json | 14 +++++---- packages/scripts/package.json | 1 + packages/scripts/scripts/env.js | 23 ++++++++++++++ .../scripts/scripts/env/connect.js | 30 ++++++++----------- .../scripts/scripts/env}/docker.js | 10 ++----- 7 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 packages/scripts/scripts/env.js rename bin/configure-local-env.js => packages/scripts/scripts/env/connect.js (77%) rename {bin => packages/scripts/scripts/env}/docker.js (59%) diff --git a/.travis.yml b/.travis.yml index c33aa9efce81a..f17f69e04ac6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ notifications: cache: directories: - - $HOME/.composer/cache - $HOME/.jest-cache - $HOME/.npm - $HOME/.nvm/.cache @@ -54,8 +53,7 @@ install: - npm run build - | if [[ "$COMPOSER_INSTALL" = "true" ]]; then - composer --version - travis_retry composer install + node bin/docker.js run -w /var/www/build/wp-content/plugins/gutenberg --rm php composer install fi - | if [[ "$WORDPRESS" = "true" ]]; then diff --git a/package-lock.json b/package-lock.json index d9a9cac611968..912e462b6bf21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5272,6 +5272,7 @@ "eslint": "^6.1.0", "jest": "^24.7.1", "jest-puppeteer": "^4.3.0", + "js-yaml": "3.13.1", "minimist": "^1.2.0", "npm-package-json-lint": "^3.6.0", "puppeteer": "^1.19.0", diff --git a/package.json b/package.json index 9ebc69d69eab8..606740fee4ff9 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,6 @@ "is-equal-shallow": "0.1.3", "jest-junit": "6.4.0", "jest-serializer-enzyme": "1.0.0", - "js-yaml": "3.13.1", "jsdom": "11.12.0", "lerna": "3.16.4", "lint-staged": "8.1.5", @@ -189,13 +188,13 @@ "dev:packages": "node ./bin/packages/watch.js", "docs:build": "node ./docs/tool/index.js && node ./bin/update-readmes.js", "fixtures:clean": "rimraf \"packages/e2e-tests/fixtures/blocks/*.+(json|serialized.html)\"", - "fixtures:server-registered": "node bin/docker.js run -w /var/www/src/wp-content/plugins/gutenberg --rm php ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json", + "fixtures:server-registered": "wp-scripts env docker run -w /var/www/src/wp-content/plugins/gutenberg --rm php ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json", "fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit", "fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate", "lint": "concurrently \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\" \"npm run lint-types\"", "lint-js": "wp-scripts lint-js", "lint-js:fix": "npm run lint-js -- --fix", - "lint-php": "composer run-script lint", + "lint-php": "wp-scripts env docker run -w /var/www/build/wp-content/plugins/gutenberg --rm php composer run-script lint", "lint-pkg-json": "wp-scripts lint-pkg-json ./packages", "lint-css": "wp-scripts lint-style '**/*.scss'", "lint-css:fix": "npm run lint-css -- --fix", @@ -214,13 +213,13 @@ "test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.js", "test-unit:update": "npm run test-unit -- --updateSnapshot", "test-unit:watch": "npm run test-unit -- --watch", - "test-unit-php": "node bin/docker.js run --rm phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", - "test-unit-php-multisite": "node bin/docker.js run --rm -e WP_MULTISITE=1 phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", + "test-unit-php": "wp-scripts env docker run --rm phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", + "test-unit-php-multisite": "wp-scripts env docker run --rm -e WP_MULTISITE=1 phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", "test-unit:native": "cd test/native/ && cross-env NODE_ENV=test jest --config ./jest.config.js", "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", "playground:start": "concurrently \"npm run dev:packages\" \"parcel playground/src/index.html -d playground/dist\"", - "env:config": "node bin/configure-local-env.js" + "env": "wp-scripts env" }, "lint-staged": { "packages/*/package.json": [ @@ -238,5 +237,8 @@ "packages/**/*.js": [ "node ./bin/update-readmes.js" ] + }, + "wp-env": { + "plugin-dir": "gutenberg" } } diff --git a/packages/scripts/package.json b/packages/scripts/package.json index eb3e0f90fa934..9a9f06f46783b 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -45,6 +45,7 @@ "eslint": "^6.1.0", "jest": "^24.7.1", "jest-puppeteer": "^4.3.0", + "js-yaml": "3.13.1", "minimist": "^1.2.0", "npm-package-json-lint": "^3.6.0", "puppeteer": "^1.19.0", diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js new file mode 100644 index 0000000000000..2af615ad99c9b --- /dev/null +++ b/packages/scripts/scripts/env.js @@ -0,0 +1,23 @@ +/** + * Node dependencies. + */ +const { exit, stdout } = require( 'process' ); + +/** + * Internal dependencies + */ +const { + getArgsFromCLI, + spawnScript, +} = require( '../utils' ); + +const args = getArgsFromCLI(); + +if ( ! args.length ) { + stdout.write( 'Environment command required.' ); + exit( 1 ); +} + +const command = args.shift(); + +spawnScript( `env/${ command }`, args ); diff --git a/bin/configure-local-env.js b/packages/scripts/scripts/env/connect.js similarity index 77% rename from bin/configure-local-env.js rename to packages/scripts/scripts/env/connect.js index 69920d2e56857..4d230de02e8b8 100644 --- a/bin/configure-local-env.js +++ b/packages/scripts/scripts/env/connect.js @@ -8,14 +8,12 @@ const yaml = require( 'js-yaml' ); */ const { existsSync, readFileSync, writeFileSync } = require( 'fs' ); const { normalize } = require( 'path' ); -const { cwd, env } = require( 'process' ); +const { cwd, env, exit, stdout } = require( 'process' ); const { execSync } = require( 'child_process' ); -/* eslint-disable no-console */ - if ( ! env.WP_DEVELOP_DIR ) { - console.log( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); - return; + stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); + exit( 1 ); } const composeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.override.yml` ); @@ -24,28 +22,28 @@ if ( existsSync( composeFile ) ) { try { compose = yaml.safeLoad( readFileSync( composeFile, 'utf8' ) ); } catch ( e ) { - console.log( 'There was an error loading your docker-compose.override.yml file. Please fix or delete it, and try again.' ); - console.log( e ); - return; + stdout.write( 'There was an error loading your docker-compose.override.yml file. Please fix or delete it, and try again.' ); + stdout.write( e ); + exit( 1 ); } } const coreComposeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.yml` ); if ( ! existsSync( coreComposeFile ) ) { - console.log( "docker-compose.yml doesn't seem to exist. Are you sure WP_DEVELOP_DIR is a WordPress source directory?" ); - return; + stdout.write( "docker-compose.yml doesn't seem to exist. Are you sure WP_DEVELOP_DIR is a WordPress source directory?" ); + exit( 1 ); } let coreCompose = {}; try { coreCompose = yaml.safeLoad( readFileSync( coreComposeFile, 'utf8' ) ); } catch ( e ) { - console.log( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.' ); - console.log( e ); - return; + stdout.write( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.' ); + stdout.write( e ); + exit( 1 ); } -console.log( 'Updating docker-compose.override.yml...' ); +stdout.write( 'Updating docker-compose.override.yml...' ); compose.version = coreCompose.version; @@ -107,9 +105,7 @@ services.forEach( ( service ) => { writeFileSync( composeFile, yaml.safeDump( compose, { lineWidth: -1 } ) ); -console.log( 'Restarting the WordPress environment...' ); +stdout.write( 'Restarting the WordPress environment...' ); execSync( 'npm run env:stop', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); - -/* eslint-enable no-console */ diff --git a/bin/docker.js b/packages/scripts/scripts/env/docker.js similarity index 59% rename from bin/docker.js rename to packages/scripts/scripts/env/docker.js index 85d1f25e9aef3..aebf1a25927d7 100644 --- a/bin/docker.js +++ b/packages/scripts/scripts/env/docker.js @@ -2,17 +2,13 @@ * Node dependencies. */ const { execSync } = require( 'child_process' ); -const { env } = require( 'process' ); +const { env, exit, stdout } = require( 'process' ); const { normalize } = require( 'path' ); -/* eslint-disable no-console */ - if ( ! env.WP_DEVELOP_DIR ) { - console.log( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); - return; + stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); + exit( 1 ); } // Execute any docker-compose command passed to this script, in the WordPress Docker environment. execSync( 'docker-compose ' + process.argv.slice( 2 ).join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); - -/* eslint-enable no-console */ From 02ca863499eec42a928105053964e26ab720bdc1 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Aug 2019 11:05:40 +1000 Subject: [PATCH 29/91] Add a bunch of env helper scripts. --- .travis.yml | 10 +++++----- package.json | 8 ++++---- packages/scripts/scripts/env.js | 7 ++++++- packages/scripts/scripts/env/cli.js | 18 ++++++++++++++++++ packages/scripts/scripts/env/connect.js | 9 ++------- packages/scripts/scripts/env/docker-run.js | 18 ++++++++++++++++++ packages/scripts/scripts/env/docker.js | 14 -------------- packages/scripts/scripts/env/lint-php.js | 18 ++++++++++++++++++ packages/scripts/scripts/env/test-php.js | 18 ++++++++++++++++++ 9 files changed, 89 insertions(+), 31 deletions(-) create mode 100644 packages/scripts/scripts/env/cli.js create mode 100644 packages/scripts/scripts/env/docker-run.js delete mode 100644 packages/scripts/scripts/env/docker.js create mode 100644 packages/scripts/scripts/env/lint-php.js create mode 100644 packages/scripts/scripts/env/test-php.js diff --git a/.travis.yml b/.travis.yml index f17f69e04ac6c..5d666594f5fd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,20 +53,20 @@ install: - npm run build - | if [[ "$COMPOSER_INSTALL" = "true" ]]; then - node bin/docker.js run -w /var/www/build/wp-content/plugins/gutenberg --rm php composer install + npm run env docker-run -- php composer install fi - | if [[ "$WORDPRESS" = "true" ]]; then # Add Gutenberg to the WordPress local environment export WP_DEVELOP_DIR=./wordpress - npm run env:config + npm run env connect - node bin/docker.js run --rm cli plugin activate gutenberg --path=build + npm run env cli plugin activate gutenberg fi - | if [[ "$E2E_ROLE" = "author" ]]; then - node bin/docker.js run --rm cli user create author author@example.com --role=author --user_pass=authpass --path=build - node bin/docker.js run --rm cli post update 1 --post_author=2 --path=build + npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build + npm run env cli -- post update 1 --post_author=2 --path=build fi env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true diff --git a/package.json b/package.json index 606740fee4ff9..6df3055470379 100644 --- a/package.json +++ b/package.json @@ -188,13 +188,13 @@ "dev:packages": "node ./bin/packages/watch.js", "docs:build": "node ./docs/tool/index.js && node ./bin/update-readmes.js", "fixtures:clean": "rimraf \"packages/e2e-tests/fixtures/blocks/*.+(json|serialized.html)\"", - "fixtures:server-registered": "wp-scripts env docker run -w /var/www/src/wp-content/plugins/gutenberg --rm php ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json", + "fixtures:server-registered": "wp-scripts env docker-run php ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json", "fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit", "fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate", "lint": "concurrently \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\" \"npm run lint-types\"", "lint-js": "wp-scripts lint-js", "lint-js:fix": "npm run lint-js -- --fix", - "lint-php": "wp-scripts env docker run -w /var/www/build/wp-content/plugins/gutenberg --rm php composer run-script lint", + "lint-php": "wp-scripts env lint-php", "lint-pkg-json": "wp-scripts lint-pkg-json ./packages", "lint-css": "wp-scripts lint-style '**/*.scss'", "lint-css:fix": "npm run lint-css -- --fix", @@ -213,8 +213,8 @@ "test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.js", "test-unit:update": "npm run test-unit -- --updateSnapshot", "test-unit:watch": "npm run test-unit -- --watch", - "test-unit-php": "wp-scripts env docker run --rm phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", - "test-unit-php-multisite": "wp-scripts env docker run --rm -e WP_MULTISITE=1 phpunit phpunit -c /wordpress-develop/build/wp-content/plugins/gutenberg/phpunit.xml.dist", + "test-unit-php": "wp-scripts env test-php", + "test-unit-php-multisite": "cross-env WP_MULTISITE=1 wp-scripts env test-php", "test-unit:native": "cd test/native/ && cross-env NODE_ENV=test jest --config ./jest.config.js", "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js index 2af615ad99c9b..16a67d161fd19 100644 --- a/packages/scripts/scripts/env.js +++ b/packages/scripts/scripts/env.js @@ -1,7 +1,7 @@ /** * Node dependencies. */ -const { exit, stdout } = require( 'process' ); +const { env, exit, stdout } = require( 'process' ); /** * Internal dependencies @@ -11,6 +11,11 @@ const { spawnScript, } = require( '../utils' ); +if ( ! env.WP_DEVELOP_DIR ) { + stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); + exit( 1 ); +} + const args = getArgsFromCLI(); if ( ! args.length ) { diff --git a/packages/scripts/scripts/env/cli.js b/packages/scripts/scripts/env/cli.js new file mode 100644 index 0000000000000..05d083daae3e1 --- /dev/null +++ b/packages/scripts/scripts/env/cli.js @@ -0,0 +1,18 @@ +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env } = require( 'process' ); +const { normalize } = require( 'path' ); + +/** + * Internal dependencies + */ +const { getArgsFromCLI } = require( '../../utils' ); + +const args = getArgsFromCLI(); + +const localDir = env.LOCAL_DIR || 'src'; + +// Run PHPUnit with the working directory set correctly. +execSync( `npm run env:cli -- --path=${ localDir } ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 4d230de02e8b8..0c08b2e23353a 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -11,11 +11,6 @@ const { normalize } = require( 'path' ); const { cwd, env, exit, stdout } = require( 'process' ); const { execSync } = require( 'child_process' ); -if ( ! env.WP_DEVELOP_DIR ) { - stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); - exit( 1 ); -} - const composeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.override.yml` ); let compose = {}; if ( existsSync( composeFile ) ) { @@ -23,7 +18,7 @@ if ( existsSync( composeFile ) ) { compose = yaml.safeLoad( readFileSync( composeFile, 'utf8' ) ); } catch ( e ) { stdout.write( 'There was an error loading your docker-compose.override.yml file. Please fix or delete it, and try again.' ); - stdout.write( e ); + stdout.write( e.toString() ); exit( 1 ); } } @@ -39,7 +34,7 @@ try { coreCompose = yaml.safeLoad( readFileSync( coreComposeFile, 'utf8' ) ); } catch ( e ) { stdout.write( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.' ); - stdout.write( e ); + stdout.write( e.toString() ); exit( 1 ); } diff --git a/packages/scripts/scripts/env/docker-run.js b/packages/scripts/scripts/env/docker-run.js new file mode 100644 index 0000000000000..533538c79da07 --- /dev/null +++ b/packages/scripts/scripts/env/docker-run.js @@ -0,0 +1,18 @@ +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env } = require( 'process' ); +const { normalize } = require( 'path' ); + +/** + * Internal dependencies + */ +const { getArgsFromCLI } = require( '../../utils' ); + +const args = getArgsFromCLI(); + +const localDir = env.LOCAL_DIR || 'src'; + +// Execute any docker-compose command passed to this script, in the WordPress Docker environment. +execSync( `docker-compose run -w /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir } --rm ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/docker.js b/packages/scripts/scripts/env/docker.js deleted file mode 100644 index aebf1a25927d7..0000000000000 --- a/packages/scripts/scripts/env/docker.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Node dependencies. - */ -const { execSync } = require( 'child_process' ); -const { env, exit, stdout } = require( 'process' ); -const { normalize } = require( 'path' ); - -if ( ! env.WP_DEVELOP_DIR ) { - stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); - exit( 1 ); -} - -// Execute any docker-compose command passed to this script, in the WordPress Docker environment. -execSync( 'docker-compose ' + process.argv.slice( 2 ).join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/lint-php.js b/packages/scripts/scripts/env/lint-php.js new file mode 100644 index 0000000000000..b7acb5020f4ba --- /dev/null +++ b/packages/scripts/scripts/env/lint-php.js @@ -0,0 +1,18 @@ +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env } = require( 'process' ); +const { normalize } = require( 'path' ); + +/** + * Internal dependencies + */ +const { getArgsFromCLI } = require( '../../utils' ); + +const args = getArgsFromCLI(); + +const localDir = env.LOCAL_DIR || 'src'; + +// Run PHPUnit with the working directory set correctly. +execSync( `docker-compose run --rm -w /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir } php composer lint ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/test-php.js b/packages/scripts/scripts/env/test-php.js new file mode 100644 index 0000000000000..855b8f02cf4d2 --- /dev/null +++ b/packages/scripts/scripts/env/test-php.js @@ -0,0 +1,18 @@ +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env } = require( 'process' ); +const { normalize } = require( 'path' ); + +/** + * Internal dependencies + */ +const { getArgsFromCLI } = require( '../../utils' ); + +const args = getArgsFromCLI(); + +const localDir = env.LOCAL_DIR || 'src'; + +// Run PHPUnit with the working directory set correctly. +execSync( `npm run test:php -- -c /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit.xml.dist ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); From 92c0117b5244db2188268e9104b9811f3fd2cf49 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Aug 2019 11:15:14 +1000 Subject: [PATCH 30/91] Travis: Composer tasks need WP installed, now. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d666594f5fd1..3503b5faedcbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,10 +51,6 @@ before_install: install: - npm ci - npm run build - - | - if [[ "$COMPOSER_INSTALL" = "true" ]]; then - npm run env docker-run -- php composer install - fi - | if [[ "$WORDPRESS" = "true" ]]; then # Add Gutenberg to the WordPress local environment @@ -63,6 +59,10 @@ install: npm run env cli plugin activate gutenberg fi + - | + if [[ "$COMPOSER_INSTALL" = "true" ]]; then + npm run env docker-run -- php composer install + fi - | if [[ "$E2E_ROLE" = "author" ]]; then npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build @@ -74,7 +74,7 @@ env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true jobs: include: - name: Lint - env: COMPOSER_INSTALL=true + env: WORDPRESS=true COMPOSER_INSTALL=true script: - npm run lint From 370ef5248dbcd22f888fefccec0e234c0b48bcab Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Aug 2019 11:25:23 +1000 Subject: [PATCH 31/91] Fix the mount directory in the PHPUnit container. --- packages/scripts/scripts/env/connect.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 0c08b2e23353a..2405bd4825006 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -61,9 +61,7 @@ services.forEach( ( service ) => { return volume.endsWith( '/plugins/gutenberg' ); } ); - const gutenbergVolume = ( service === 'phpunit' ) ? - normalize( cwd() ) + ':/wordpress-develop/${LOCAL_DIR-src}/wp-content/plugins/gutenberg' : - normalize( cwd() ) + ':/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg'; + const gutenbergVolume = normalize( cwd() ) + ':/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg'; if ( index > -1 ) { compose.services[ service ].volumes[ index ] = gutenbergVolume; From 273c76160f2fb06409f347ca21dcd1bccec4265e Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Aug 2019 11:32:02 +1000 Subject: [PATCH 32/91] Don't lint CSS in the WordPress directory. --- .travis.yml | 2 +- packages/scripts/config/.stylelintignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3503b5faedcbe..c58e7de4c00dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_install: sudo mv docker-compose /usr/local/bin # Check out WordPress - git clone git://develop.git.wordpress.org/ wordpress + git clone --depth=1 git://develop.git.wordpress.org/ wordpress cd wordpress diff --git a/packages/scripts/config/.stylelintignore b/packages/scripts/config/.stylelintignore index ae6cdbfb623bb..c551598526f04 100644 --- a/packages/scripts/config/.stylelintignore +++ b/packages/scripts/config/.stylelintignore @@ -1,3 +1,4 @@ # By default, all `node_modules` are ignored. build +wordpress From 9e48716b06412fd7ce50d77c169ce972816c58f3 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Aug 2019 11:55:30 +1000 Subject: [PATCH 33/91] Disable SCRIPT_DEBUG, and clean up the globals. --- .travis.yml | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index c58e7de4c00dc..0bc4fdde3117e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,14 @@ branches: only: - master +env: + global: + - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true + - LOCAL_DIR: build + - LOCAL_SCRIPT_DEBUG: false + - COMPOSER_INSTALL: false + - WORDPRESS: true + before_install: - nvm install - | @@ -69,16 +77,15 @@ install: npm run env cli -- post update 1 --post_author=2 --path=build fi -env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true - jobs: include: - name: Lint - env: WORDPRESS=true COMPOSER_INSTALL=true + env: COMPOSER_INSTALL=true script: - npm run lint - name: Build artifacts + env: WORDPRESS=false install: # A "full" install is executed, since `npm ci` does not always exit # with an error status code if the lock file is inaccurate. @@ -89,10 +96,12 @@ jobs: - npm run check-local-changes - name: License compatibility + env: WORDPRESS=false script: - npm run check-licenses - name: JavaScript unit tests + env: WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -101,6 +110,7 @@ jobs: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests + env: WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -109,59 +119,59 @@ jobs: - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: PHP unit tests - env: WORDPRESS=true LOCAL_DIR=build COMPOSER_INSTALL=true + env: COMPOSER_INSTALL=true script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - env: WORDPRESS=true LOCAL_DIR=build COMPOSER_INSTALL=true LOCAL_PHP=5.6-fpm + env: COMPOSER_INSTALL=true LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite - name: E2E tests (Admin) (1/4) - env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (2/4) - env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (3/4) - env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (4/4) - env: WORDPRESS=true LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - env: WORDPRESS=true E2E_ROLE=author LOCAL_DIR=build FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) From 1e948c99c01f1d44574705f2602f3e98dd611f55 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Aug 2019 13:58:32 +1000 Subject: [PATCH 34/91] Generate docker-compose.override.yml from a template file. --- .../docker-compose.override.yml.template | 17 ++++ packages/scripts/scripts/env/connect.js | 99 +++++++++---------- 2 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 packages/scripts/config/docker-compose.override.yml.template diff --git a/packages/scripts/config/docker-compose.override.yml.template b/packages/scripts/config/docker-compose.override.yml.template new file mode 100644 index 0000000000000..43d2fc0fddb8f --- /dev/null +++ b/packages/scripts/config/docker-compose.override.yml.template @@ -0,0 +1,17 @@ +services: + wordpress-develop: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + php: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + cli: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg + phpunit: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 2405bd4825006..37b26bee270e5 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -11,6 +11,11 @@ const { normalize } = require( 'path' ); const { cwd, env, exit, stdout } = require( 'process' ); const { execSync } = require( 'child_process' ); +/** + * Internal dependencies + */ +const { fromConfigRoot } = require( '../../utils' ); + const composeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.override.yml` ); let compose = {}; if ( existsSync( composeFile ) ) { @@ -33,70 +38,64 @@ let coreCompose = {}; try { coreCompose = yaml.safeLoad( readFileSync( coreComposeFile, 'utf8' ) ); } catch ( e ) { - stdout.write( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.' ); + stdout.write( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.' ); stdout.write( e.toString() ); exit( 1 ); } -stdout.write( 'Updating docker-compose.override.yml...' ); - -compose.version = coreCompose.version; - -if ( ! compose.services ) { - compose.services = {}; -} - -const services = [ 'wordpress-develop', 'php', 'cli', 'phpunit' ]; - -services.forEach( ( service ) => { - if ( ! compose.services[ service ] ) { - compose.services[ service ] = {}; - } - - if ( ! compose.services[ service ].volumes ) { - compose.services[ service ].volumes = []; - } - - const index = compose.services[ service ].volumes.findIndex( ( volume ) => { - return volume.endsWith( '/plugins/gutenberg' ); - } ); +const pluginMountDir = normalize( cwd() ); - const gutenbergVolume = normalize( cwd() ) + ':/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg'; +const composeTemplate = readFileSync( fromConfigRoot( 'docker-compose.override.yml.template' ), 'utf8' ) + .replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir ); - if ( index > -1 ) { - compose.services[ service ].volumes[ index ] = gutenbergVolume; - } else { - compose.services[ service ].volumes.push( gutenbergVolume ); - } +const pluginCompose = yaml.safeLoad( composeTemplate ); - if ( service === 'wordpress-develop' || service === 'php' ) { - const testPluginsIndex = compose.services[ service ].volumes.findIndex( ( volume ) => { - return volume.endsWith( '/plugins/gutenberg-test-plugins' ); - } ); +stdout.write( 'Updating docker-compose.override.yml...' ); - const testPluginsVolume = normalize( cwd() + '/packages/e2e-tests/plugins' ) + ':/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins'; +compose.version = coreCompose.version; - if ( testPluginsIndex > -1 ) { - compose.services[ service ].volumes[ testPluginsIndex ] = testPluginsVolume; +/** + * Merges two YAML configs together. + * + * All new data from newConfig will be added to originalConfig. When arrays in newConfig look like lists of volume + * mount instructions, it will attempt to replace items that mount from the same location. This allows the config + * to be safely updated, and it'll be reflected in the updated config. + * + * @param {Object} originalConfig The original config object that we're overwriting. + * @param {Object} newConfig A new config object to merge into originalConfig. + * @return {Object} The merged config object. + */ +function mergeConfigs( originalConfig, newConfig ) { + Object.keys( newConfig ).forEach( ( key ) => { + if ( ! originalConfig[ key ] ) { + originalConfig[ key ] = newConfig[ key ]; + } else if ( newConfig[ key ] instanceof Array ) { + newConfig[ key ].forEach( ( element ) => { + if ( element.startsWith( pluginMountDir ) && element.includes( ':' ) ) { + const mountDir = element.split( ':' )[ 0 ]; + const index = originalConfig[ key ].findIndex( ( volume ) => { + return volume.startsWith( `${ mountDir }:` ); + } ); + if ( index > -1 ) { + originalConfig[ key ][ index ] = element; + } else { + originalConfig[ key ].push( element ); + } + } + } ); + } else if ( newConfig[ key ] instanceof Object ) { + originalConfig[ key ] = mergeConfigs( originalConfig[ key ], newConfig[ key ] ); } else { - compose.services[ service ].volumes.push( testPluginsVolume ); + originalConfig[ key ] = newConfig[ key ]; } + } ); - const muPluginsIndex = compose.services[ service ].volumes.findIndex( ( volume ) => { - return volume.endsWith( '/mu-plugins' ); - } ); - - const muPluginsVolume = normalize( cwd() + '/packages/e2e-tests/mu-plugins' ) + ':/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins'; + return originalConfig; +} - if ( muPluginsIndex > -1 ) { - compose.services[ service ].volumes[ muPluginsIndex ] = muPluginsVolume; - } else { - compose.services[ service ].volumes.push( muPluginsVolume ); - } - } -} ); +const mergedCompose = mergeConfigs( compose, pluginCompose ); -writeFileSync( composeFile, yaml.safeDump( compose, { lineWidth: -1 } ) ); +writeFileSync( composeFile, yaml.safeDump( mergedCompose, { lineWidth: -1 } ) ); stdout.write( 'Restarting the WordPress environment...' ); From 8b0c239d5b7e745b360a57d5d3a9f7498ad27163 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 16 Aug 2019 14:48:50 +1000 Subject: [PATCH 35/91] Add start/stop scripts. --- packages/scripts/scripts/env/start.js | 9 +++++++++ packages/scripts/scripts/env/stop.js | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 packages/scripts/scripts/env/start.js create mode 100644 packages/scripts/scripts/env/stop.js diff --git a/packages/scripts/scripts/env/start.js b/packages/scripts/scripts/env/start.js new file mode 100644 index 0000000000000..318a7dc87d02f --- /dev/null +++ b/packages/scripts/scripts/env/start.js @@ -0,0 +1,9 @@ +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env } = require( 'process' ); +const { normalize } = require( 'path' ); + +// Start the environment in the WordPress directory. +execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/stop.js b/packages/scripts/scripts/env/stop.js new file mode 100644 index 0000000000000..444faae7d98ed --- /dev/null +++ b/packages/scripts/scripts/env/stop.js @@ -0,0 +1,10 @@ + +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env } = require( 'process' ); +const { normalize } = require( 'path' ); + +// Stop the environment in the WordPress directory. +execSync( 'npm run env:stop', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); From fcc14676ad5bb3c023dab5923c26424a3f734c13 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 16 Aug 2019 16:09:14 +1000 Subject: [PATCH 36/91] Add an install script. --- .travis.yml | 13 +- package-lock.json | 194 ++++++++++++++++++++++++ packages/scripts/package.json | 3 + packages/scripts/scripts/env.js | 20 ++- packages/scripts/scripts/env/connect.js | 10 +- packages/scripts/scripts/env/install.js | 59 +++++++ 6 files changed, 276 insertions(+), 23 deletions(-) create mode 100644 packages/scripts/scripts/env/install.js diff --git a/.travis.yml b/.travis.yml index 0bc4fdde3117e..1ca57238b4556 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,16 +39,8 @@ before_install: chmod +x docker-compose sudo mv docker-compose /usr/local/bin - # Check out WordPress - git clone --depth=1 git://develop.git.wordpress.org/ wordpress - - cd wordpress - - # Configure WordPress - npm ci - npm run env:start - npm run build - npm run env:install + # Install WordPress + npm run env install mkdir -p build/wp-content/uploads chmod 767 build/wp-content/uploads @@ -62,7 +54,6 @@ install: - | if [[ "$WORDPRESS" = "true" ]]; then # Add Gutenberg to the WordPress local environment - export WP_DEVELOP_DIR=./wordpress npm run env connect npm run env cli plugin activate gutenberg diff --git a/package-lock.json b/package-lock.json index 912e462b6bf21..db8d6bad69b7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5268,7 +5268,9 @@ "babel-loader": "^8.0.5", "chalk": "^2.4.1", "check-node-version": "^3.1.1", + "command-exists": "1.2.8", "cross-spawn": "^5.1.0", + "decompress-zip": "0.2.2", "eslint": "^6.1.0", "jest": "^24.7.1", "jest-puppeteer": "^4.3.0", @@ -5277,6 +5279,7 @@ "npm-package-json-lint": "^3.6.0", "puppeteer": "^1.19.0", "read-pkg-up": "^1.0.1", + "request": "2.88.0", "resolve-bin": "^0.4.0", "source-map-loader": "^0.2.4", "stylelint": "^9.10.1", @@ -5286,6 +5289,97 @@ "webpack-bundle-analyzer": "^3.3.2", "webpack-cli": "^3.1.2", "webpack-livereload-plugin": "^2.2.0" + }, + "dependencies": { + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + } } }, "@wordpress/server-side-render": { @@ -6723,6 +6817,16 @@ "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", "dev": true }, + "binary": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", + "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", + "dev": true, + "requires": { + "buffers": "~0.1.1", + "chainsaw": "~0.1.0" + } + }, "binary-extensions": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.0.tgz", @@ -7117,6 +7221,12 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, + "buffers": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", + "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=", + "dev": true + }, "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", @@ -7308,6 +7418,23 @@ "integrity": "sha512-Jt9tIBkRc9POUof7QA/VwWd+58fKkEEfI+/t1/eOlxKM7ZhrczNzMFefge7Ai+39y1pR/pP6cI19guHy3FSLmw==", "dev": true }, + "chainsaw": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", + "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", + "dev": true, + "requires": { + "traverse": ">=0.3.0 <0.4" + }, + "dependencies": { + "traverse": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", + "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=", + "dev": true + } + } + }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -9809,6 +9936,47 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, + "decompress-zip": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decompress-zip/-/decompress-zip-0.2.2.tgz", + "integrity": "sha512-v+Na3Ck86Px7s2ix+f77pMQC3GlkxHHN+YyvnkEW7+xX5F39pcDpIV/VFvGYk8MznTFcMoPjL3XNWEJLXWoSPw==", + "dev": true, + "requires": { + "binary": "^0.3.0", + "graceful-fs": "^4.1.3", + "mkpath": "^0.1.0", + "nopt": "^3.0.1", + "q": "^1.1.2", + "readable-stream": "^1.1.8", + "touch": "0.0.3" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, "dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -18496,6 +18664,12 @@ "mkdirp": "*" } }, + "mkpath": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/mkpath/-/mkpath-0.1.0.tgz", + "integrity": "sha1-dVSm+Nhxg0zJe1RisSLEwSTW3pE=", + "dev": true + }, "modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", @@ -25637,6 +25811,26 @@ "integrity": "sha1-riF2gXXRVZ1IvvNUILL0li8JwzA=", "dev": true }, + "touch": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/touch/-/touch-0.0.3.tgz", + "integrity": "sha1-Ua7z1ElXHU8oel2Hyci0kYGg2x0=", + "dev": true, + "requires": { + "nopt": "~1.0.10" + }, + "dependencies": { + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "dev": true, + "requires": { + "abbrev": "1" + } + } + } + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 9a9f06f46783b..4ebf7c2f352bf 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -41,7 +41,9 @@ "babel-loader": "^8.0.5", "chalk": "^2.4.1", "check-node-version": "^3.1.1", + "command-exists": "1.2.8", "cross-spawn": "^5.1.0", + "decompress-zip": "0.2.2", "eslint": "^6.1.0", "jest": "^24.7.1", "jest-puppeteer": "^4.3.0", @@ -50,6 +52,7 @@ "npm-package-json-lint": "^3.6.0", "puppeteer": "^1.19.0", "read-pkg-up": "^1.0.1", + "request": "2.88.0", "resolve-bin": "^0.4.0", "source-map-loader": "^0.2.4", "stylelint": "^9.10.1", diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js index 16a67d161fd19..cb40a91920eb4 100644 --- a/packages/scripts/scripts/env.js +++ b/packages/scripts/scripts/env.js @@ -1,7 +1,9 @@ /** * Node dependencies. */ -const { env, exit, stdout } = require( 'process' ); +const { env, exit, stdout, cwd } = require( 'process' ); +const { normalize } = require( 'path' ); +const { existsSync } = require( 'fs' ); /** * Internal dependencies @@ -11,18 +13,22 @@ const { spawnScript, } = require( '../utils' ); -if ( ! env.WP_DEVELOP_DIR ) { - stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.' ); - exit( 1 ); -} - const args = getArgsFromCLI(); if ( ! args.length ) { - stdout.write( 'Environment command required.' ); + stdout.write( 'Environment command required.\n' ); exit( 1 ); } const command = args.shift(); +if ( ! env.WP_DEVELOP_DIR && command !== 'install' ) { + if ( existsSync( normalize( cwd() + '/wordpress/wp-config-sample.php' ) ) ) { + env.WP_DEVELOP_DIR = cwd() + '/wordpress'; + } else { + stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.\n' ); + exit( 1 ); + } +} + spawnScript( `env/${ command }`, args ); diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 37b26bee270e5..1512d92ef6948 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -22,7 +22,7 @@ if ( existsSync( composeFile ) ) { try { compose = yaml.safeLoad( readFileSync( composeFile, 'utf8' ) ); } catch ( e ) { - stdout.write( 'There was an error loading your docker-compose.override.yml file. Please fix or delete it, and try again.' ); + stdout.write( 'There was an error loading your docker-compose.override.yml file. Please fix or delete it, and try again.\n' ); stdout.write( e.toString() ); exit( 1 ); } @@ -30,7 +30,7 @@ if ( existsSync( composeFile ) ) { const coreComposeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.yml` ); if ( ! existsSync( coreComposeFile ) ) { - stdout.write( "docker-compose.yml doesn't seem to exist. Are you sure WP_DEVELOP_DIR is a WordPress source directory?" ); + stdout.write( "docker-compose.yml doesn't seem to exist. Are you sure WP_DEVELOP_DIR is a WordPress source directory?\n" ); exit( 1 ); } @@ -38,7 +38,7 @@ let coreCompose = {}; try { coreCompose = yaml.safeLoad( readFileSync( coreComposeFile, 'utf8' ) ); } catch ( e ) { - stdout.write( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.' ); + stdout.write( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.\n' ); stdout.write( e.toString() ); exit( 1 ); } @@ -50,7 +50,7 @@ const composeTemplate = readFileSync( fromConfigRoot( 'docker-compose.override.y const pluginCompose = yaml.safeLoad( composeTemplate ); -stdout.write( 'Updating docker-compose.override.yml...' ); +stdout.write( 'Updating docker-compose.override.yml...\n' ); compose.version = coreCompose.version; @@ -97,7 +97,7 @@ const mergedCompose = mergeConfigs( compose, pluginCompose ); writeFileSync( composeFile, yaml.safeDump( mergedCompose, { lineWidth: -1 } ) ); -stdout.write( 'Restarting the WordPress environment...' ); +stdout.write( 'Restarting the WordPress environment...\n' ); execSync( 'npm run env:stop', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js new file mode 100644 index 0000000000000..294f8251b48dd --- /dev/null +++ b/packages/scripts/scripts/env/install.js @@ -0,0 +1,59 @@ +/** + * External dependencies + */ +const commandExistsSync = require( 'command-exists' ).sync; +const request = require( 'request' ); +const DecompressZip = require( 'decompress-zip' ); + +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env, cwd, stdout } = require( 'process' ); +const { normalize } = require( 'path' ); +const { createWriteStream } = require( 'fs' ); +const { tmpdir } = require( 'os' ); + +env.WP_DEVELOP_DIR = cwd() + '/wordpress'; + +if ( commandExistsSync( 'git' ) ) { + execSync( 'git clone --depth=1 git://develop.git.wordpress.org/ wordpress', { stdio: 'inherit' } ); + buildWordPress(); +} else { + stdout.write( "Git isn't availabe. Switching to downloading a zip version.\n" ); + const tmpZip = normalize( tmpdir() + '/wordpress-develop.zip' ); + const tmpZipWriter = createWriteStream( tmpZip ); + + // Set up the unzipper to unzip the archive when it finishes downloading. + tmpZipWriter.on( 'finish', () => { + const unzipper = new DecompressZip( tmpZip ); + + unzipper.on( 'extract', buildWordPress ); + + stdout.write( 'Extracing...\n' ); + + unzipper.extract( { + path: env.WP_DEVELOP_DIR, + strip: 1, + filter: ( file ) => file.type !== 'Directory', + } ); + } ); + + stdout.write( 'Downloading...\n' ); + // Download the archive. + request( 'https://github.com/WordPress/wordpress-develop/archive/master.zip' ).pipe( tmpZipWriter ); +} + +/** + * Runs the appropriate build/install commands in the WordPress directory. + */ +function buildWordPress() { + execSync( 'npm install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run build:dev', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run env:install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + + // Mount Gutenberg into the WordPress install. + execSync( 'npm run env connect', { stdio: 'inherit' } ); + execSync( 'npm run env cli plugin activate gutenberg', { stdio: 'inherit' } ); +} From 519de4d2fe6ec5a0086c0a6825bbfd59cb1ad1a1 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 16 Aug 2019 16:27:52 +1000 Subject: [PATCH 37/91] Tidy up .travis.yml --- .travis.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ca57238b4556..2c7743b77f599 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,22 +42,13 @@ before_install: # Install WordPress npm run env install - mkdir -p build/wp-content/uploads - chmod 767 build/wp-content/uploads - - cd .. + mkdir -p wordpress/build/wp-content/uploads + chmod 767 wordpress/build/wp-content/uploads fi install: - npm ci - npm run build - - | - if [[ "$WORDPRESS" = "true" ]]; then - # Add Gutenberg to the WordPress local environment - npm run env connect - - npm run env cli plugin activate gutenberg - fi - | if [[ "$COMPOSER_INSTALL" = "true" ]]; then npm run env docker-run -- php composer install From baf81fb040c435c4c1d2f7b10d537987a6fd159f Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 16 Aug 2019 16:36:41 +1000 Subject: [PATCH 38/91] Travis: WordPress install now needs to happen after npm ci. --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c7743b77f599..b935b82e23c0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,17 +38,19 @@ before_install: curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose chmod +x docker-compose sudo mv docker-compose /usr/local/bin + fi +install: + - npm ci + - npm run build + - | + if [[ "$WORDPRESS" = "true" ]]; then # Install WordPress npm run env install mkdir -p wordpress/build/wp-content/uploads chmod 767 wordpress/build/wp-content/uploads fi - -install: - - npm ci - - npm run build - | if [[ "$COMPOSER_INSTALL" = "true" ]]; then npm run env docker-run -- php composer install From 82278698b6d05b9599ec45861eb1c796f7ba0215 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 19 Aug 2019 12:29:23 +1000 Subject: [PATCH 39/91] Allow other plugins using these scripts to override the docker-compose template with their own. --- bin/docker-compose.override.yml.template | 17 +++++++++++++++++ package.json | 3 ++- .../config/docker-compose.override.yml.template | 12 ++++-------- packages/scripts/scripts/env/connect.js | 7 +++++-- packages/scripts/scripts/env/install.js | 2 +- 5 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 bin/docker-compose.override.yml.template diff --git a/bin/docker-compose.override.yml.template b/bin/docker-compose.override.yml.template new file mode 100644 index 0000000000000..465211fe7a4a6 --- /dev/null +++ b/bin/docker-compose.override.yml.template @@ -0,0 +1,17 @@ +services: + wordpress-develop: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + php: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + cli: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% + phpunit: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% diff --git a/package.json b/package.json index 6df3055470379..f598775e8dbaa 100644 --- a/package.json +++ b/package.json @@ -239,6 +239,7 @@ ] }, "wp-env": { - "plugin-dir": "gutenberg" + "plugin-dir": "gutenberg", + "docker-template": "./bin/docker-compose.override.yml.template" } } diff --git a/packages/scripts/config/docker-compose.override.yml.template b/packages/scripts/config/docker-compose.override.yml.template index 43d2fc0fddb8f..092d2df9c3568 100644 --- a/packages/scripts/config/docker-compose.override.yml.template +++ b/packages/scripts/config/docker-compose.override.yml.template @@ -1,17 +1,13 @@ services: wordpress-develop: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% php: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% cli: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% phpunit: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 1512d92ef6948..66db5d4671da6 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -45,8 +45,11 @@ try { const pluginMountDir = normalize( cwd() ); -const composeTemplate = readFileSync( fromConfigRoot( 'docker-compose.override.yml.template' ), 'utf8' ) - .replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir ); +const composeTemplateFile = env.npm_package_wp_env_docker_template ? normalize( cwd() + `/${ env.npm_package_wp_env_docker_template }` ) : fromConfigRoot( 'docker-compose.override.yml.template' ); + +const composeTemplate = readFileSync( composeTemplateFile, 'utf8' ) + .replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir ) + .replace( /%PLUGIN_INSTALL_DIR%/gi, env.npm_package_wp_env_plugin_dir ); const pluginCompose = yaml.safeLoad( composeTemplate ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 294f8251b48dd..fe1ab8ee88a7c 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -55,5 +55,5 @@ function buildWordPress() { // Mount Gutenberg into the WordPress install. execSync( 'npm run env connect', { stdio: 'inherit' } ); - execSync( 'npm run env cli plugin activate gutenberg', { stdio: 'inherit' } ); + execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); } From 83b0aa78b5f27e44fd4643fbcc28f2514547bf53 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 19 Aug 2019 16:44:51 +1000 Subject: [PATCH 40/91] Try activating the plugin using the core WP-CLI script. --- packages/scripts/scripts/env/install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index fe1ab8ee88a7c..9e3b337db8678 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -55,5 +55,5 @@ function buildWordPress() { // Mount Gutenberg into the WordPress install. execSync( 'npm run env connect', { stdio: 'inherit' } ); - execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); + execSync( `npm run env:cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); } From ece0f01905b522226ab0371482a018a4fbf70b8c Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 19 Aug 2019 16:57:29 +1000 Subject: [PATCH 41/91] Run the correct core build command. --- packages/scripts/scripts/env/cli.js | 2 +- packages/scripts/scripts/env/install.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/scripts/scripts/env/cli.js b/packages/scripts/scripts/env/cli.js index 05d083daae3e1..342947b35782b 100644 --- a/packages/scripts/scripts/env/cli.js +++ b/packages/scripts/scripts/env/cli.js @@ -15,4 +15,4 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; // Run PHPUnit with the working directory set correctly. -execSync( `npm run env:cli -- --path=${ localDir } ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( `npm run env:cli -- --path=/var/www/${ localDir } ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 9e3b337db8678..106fb068491b4 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -50,10 +50,14 @@ if ( commandExistsSync( 'git' ) ) { function buildWordPress() { execSync( 'npm install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); - execSync( 'npm run build:dev', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + if ( env.LOCAL_DIR === 'build' ) { + execSync( 'npm run build', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + } else { + execSync( 'npm run build:dev', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + } execSync( 'npm run env:install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); // Mount Gutenberg into the WordPress install. execSync( 'npm run env connect', { stdio: 'inherit' } ); - execSync( `npm run env:cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); } From 843f62279413352341f83fade870e656e5471496 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 20 Aug 2019 15:45:32 +1000 Subject: [PATCH 42/91] b0d7330cf773d06a292a56ab9cb27793a7874c39 is obseleted by #16243. --- packages/scripts/config/.stylelintignore | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/scripts/config/.stylelintignore b/packages/scripts/config/.stylelintignore index c551598526f04..ae6cdbfb623bb 100644 --- a/packages/scripts/config/.stylelintignore +++ b/packages/scripts/config/.stylelintignore @@ -1,4 +1,3 @@ # By default, all `node_modules` are ignored. build -wordpress From ecc8b259c8a94706943f174bd2993fb1a0778ad1 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 21 Aug 2019 11:00:56 +1000 Subject: [PATCH 43/91] Check if WordPress is already installed before trying to install it again. --- package-lock.json | 126 ++++++++++++------------ packages/scripts/scripts/env/install.js | 9 +- 2 files changed, 70 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index db8d6bad69b7b..35b0bed136dd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5615,7 +5615,7 @@ }, "ansi-escapes": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", "dev": true }, @@ -5804,7 +5804,7 @@ }, "array-equal": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", "dev": true }, @@ -5998,7 +5998,7 @@ }, "util": { "version": "0.10.3", - "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -6835,7 +6835,7 @@ }, "bindings": { "version": "1.2.1", - "resolved": "http://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=", "dev": true }, @@ -7068,7 +7068,7 @@ }, "browserify-aes": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { @@ -7105,7 +7105,7 @@ }, "browserify-rsa": { "version": "4.0.1", - "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { @@ -7188,7 +7188,7 @@ }, "buffer": { "version": "4.9.1", - "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "dev": true, "requires": { @@ -7265,7 +7265,7 @@ }, "cacache": { "version": "10.0.4", - "resolved": "http://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", "dev": true, "requires": { @@ -8260,7 +8260,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -8425,7 +8425,7 @@ }, "colors": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/colors/-/colors-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz", "integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q=", "dev": true }, @@ -8447,7 +8447,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -8612,7 +8612,7 @@ "dependencies": { "ansi-regex": { "version": "0.2.1", - "resolved": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", "dev": true }, @@ -8624,7 +8624,7 @@ }, "chalk": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", "dev": true, "requires": { @@ -8645,7 +8645,7 @@ }, "commander": { "version": "2.6.0", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.6.0.tgz", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", "dev": true }, @@ -8666,7 +8666,7 @@ }, "strip-ansi": { "version": "0.3.0", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", "dev": true, "requires": { @@ -9382,7 +9382,7 @@ }, "create-hash": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { @@ -9395,7 +9395,7 @@ }, "create-hmac": { "version": "1.1.7", - "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { @@ -9490,7 +9490,7 @@ }, "css-color-names": { "version": "0.0.4", - "resolved": "http://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", + "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", "integrity": "sha1-gIrcLnnPhHOAabZGyyDsJ762KeA=", "dev": true }, @@ -9590,7 +9590,7 @@ }, "css-select": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", "dev": true, "requires": { @@ -10205,7 +10205,7 @@ }, "diffie-hellman": { "version": "5.0.3", - "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { @@ -10261,7 +10261,7 @@ "dependencies": { "domelementtype": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", "dev": true } @@ -10336,7 +10336,7 @@ }, "duplexer": { "version": "0.1.1", - "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, @@ -10778,7 +10778,7 @@ }, "es6-promisify": { "version": "5.0.0", - "resolved": "http://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", "dev": true, "requires": { @@ -11959,7 +11959,7 @@ "dependencies": { "core-js": { "version": "1.2.7", - "resolved": "http://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" } } @@ -12076,7 +12076,7 @@ }, "finalhandler": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", "dev": true, "requires": { @@ -12244,13 +12244,13 @@ "dependencies": { "colors": { "version": "0.6.2", - "resolved": "http://registry.npmjs.org/colors/-/colors-0.6.2.tgz", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", "dev": true }, "commander": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.1.0.tgz", "integrity": "sha1-0SG7roYNmZKj1Re6lvVliOR8Z4E=", "dev": true } @@ -12835,7 +12835,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": false, "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true @@ -13069,7 +13069,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -13125,7 +13125,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -13150,7 +13150,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -13207,7 +13207,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "get-value": { @@ -13227,7 +13227,7 @@ }, "gettext-parser": { "version": "1.4.0", - "resolved": "http://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz", + "resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz", "integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==", "requires": { "encoding": "^0.1.12", @@ -13613,7 +13613,7 @@ "dependencies": { "minimist": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz", "integrity": "sha1-O+39kaktOQFvz6ocaB6Pqhoe/ag=", "dev": true } @@ -14406,7 +14406,7 @@ }, "is-builtin-module": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { @@ -14598,7 +14598,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -16366,7 +16366,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, @@ -16733,7 +16733,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -17479,7 +17479,7 @@ }, "media-typer": { "version": "0.3.0", - "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "dev": true }, @@ -18640,7 +18640,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -18898,7 +18898,7 @@ "dependencies": { "semver": { "version": "5.3.0", - "resolved": "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true } @@ -19055,7 +19055,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -19065,7 +19065,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -19131,7 +19131,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -19214,7 +19214,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -19893,7 +19893,7 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, @@ -19919,7 +19919,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -19955,7 +19955,7 @@ }, "p-is-promise": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", "dev": true }, @@ -20493,7 +20493,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, @@ -20552,7 +20552,7 @@ }, "pegjs": { "version": "0.10.0", - "resolved": "http://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", + "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", "integrity": "sha1-z4uvrm7d/0tafvsYUmnqr0YQ3b0=" }, "pend": { @@ -20580,7 +20580,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -23158,7 +23158,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } @@ -23551,7 +23551,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { @@ -23692,7 +23692,7 @@ }, "os-locale": { "version": "1.4.0", - "resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "dev": true, "requires": { @@ -23712,7 +23712,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -23841,7 +23841,7 @@ "dependencies": { "source-map": { "version": "0.4.4", - "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { @@ -23980,7 +23980,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { @@ -24776,7 +24776,7 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" }, "strip-indent": { @@ -25672,7 +25672,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -26724,7 +26724,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -26746,7 +26746,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -27286,7 +27286,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "requires": { "string-width": "^1.0.1", @@ -27318,7 +27318,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 106fb068491b4..ce9674cdf17d4 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -9,13 +9,18 @@ const DecompressZip = require( 'decompress-zip' ); * Node dependencies. */ const { execSync } = require( 'child_process' ); -const { env, cwd, stdout } = require( 'process' ); +const { env, exit, cwd, stdout } = require( 'process' ); const { normalize } = require( 'path' ); -const { createWriteStream } = require( 'fs' ); +const { createWriteStream, existsSync } = require( 'fs' ); const { tmpdir } = require( 'os' ); env.WP_DEVELOP_DIR = cwd() + '/wordpress'; +if ( existsSync( normalize( cwd() + '/wordpress/wp-config-sample.php' ) ) ) { + stdout.write( 'It looks like WordPress is already installed, please delete the `wordpress` directory for a fresh install, or run `npm run env start` to start the existing environment.\n' ); + exit( 1 ); +} + if ( commandExistsSync( 'git' ) ) { execSync( 'git clone --depth=1 git://develop.git.wordpress.org/ wordpress', { stdio: 'inherit' } ); buildWordPress(); From 028460afe95323da2b90127bc595ca8cfd5f08bc Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 21 Aug 2019 13:46:51 +1000 Subject: [PATCH 44/91] If we're running in a managed environment, encourage updating if it hasn't been updated in over a week. --- packages/scripts/scripts/env.js | 1 + packages/scripts/scripts/env/install.js | 2 +- packages/scripts/scripts/env/start.js | 23 +++++++++- packages/scripts/scripts/env/update.js | 61 +++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 packages/scripts/scripts/env/update.js diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js index cb40a91920eb4..4dbf10c777e88 100644 --- a/packages/scripts/scripts/env.js +++ b/packages/scripts/scripts/env.js @@ -25,6 +25,7 @@ const command = args.shift(); if ( ! env.WP_DEVELOP_DIR && command !== 'install' ) { if ( existsSync( normalize( cwd() + '/wordpress/wp-config-sample.php' ) ) ) { env.WP_DEVELOP_DIR = cwd() + '/wordpress'; + env.MANAGED_WP = true; } else { stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.\n' ); exit( 1 ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index ce9674cdf17d4..880099767f526 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -62,7 +62,7 @@ function buildWordPress() { } execSync( 'npm run env:install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); - // Mount Gutenberg into the WordPress install. + // Mount the plugin into the WordPress install. execSync( 'npm run env connect', { stdio: 'inherit' } ); execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); } diff --git a/packages/scripts/scripts/env/start.js b/packages/scripts/scripts/env/start.js index 318a7dc87d02f..d633c9cb418cd 100644 --- a/packages/scripts/scripts/env/start.js +++ b/packages/scripts/scripts/env/start.js @@ -1,9 +1,30 @@ +/** + * External dependencies + */ +const commandExistsSync = require( 'command-exists' ).sync; + /** * Node dependencies. */ const { execSync } = require( 'child_process' ); -const { env } = require( 'process' ); +const { env, stdout } = require( 'process' ); const { normalize } = require( 'path' ); +const { statSync } = require( 'fs' ); + +if ( env.MANAGED_WP ) { + // We're running in our managed WordPress environment, so check if we need to update. + let stat; + if ( commandExistsSync( 'git' ) ) { + stat = statSync( normalize( env.WP_DEVELOP_DIR + '/.git' ) ); + } else { + stat = statSync( normalize( env.WP_DEVELOP_DIR + '/.wp-config-sample.php' ) ); + } + + const lastUpdated = new Date( stat.mtimeMs ); + if ( Date.now() - lastUpdated.getTime() > 7 * 24 * 60 * 60 * 1000 ) { + stdout.write( "\nIt's been a while since you updated WordPress. Run `npm run env update` to update it.\n\n" ); + } +} // Start the environment in the WordPress directory. execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/update.js b/packages/scripts/scripts/env/update.js new file mode 100644 index 0000000000000..7950e1e66a0f8 --- /dev/null +++ b/packages/scripts/scripts/env/update.js @@ -0,0 +1,61 @@ +/** + * External dependencies + */ +const commandExistsSync = require( 'command-exists' ).sync; +const request = require( 'request' ); +const DecompressZip = require( 'decompress-zip' ); + +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env, cwd, stdout } = require( 'process' ); +const { normalize } = require( 'path' ); +const { createWriteStream } = require( 'fs' ); +const { tmpdir } = require( 'os' ); + +env.WP_DEVELOP_DIR = cwd() + '/wordpress'; + +if ( commandExistsSync( 'git' ) ) { + execSync( 'git pull', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + buildWordPress(); +} else { + stdout.write( "Git isn't availabe. Switching to downloading a zip version.\n" ); + const tmpZip = normalize( tmpdir() + '/wordpress-develop.zip' ); + const tmpZipWriter = createWriteStream( tmpZip ); + + // Set up the unzipper to unzip the archive when it finishes downloading. + tmpZipWriter.on( 'finish', () => { + const unzipper = new DecompressZip( tmpZip ); + + unzipper.on( 'extract', buildWordPress ); + + stdout.write( 'Extracing...\n' ); + + unzipper.extract( { + path: env.WP_DEVELOP_DIR, + strip: 1, + filter: ( file ) => file.type !== 'Directory', + } ); + } ); + + stdout.write( 'Downloading...\n' ); + // Download the archive. + request( 'https://github.com/WordPress/wordpress-develop/archive/master.zip' ).pipe( tmpZipWriter ); +} + +/** + * Runs the appropriate build/install commands in the WordPress directory. + */ +function buildWordPress() { + execSync( 'npm install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + if ( env.LOCAL_DIR === 'build' ) { + execSync( 'npm run build', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + } else { + execSync( 'npm run build:dev', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + } + + // Ensure the plugin is still mounted. + execSync( 'npm run env connect', { stdio: 'inherit' } ); +} From 52059be813b7631d90b639b52b7dd5a3643597da Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 10:00:26 +1000 Subject: [PATCH 45/91] Check the Node version before trying to do any environment work. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f598775e8dbaa..8453cc8e1c19a 100644 --- a/package.json +++ b/package.json @@ -219,6 +219,7 @@ "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", "playground:start": "concurrently \"npm run dev:packages\" \"parcel playground/src/index.html -d playground/dist\"", + "preenv": "npm run check-engines", "env": "wp-scripts env" }, "lint-staged": { From 9e6054b3314f5e2184da3a73aced53c90bc384da Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 10:41:03 +1000 Subject: [PATCH 46/91] Add a placeholder for setup-local-env.sh, pointing folks at the new way of doing things. --- bin/setup-local-env.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 bin/setup-local-env.sh diff --git a/bin/setup-local-env.sh b/bin/setup-local-env.sh new file mode 100755 index 0000000000000..a427fb4e3f3ef --- /dev/null +++ b/bin/setup-local-env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Exit if any command fails. +set -e + +echo "Hi there! It looks like you're trying to use the old local environment setup script. This script has been retired, running \`npm run env install\` will setup a local environment for you, instead. + +Check out the documentation for more information: https://developer.wordpress.org/block-editor/contributors/develop/getting-started/" From 07be5aa1e39dd7671a605ec6816d25690e4b27c6 Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 10:41:20 +1000 Subject: [PATCH 47/91] Update the documentation for the local-env. --- docs/contributors/coding-guidelines.md | 2 +- docs/contributors/getting-started.md | 65 +++++++++----------------- 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/docs/contributors/coding-guidelines.md b/docs/contributors/coding-guidelines.md index dac400e51f663..2e02dfeaa10f7 100644 --- a/docs/contributors/coding-guidelines.md +++ b/docs/contributors/coding-guidelines.md @@ -208,4 +208,4 @@ We use The easiest way to use PHPCS is [local environment](/docs/contributors/getting-started.md#local-environment). Once that's installed, you can check your PHP by running `npm run lint-php`. -If you prefer to install PHPCS locally, you should use `composer`. [Install `composer`](https://getcomposer.org/download/) on your computer, then run `composer install`. This will install `phpcs` and `WordPress-Coding-Standards` which you can the run via `vendor/bin/phpcs`. +If you prefer to install PHPCS locally, you should use `composer`. [Install `composer`](https://getcomposer.org/download/) on your computer, then run `composer install`. This will install `phpcs` and `WordPress-Coding-Standards` which you can then run via `composer lint`. diff --git a/docs/contributors/getting-started.md b/docs/contributors/getting-started.md index 24217faed45fd..3105b6a0aa15d 100644 --- a/docs/contributors/getting-started.md +++ b/docs/contributors/getting-started.md @@ -2,74 +2,53 @@ Gutenberg is a Node.js-based project, built primarily in JavaScript. -The easiest way to get started (on MacOS, Linux, or Windows 10 with the Linux Subsystem) is by running the Local Environment setup script, `./bin/setup-local-env.sh`. This will check if you have everything installed and updated, and help you download any extra tools you need. +The first step is to install a recent version of Node. The easiest way (on MacOS, Linux, or Windows 10 with the Linux Subsystem) is by installing and running [nvm]. Once `nvm` is installed, you can install the correct version of Node by running `nvm install` in the Gutenberg directory. -For another version of Windows, or if you prefer to set things up manually, be sure to have Node.js installed first. You should be running a Node version matching the [current active LTS release](https://github.com/nodejs/Release#release-schedule) or newer for this plugin to work correctly. You can check your Node.js version by typing `node -v` in the Terminal prompt. - -If you have an incompatible version of Node in your development environment, you can use [nvm] to change node versions on the command line: +Once you have Node installed, run these scripts: ``` -nvm install -nvm use +npm install +npm run build ``` -You also should have the latest release of [npm installed][npm]. npm is a separate project from Node.js and is updated frequently. If you've just installed Node.js which includes a version of npm within the installation you most likely will need also to update your npm installation. To update npm, type this into your terminal: `npm install npm@latest -g` +This will build Gutenberg, ready to be used as a WordPress plugin! -To test the plugin, or to contribute to it, you can clone this repository and build the plugin files using Node. How you do that depends on whether you're developing locally or uploading the plugin to a remote host. +If you don't have a local WordPress environment to load Gutenberg in, we can help get that up and running, too. ## Local Environment -First, you need a WordPress Environment to run the plugin on. The quickest way to get up and running is to use the provided docker setup. Install [docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/) by following the most recent instructions on the docker site. +The quickest way to get up and running is to use the provided Docker setup. If you don't already have it, you'll need to install Docker by following their instructions for [Windows 10 Pro](https://docs.docker.com/docker-for-windows/install/), [all other version of Windows](https://docs.docker.com/toolbox/toolbox_install_windows/), [macOS](https://docs.docker.com/docker-for-mac/install/), or [Linux](https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script). -In the folder of your preference, clone this project and enter the working directory: -```bash -git clone git@github.com:WordPress/gutenberg.git -cd gutenberg -``` +Once Docker is installed and running, run this script to install WordPress, and build your local environment: -Then, run a setup script to check if docker and node are configured properly and starts the local WordPress instance. You may need to run this script multiple times if prompted. ``` -./bin/setup-local-env.sh +npm run env install ``` -**If you're developing themes, or core WordPress functionality alongside Gutenberg**, you can make the WordPress files accessible in `wordpress/` by following these instructions instead: +WordPress will be installed in the `wordpress` directory, if you need to access WordPress core files directly, you can find them there. -1. If this is your first time setting up the environment, run `DOCKER_ENV=localwpdev ./bin/setup-local-env.sh` instead of `./bin/setup-local-env.sh` -2. If you've already had the previous environment set up, you need to start fresh, and you can do that by first running `docker-compose down --rmi all`. After that, you can repeat step 1. -3. If you turn off your computer or restart Docker, you can get your local WordPress dev environment back by typing `docker-compose -f docker-compose.yml -f docker-compose-localdev.yml up`. If you just run `docker-compose up`, you will get the vanilla install that doesn't expose the WordPress folder. +If you already have WordPress checked out in a different directory, you can use that installation, instead, by running these commands: -**If everything was successful**, you'll see the following ASCII art: ``` -Welcome to... - -,⁻⁻⁻· . | -| ،⁓’. . |--- ,---. ,---. |---. ,---. ,---. ,---. -| | | | | |---' | | | | |---' | | | -`---' `---' `---’ `---’ ' ` `---' `---’ ` `---| - `---' +export WP_DEVELOP_DIR=/path/to/wordpress-develop +npm run env connect ``` -The WordPress installation should be available at `http://localhost:8888` (**Username**: `admin`, **Password**: `password`). -Inside the "docker" directory, you can use any docker command to interact with your containers. If this port is in use, you can override it in your `docker-compose.override.yml` file. If you're running [e2e tests](/docs/contributors/testing-overview.md#end-to-end-testing), this change will be used correctly. +This will use WordPress' own local environment, and mount your Gutenberg directory as a volume there. -To bring down this local WordPress instance later run: -``` -docker-compose down -``` +In Windows, you can set the `WP_DEVELOP_DIR` environment variable using the appropriate method for your shell: -If you'd like to see your changes reflected in this local WordPress instance, run: -``` -npm install -npm run dev -``` + CMD: set WP_DEVELOP_DIR=/path/to/wordpress-develop + PowerShell: $env:WP_DEVELOP_DIR = "/path/to/wordpress-develop" -Alternatively, you can use your own local WordPress environment and clone this repository right into your `wp-content/plugins` directory. +The WordPress installation should be available at `http://localhost:8889` (**Username**: `admin`, **Password**: `password`). +If this port is in use, you can override it using the `LOCAL_PORT` environment variable. For example, `export LOCAL_PORT=7777` will change the URL to `http://localhost:7777` . If you're running [e2e tests](/docs/contributors/testing-overview.md#end-to-end-testing), this change will be used correctly. -Next, open a terminal (or if on Windows, a command prompt) and navigate to the repository you cloned. Now type `npm install` to get the dependencies all set up. Then you can type `npm run dev` in your terminal or command prompt to keep the plugin building in the background as you work on it. +To bring down this local WordPress instance later run `npm run env stop`. To bring it back up again, run `npm run env start`. -WordPress comes with specific [debug systems](https://wordpress.org/support/article/debugging-in-wordpress/) designed to simplify the process as well as standardize code across core, plugins and themes. It is possible to use environment variables (`WP_DEBUG` and `SCRIPT_DEBUG`) to update a site's configuration constants located in `wp-config.php` file. Both flags can be disabled at any time by running the following command: +WordPress comes with specific [debug systems](https://wordpress.org/support/article/debugging-in-wordpress/) designed to simplify the process as well as standardize code across core, plugins and themes. It is possible to use environment variables (`LOCAL_WP_DEBUG` and `LOCAL_SCRIPT_DEBUG`) to update a site's configuration constants located in `wp-config.php` file. Both flags can be disabled at any time by running the following command: ``` -SCRIPT_DEBUG=false WP_DEBUG=false ./bin/setup-local-env.sh +LOCAL_SCRIPT_DEBUG=false LOCAL_WP_DEBUG=false npm run env install ``` By default, both flags will be set to `true`. From 78bdc3b4be5b9650079eea627a6277cd63beb7b6 Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 11:52:37 +1000 Subject: [PATCH 48/91] Add inline commenting for mergeConfigs(). --- packages/scripts/scripts/env/connect.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 66db5d4671da6..6301a3257fd82 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -69,26 +69,39 @@ compose.version = coreCompose.version; * @return {Object} The merged config object. */ function mergeConfigs( originalConfig, newConfig ) { + // Loop through each element of newConfig, and test what should be done with them. Object.keys( newConfig ).forEach( ( key ) => { if ( ! originalConfig[ key ] ) { + // If the originalConfig object doesn't have this element, we can just add it. originalConfig[ key ] = newConfig[ key ]; } else if ( newConfig[ key ] instanceof Array ) { + // If the newConfig element is an array, we need to try and merge them. + // This is intended to merge Docker volume configs, which exist in the form: + // /path/to/local/dir:/path/to/container/dir:config:stuff newConfig[ key ].forEach( ( element ) => { + // First, check if it's actually a volume config. if ( element.startsWith( pluginMountDir ) && element.includes( ':' ) ) { + // Get the local directory that's being mounted. This can either be the plugin + // base directory, or a subdirectory of it. const mountDir = element.split( ':' )[ 0 ]; + // See if this mountDir exists in the originalConfig. const index = originalConfig[ key ].findIndex( ( volume ) => { return volume.startsWith( `${ mountDir }:` ); } ); if ( index > -1 ) { + // If mountDir exists in originalConfig, overwrite it with the new config. originalConfig[ key ][ index ] = element; } else { + // If mountDir doesn't exist, append the new config, instead. originalConfig[ key ].push( element ); } } } ); } else if ( newConfig[ key ] instanceof Object ) { + // If the newConfig element is an object, we need to recursively merge it. originalConfig[ key ] = mergeConfigs( originalConfig[ key ], newConfig[ key ] ); } else { + // Any other data types are overwritten by the newConfig. originalConfig[ key ] = newConfig[ key ]; } } ); From 548b10a0e9fad25d71c5f7c2ffd0e4ed4338a09a Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 11:55:41 +1000 Subject: [PATCH 49/91] Ensure we catch invalid YAML template files. --- packages/scripts/scripts/env/connect.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 6301a3257fd82..30aef581ab904 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -51,7 +51,14 @@ const composeTemplate = readFileSync( composeTemplateFile, 'utf8' ) .replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir ) .replace( /%PLUGIN_INSTALL_DIR%/gi, env.npm_package_wp_env_plugin_dir ); -const pluginCompose = yaml.safeLoad( composeTemplate ); +let pluginCompose = {}; +try { + pluginCompose = yaml.safeLoad( composeTemplate ); +} catch ( e ) { + stdout.write( 'There was an error loading your docker-compose.override.yml.template file. Please revert any changes to it, and try again.\n' ); + stdout.write( e.toString() ); + exit( 1 ); +} stdout.write( 'Updating docker-compose.override.yml...\n' ); From 2b020f497547805e4390dabb5f85d65a50b657f7 Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 14:21:26 +1000 Subject: [PATCH 50/91] Improve behaviour on Windows. --- packages/scripts/scripts/env/connect.js | 6 ++++-- packages/scripts/scripts/env/install.js | 6 +++--- packages/scripts/scripts/env/update.js | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 30aef581ab904..12a0b0939ccac 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -87,10 +87,12 @@ function mergeConfigs( originalConfig, newConfig ) { // /path/to/local/dir:/path/to/container/dir:config:stuff newConfig[ key ].forEach( ( element ) => { // First, check if it's actually a volume config. - if ( element.startsWith( pluginMountDir ) && element.includes( ':' ) ) { + // Ignore the first few characters, so that we skip over Windows drive letters. + const colonPos = element.indexOf( ':', 3 ); + if ( colonPos > -1 && element.startsWith( pluginMountDir ) ) { // Get the local directory that's being mounted. This can either be the plugin // base directory, or a subdirectory of it. - const mountDir = element.split( ':' )[ 0 ]; + const mountDir = element.substring( 0, colonPos ); // See if this mountDir exists in the originalConfig. const index = originalConfig[ key ].findIndex( ( volume ) => { return volume.startsWith( `${ mountDir }:` ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 880099767f526..4cf935f4f9ace 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -25,7 +25,7 @@ if ( commandExistsSync( 'git' ) ) { execSync( 'git clone --depth=1 git://develop.git.wordpress.org/ wordpress', { stdio: 'inherit' } ); buildWordPress(); } else { - stdout.write( "Git isn't availabe. Switching to downloading a zip version.\n" ); + stdout.write( "Git isn't available. Switching to downloading a zip version.\n" ); const tmpZip = normalize( tmpdir() + '/wordpress-develop.zip' ); const tmpZipWriter = createWriteStream( tmpZip ); @@ -35,10 +35,10 @@ if ( commandExistsSync( 'git' ) ) { unzipper.on( 'extract', buildWordPress ); - stdout.write( 'Extracing...\n' ); + stdout.write( 'Extracting...\n' ); unzipper.extract( { - path: env.WP_DEVELOP_DIR, + path: normalize( env.WP_DEVELOP_DIR ), strip: 1, filter: ( file ) => file.type !== 'Directory', } ); diff --git a/packages/scripts/scripts/env/update.js b/packages/scripts/scripts/env/update.js index 7950e1e66a0f8..00f41e6592fe6 100644 --- a/packages/scripts/scripts/env/update.js +++ b/packages/scripts/scripts/env/update.js @@ -20,7 +20,7 @@ if ( commandExistsSync( 'git' ) ) { execSync( 'git pull', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); buildWordPress(); } else { - stdout.write( "Git isn't availabe. Switching to downloading a zip version.\n" ); + stdout.write( "Git isn't available. Switching to downloading a zip version.\n" ); const tmpZip = normalize( tmpdir() + '/wordpress-develop.zip' ); const tmpZipWriter = createWriteStream( tmpZip ); @@ -30,10 +30,10 @@ if ( commandExistsSync( 'git' ) ) { unzipper.on( 'extract', buildWordPress ); - stdout.write( 'Extracing...\n' ); + stdout.write( 'Extracting...\n' ); unzipper.extract( { - path: env.WP_DEVELOP_DIR, + path: normalize( env.WP_DEVELOP_DIR ), strip: 1, filter: ( file ) => file.type !== 'Directory', } ); From ebaffd8d6f6cac490896f64e9378aab4c18addd5 Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 16:49:38 +1000 Subject: [PATCH 51/91] Simplify the array merging, so old items aren't left hanging around. --- packages/scripts/scripts/env/connect.js | 27 +++++++------------------ 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 12a0b0939ccac..b6ad74e97e454 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -85,27 +85,14 @@ function mergeConfigs( originalConfig, newConfig ) { // If the newConfig element is an array, we need to try and merge them. // This is intended to merge Docker volume configs, which exist in the form: // /path/to/local/dir:/path/to/container/dir:config:stuff - newConfig[ key ].forEach( ( element ) => { - // First, check if it's actually a volume config. - // Ignore the first few characters, so that we skip over Windows drive letters. - const colonPos = element.indexOf( ':', 3 ); - if ( colonPos > -1 && element.startsWith( pluginMountDir ) ) { - // Get the local directory that's being mounted. This can either be the plugin - // base directory, or a subdirectory of it. - const mountDir = element.substring( 0, colonPos ); - // See if this mountDir exists in the originalConfig. - const index = originalConfig[ key ].findIndex( ( volume ) => { - return volume.startsWith( `${ mountDir }:` ); - } ); - if ( index > -1 ) { - // If mountDir exists in originalConfig, overwrite it with the new config. - originalConfig[ key ][ index ] = element; - } else { - // If mountDir doesn't exist, append the new config, instead. - originalConfig[ key ].push( element ); - } - } + + // Build an array from the original config, with items that belong to this plugin removed. + const cleanOriginal = originalConfig[ key ].filter( ( element ) => { + return ! element.startsWith( pluginMountDir ); } ); + + // Append the newConfig to the remaining config. + originalConfig[ key ] = [ ...cleanOriginal, ...newConfig[ key ] ]; } else if ( newConfig[ key ] instanceof Object ) { // If the newConfig element is an object, we need to recursively merge it. originalConfig[ key ] = mergeConfigs( originalConfig[ key ], newConfig[ key ] ); From 8248c80f39249531a51aa6352d512616a92b42fd Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 16:52:53 +1000 Subject: [PATCH 52/91] Add an extra prompt to help people who run env commands without a WP_DEVELOP_DIR set. --- packages/scripts/scripts/env.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js index 4dbf10c777e88..1c1e54cffbb12 100644 --- a/packages/scripts/scripts/env.js +++ b/packages/scripts/scripts/env.js @@ -27,7 +27,8 @@ if ( ! env.WP_DEVELOP_DIR && command !== 'install' ) { env.WP_DEVELOP_DIR = cwd() + '/wordpress'; env.MANAGED_WP = true; } else { - stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.\n' ); + stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.\n\n' ); + stdout.write( "If you don't have a WordPress Development directory to use, run `npm run env install` to automatically configure one!\n" ); exit( 1 ); } } From 69a91dfb0808c2909a6975512ddee35d9a16b900 Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 17:15:10 +1000 Subject: [PATCH 53/91] List the commands when no arguments are passed to npm run env. --- packages/scripts/scripts/env.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js index 1c1e54cffbb12..ed109d7ce525e 100644 --- a/packages/scripts/scripts/env.js +++ b/packages/scripts/scripts/env.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +const chalk = require( 'chalk' ); + /** * Node dependencies. */ @@ -16,8 +21,28 @@ const { const args = getArgsFromCLI(); if ( ! args.length ) { - stdout.write( 'Environment command required.\n' ); - exit( 1 ); + const scripts = { + install: "If you don't have a check out of the WordPress repository that you want to work with, this will automatically download, configure, and connect to WordPress.", + connect: 'If you have a WordPress respository already, define the ' + chalk.magenta( 'WP_DEVELOP_DIR' ) + ' environment variable with the path to your repository, then run this command to add this plugin to it.', + start: "This will start a container that you've already installed and connected to.", + stop: "And this will stop it when you're done!", + update: 'If you used ' + chalk.blue( 'npm run env install' ) + ' to setup WordPress, run this command to update it.', + cli: 'Run WP-CLI commands against the WordPress install.', + 'lint-php': 'Run PHPCS linting on the plugin.', + 'test-php': "Run the plugin's PHPUnit tests.", + 'docker-run': 'For more advanced debugging, you may sometimes need to run commands in the Docker containers. This is the equivalent of running ' + chalk.blue( 'docker-compose run' ) + '.', + }; + + stdout.write( chalk.white( 'Welcome to the WordPress Local Environment! There are several commands available to help you get up and running. Each of these commands should be run after ' ) ); + stdout.write( chalk.blue( 'npm run env' ) ); + stdout.write( chalk.white( '. For example, ' ) ); + stdout.write( chalk.blue( 'npm run env install' ) ); + stdout.write( chalk.white( '.\n\n' ) ); + + Object.keys( scripts ).forEach( ( script ) => { + stdout.write( chalk.green( script ) + '\n ' + chalk.white( scripts[ script ] ) + '\n\n' ); + } ); + exit( 0 ); } const command = args.shift(); @@ -27,8 +52,8 @@ if ( ! env.WP_DEVELOP_DIR && command !== 'install' ) { env.WP_DEVELOP_DIR = cwd() + '/wordpress'; env.MANAGED_WP = true; } else { - stdout.write( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.\n\n' ); - stdout.write( "If you don't have a WordPress Development directory to use, run `npm run env install` to automatically configure one!\n" ); + stdout.write( chalk.white( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.\n\n' ) ); + stdout.write( chalk.white( "If you don't have a WordPress Development directory to use, run `npm run env install` to automatically configure one!\n" ) ); exit( 1 ); } } From 6fd7805b6de5a246d374bb5f8a90f5c4f578bae2 Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 22 Aug 2019 17:33:15 +1000 Subject: [PATCH 54/91] Auto switch between running PHPUnit tests from the src or build directory. --- packages/scripts/scripts/env/test-php.js | 8 +++++++- phpunit.xml.dist | 3 --- phpunit/build-dir.php | 8 ++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 phpunit/build-dir.php diff --git a/packages/scripts/scripts/env/test-php.js b/packages/scripts/scripts/env/test-php.js index 855b8f02cf4d2..b4db8e0f5a069 100644 --- a/packages/scripts/scripts/env/test-php.js +++ b/packages/scripts/scripts/env/test-php.js @@ -4,6 +4,7 @@ const { execSync } = require( 'child_process' ); const { env } = require( 'process' ); const { normalize } = require( 'path' ); +const { existsSync } = require( 'fs' ); /** * Internal dependencies @@ -14,5 +15,10 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; +let buildConfig = ''; +if ( localDir === 'build' && existsSync( 'phpunit/build-dir.php' ) ) { + buildConfig = `--prepend /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit/build-dir.php`; +} + // Run PHPUnit with the working directory set correctly. -execSync( `npm run test:php -- -c /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit.xml.dist ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( `npm run test:php -- -c /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit.xml.dist ${ buildConfig } ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b0d33bcc286f7..e799a44754caf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,4 @@ ./phpunit/ - - - diff --git a/phpunit/build-dir.php b/phpunit/build-dir.php new file mode 100644 index 0000000000000..fc71124dcf42c --- /dev/null +++ b/phpunit/build-dir.php @@ -0,0 +1,8 @@ + Date: Fri, 23 Aug 2019 11:40:30 +1000 Subject: [PATCH 55/91] Fix PHPUnit tests not properly running in the build directory. --- packages/scripts/scripts/env/test-php.js | 8 +------- phpunit/bootstrap.php | 5 +++++ phpunit/build-dir.php | 8 -------- 3 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 phpunit/build-dir.php diff --git a/packages/scripts/scripts/env/test-php.js b/packages/scripts/scripts/env/test-php.js index b4db8e0f5a069..855b8f02cf4d2 100644 --- a/packages/scripts/scripts/env/test-php.js +++ b/packages/scripts/scripts/env/test-php.js @@ -4,7 +4,6 @@ const { execSync } = require( 'child_process' ); const { env } = require( 'process' ); const { normalize } = require( 'path' ); -const { existsSync } = require( 'fs' ); /** * Internal dependencies @@ -15,10 +14,5 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; -let buildConfig = ''; -if ( localDir === 'build' && existsSync( 'phpunit/build-dir.php' ) ) { - buildConfig = `--prepend /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit/build-dir.php`; -} - // Run PHPUnit with the working directory set correctly. -execSync( `npm run test:php -- -c /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit.xml.dist ${ buildConfig } ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( `npm run test:php -- -c /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit.xml.dist ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index 8aab3cac808dd..17989ee336b11 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -5,6 +5,11 @@ * @package Gutenberg */ +// If we're running in WP's build directory, ensure that WP knows that, too. +if ( 'build' === getenv( 'LOCAL_DIR' ) ) { + define( 'WP_RUN_CORE_TESTS', true ); +} + // Determine the tests directory (from a WP dev checkout). // Try the WP_TESTS_DIR environment variable first. $_tests_dir = getenv( 'WP_TESTS_DIR' ); diff --git a/phpunit/build-dir.php b/phpunit/build-dir.php deleted file mode 100644 index fc71124dcf42c..0000000000000 --- a/phpunit/build-dir.php +++ /dev/null @@ -1,8 +0,0 @@ - Date: Fri, 23 Aug 2019 14:42:46 +1000 Subject: [PATCH 56/91] Let's keep the welcome message when installing local-env. --- package-lock.json | 1 + package.json | 11 +++++++++- packages/scripts/package.json | 1 + packages/scripts/scripts/env/install.js | 29 +++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 35b0bed136dd3..85f7ba1c82149 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5282,6 +5282,7 @@ "request": "2.88.0", "resolve-bin": "^0.4.0", "source-map-loader": "^0.2.4", + "sprintf-js": "^1.1.1", "stylelint": "^9.10.1", "stylelint-config-wordpress": "^13.1.0", "thread-loader": "^2.1.2", diff --git a/package.json b/package.json index 8453cc8e1c19a..2cfec6e1cb235 100644 --- a/package.json +++ b/package.json @@ -241,6 +241,15 @@ }, "wp-env": { "plugin-dir": "gutenberg", - "docker-template": "./bin/docker-compose.override.yml.template" + "plugin-name": "Gutenberg", + "docker-template": "./bin/docker-compose.override.yml.template", + "welcome-logo": [ + ",⁻⁻⁻· . |", + "| ،⁓’. . |--- ,---. ,---. |---. ,---. ,---. ,---.", + "| | | | | |---' | | | | |---' | | |", + "`---' `---' `---’ `---’ ' ` `---' `---’ ` `---|", + " `---'" + ], + "welcome-build-command": "npm run dev" } } diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 4ebf7c2f352bf..7a33a8e83e7d5 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -55,6 +55,7 @@ "request": "2.88.0", "resolve-bin": "^0.4.0", "source-map-loader": "^0.2.4", + "sprintf-js": "^1.1.1", "stylelint": "^9.10.1", "stylelint-config-wordpress": "^13.1.0", "thread-loader": "^2.1.2", diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 4cf935f4f9ace..5eb2251970bf8 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -4,6 +4,8 @@ const commandExistsSync = require( 'command-exists' ).sync; const request = require( 'request' ); const DecompressZip = require( 'decompress-zip' ); +const chalk = require( 'chalk' ); +const { sprintf } = require( 'sprintf-js' ); /** * Node dependencies. @@ -65,4 +67,31 @@ function buildWordPress() { // Mount the plugin into the WordPress install. execSync( 'npm run env connect', { stdio: 'inherit' } ); execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); + + const currentUrl = execSync( 'npm run --silent env cli option get siteurl' ).toString().trim(); + + stdout.write( chalk.white( '\nWelcome to...\n' ) ); + for ( let ii = 0; env[ `npm_package_wp_env_welcome_logo_${ ii }` ]; ii++ ) { + stdout.write( chalk.green( env[ `npm_package_wp_env_welcome_logo_${ ii }` ] ) + '\n' ); + } + + if ( env.npm_package_wp_env_welcome_build_command ) { + const nextStep = sprintf( + '\nRun %s to build the latest version of %s, then open %s to get started!\n', + chalk.blue( env.npm_package_wp_env_welcome_build_command ), + chalk.green( env.npm_package_wp_env_plugin_name ), + chalk.blue( currentUrl ) + ); + stdout.write( chalk.white( nextStep ) ); + } + + stdout.write( chalk.white( '\nAccess the above install using the following credentials:\n' ) ); + + const access = sprintf( + 'Default username: %s, password: %s\n', + chalk.blue( 'admin' ), + chalk.blue( 'password' ) + ); + + stdout.write( chalk.white( access ) ); } From 56e20098233f1c457394b9860f7bcc4924e49b93 Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 14:58:11 +1000 Subject: [PATCH 57/91] Normalise WP_DEVELOP_DIR when it's generated, so we don't need to normalize it everywhere it's used. --- packages/scripts/scripts/env.js | 2 +- packages/scripts/scripts/env/cli.js | 3 +-- packages/scripts/scripts/env/connect.js | 4 ++-- packages/scripts/scripts/env/docker-run.js | 3 +-- packages/scripts/scripts/env/install.js | 14 +++++++------- packages/scripts/scripts/env/lint-php.js | 3 +-- packages/scripts/scripts/env/start.js | 2 +- packages/scripts/scripts/env/stop.js | 3 +-- packages/scripts/scripts/env/test-php.js | 3 +-- packages/scripts/scripts/env/update.js | 14 +++++++------- 10 files changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js index ed109d7ce525e..b626304f33add 100644 --- a/packages/scripts/scripts/env.js +++ b/packages/scripts/scripts/env.js @@ -49,7 +49,7 @@ const command = args.shift(); if ( ! env.WP_DEVELOP_DIR && command !== 'install' ) { if ( existsSync( normalize( cwd() + '/wordpress/wp-config-sample.php' ) ) ) { - env.WP_DEVELOP_DIR = cwd() + '/wordpress'; + env.WP_DEVELOP_DIR = normalize( cwd() + '/wordpress' ); env.MANAGED_WP = true; } else { stdout.write( chalk.white( 'Please ensure the WP_DEVELOP_DIR environment variable is set to your WordPress Development directory before running this script.\n\n' ) ); diff --git a/packages/scripts/scripts/env/cli.js b/packages/scripts/scripts/env/cli.js index 342947b35782b..641d424f932f1 100644 --- a/packages/scripts/scripts/env/cli.js +++ b/packages/scripts/scripts/env/cli.js @@ -3,7 +3,6 @@ */ const { execSync } = require( 'child_process' ); const { env } = require( 'process' ); -const { normalize } = require( 'path' ); /** * Internal dependencies @@ -15,4 +14,4 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; // Run PHPUnit with the working directory set correctly. -execSync( `npm run env:cli -- --path=/var/www/${ localDir } ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( `npm run env:cli -- --path=/var/www/${ localDir } ` + args.join( ' ' ), { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index b6ad74e97e454..f85e84fe11f5b 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -111,5 +111,5 @@ writeFileSync( composeFile, yaml.safeDump( mergedCompose, { lineWidth: -1 } ) ); stdout.write( 'Restarting the WordPress environment...\n' ); -execSync( 'npm run env:stop', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); -execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( 'npm run env:stop', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); +execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/docker-run.js b/packages/scripts/scripts/env/docker-run.js index 533538c79da07..bde99a4dadfdc 100644 --- a/packages/scripts/scripts/env/docker-run.js +++ b/packages/scripts/scripts/env/docker-run.js @@ -3,7 +3,6 @@ */ const { execSync } = require( 'child_process' ); const { env } = require( 'process' ); -const { normalize } = require( 'path' ); /** * Internal dependencies @@ -15,4 +14,4 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; // Execute any docker-compose command passed to this script, in the WordPress Docker environment. -execSync( `docker-compose run -w /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir } --rm ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( `docker-compose run -w /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir } --rm ` + args.join( ' ' ), { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 5eb2251970bf8..e3cef280d7b86 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -16,7 +16,7 @@ const { normalize } = require( 'path' ); const { createWriteStream, existsSync } = require( 'fs' ); const { tmpdir } = require( 'os' ); -env.WP_DEVELOP_DIR = cwd() + '/wordpress'; +env.WP_DEVELOP_DIR = normalize( cwd() + '/wordpress' ); if ( existsSync( normalize( cwd() + '/wordpress/wp-config-sample.php' ) ) ) { stdout.write( 'It looks like WordPress is already installed, please delete the `wordpress` directory for a fresh install, or run `npm run env start` to start the existing environment.\n' ); @@ -40,7 +40,7 @@ if ( commandExistsSync( 'git' ) ) { stdout.write( 'Extracting...\n' ); unzipper.extract( { - path: normalize( env.WP_DEVELOP_DIR ), + path: env.WP_DEVELOP_DIR, strip: 1, filter: ( file ) => file.type !== 'Directory', } ); @@ -55,14 +55,14 @@ if ( commandExistsSync( 'git' ) ) { * Runs the appropriate build/install commands in the WordPress directory. */ function buildWordPress() { - execSync( 'npm install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); - execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); if ( env.LOCAL_DIR === 'build' ) { - execSync( 'npm run build', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run build', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); } else { - execSync( 'npm run build:dev', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run build:dev', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); } - execSync( 'npm run env:install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run env:install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); // Mount the plugin into the WordPress install. execSync( 'npm run env connect', { stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/lint-php.js b/packages/scripts/scripts/env/lint-php.js index b7acb5020f4ba..7c93519e933e9 100644 --- a/packages/scripts/scripts/env/lint-php.js +++ b/packages/scripts/scripts/env/lint-php.js @@ -3,7 +3,6 @@ */ const { execSync } = require( 'child_process' ); const { env } = require( 'process' ); -const { normalize } = require( 'path' ); /** * Internal dependencies @@ -15,4 +14,4 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; // Run PHPUnit with the working directory set correctly. -execSync( `docker-compose run --rm -w /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir } php composer lint ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( `docker-compose run --rm -w /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir } php composer lint ` + args.join( ' ' ), { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/start.js b/packages/scripts/scripts/env/start.js index d633c9cb418cd..8133f01962233 100644 --- a/packages/scripts/scripts/env/start.js +++ b/packages/scripts/scripts/env/start.js @@ -27,4 +27,4 @@ if ( env.MANAGED_WP ) { } // Start the environment in the WordPress directory. -execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/stop.js b/packages/scripts/scripts/env/stop.js index 444faae7d98ed..b51e4f2b6b268 100644 --- a/packages/scripts/scripts/env/stop.js +++ b/packages/scripts/scripts/env/stop.js @@ -4,7 +4,6 @@ */ const { execSync } = require( 'child_process' ); const { env } = require( 'process' ); -const { normalize } = require( 'path' ); // Stop the environment in the WordPress directory. -execSync( 'npm run env:stop', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( 'npm run env:stop', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/test-php.js b/packages/scripts/scripts/env/test-php.js index 855b8f02cf4d2..da3529bd7ec6b 100644 --- a/packages/scripts/scripts/env/test-php.js +++ b/packages/scripts/scripts/env/test-php.js @@ -3,7 +3,6 @@ */ const { execSync } = require( 'child_process' ); const { env } = require( 'process' ); -const { normalize } = require( 'path' ); /** * Internal dependencies @@ -15,4 +14,4 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; // Run PHPUnit with the working directory set correctly. -execSync( `npm run test:php -- -c /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit.xml.dist ` + args.join( ' ' ), { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); +execSync( `npm run test:php -- -c /var/www/${ localDir }/wp-content/plugins/${ env.npm_package_wp_env_plugin_dir }/phpunit.xml.dist ` + args.join( ' ' ), { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/update.js b/packages/scripts/scripts/env/update.js index 00f41e6592fe6..2829a71b9ea21 100644 --- a/packages/scripts/scripts/env/update.js +++ b/packages/scripts/scripts/env/update.js @@ -14,10 +14,10 @@ const { normalize } = require( 'path' ); const { createWriteStream } = require( 'fs' ); const { tmpdir } = require( 'os' ); -env.WP_DEVELOP_DIR = cwd() + '/wordpress'; +env.WP_DEVELOP_DIR = normalize( cwd() + '/wordpress' ); if ( commandExistsSync( 'git' ) ) { - execSync( 'git pull', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'git pull', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); buildWordPress(); } else { stdout.write( "Git isn't available. Switching to downloading a zip version.\n" ); @@ -33,7 +33,7 @@ if ( commandExistsSync( 'git' ) ) { stdout.write( 'Extracting...\n' ); unzipper.extract( { - path: normalize( env.WP_DEVELOP_DIR ), + path: env.WP_DEVELOP_DIR, strip: 1, filter: ( file ) => file.type !== 'Directory', } ); @@ -48,12 +48,12 @@ if ( commandExistsSync( 'git' ) ) { * Runs the appropriate build/install commands in the WordPress directory. */ function buildWordPress() { - execSync( 'npm install', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); - execSync( 'npm run env:start', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); if ( env.LOCAL_DIR === 'build' ) { - execSync( 'npm run build', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run build', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); } else { - execSync( 'npm run build:dev', { cwd: normalize( env.WP_DEVELOP_DIR ), stdio: 'inherit' } ); + execSync( 'npm run build:dev', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); } // Ensure the plugin is still mounted. From e97900c452bce36da1777f8a287bf5c11c622dd4 Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 14:59:36 +1000 Subject: [PATCH 58/91] Fix an incorrect comment referring to PHPUnit instead of WP-CLI. --- packages/scripts/scripts/env/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env/cli.js b/packages/scripts/scripts/env/cli.js index 641d424f932f1..ec1141a710965 100644 --- a/packages/scripts/scripts/env/cli.js +++ b/packages/scripts/scripts/env/cli.js @@ -13,5 +13,5 @@ const args = getArgsFromCLI(); const localDir = env.LOCAL_DIR || 'src'; -// Run PHPUnit with the working directory set correctly. +// Run WP-CLI with the working directory set correctly. execSync( `npm run env:cli -- --path=/var/www/${ localDir } ` + args.join( ' ' ), { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); From 15db588f584d3704cdebcc18c261791d2e718eb8 Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 15:02:33 +1000 Subject: [PATCH 59/91] Expand abbreviated variable names. --- packages/scripts/scripts/env/connect.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index f85e84fe11f5b..5bb9d3d8c4505 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -21,9 +21,9 @@ let compose = {}; if ( existsSync( composeFile ) ) { try { compose = yaml.safeLoad( readFileSync( composeFile, 'utf8' ) ); - } catch ( e ) { + } catch ( error ) { stdout.write( 'There was an error loading your docker-compose.override.yml file. Please fix or delete it, and try again.\n' ); - stdout.write( e.toString() ); + stdout.write( error.toString() ); exit( 1 ); } } @@ -37,9 +37,9 @@ if ( ! existsSync( coreComposeFile ) ) { let coreCompose = {}; try { coreCompose = yaml.safeLoad( readFileSync( coreComposeFile, 'utf8' ) ); -} catch ( e ) { +} catch ( error ) { stdout.write( 'There was an error loading your docker-compose.yml in your WordPress directory. Please revert any changes to it, and try again.\n' ); - stdout.write( e.toString() ); + stdout.write( error.toString() ); exit( 1 ); } @@ -54,9 +54,9 @@ const composeTemplate = readFileSync( composeTemplateFile, 'utf8' ) let pluginCompose = {}; try { pluginCompose = yaml.safeLoad( composeTemplate ); -} catch ( e ) { +} catch ( error ) { stdout.write( 'There was an error loading your docker-compose.override.yml.template file. Please revert any changes to it, and try again.\n' ); - stdout.write( e.toString() ); + stdout.write( error.toString() ); exit( 1 ); } From f9637934d968d684f6a5203b62cfd931f02c137b Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 15:03:57 +1000 Subject: [PATCH 60/91] Remove an unnecessary normalize() --- packages/scripts/scripts/env/connect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 5bb9d3d8c4505..b9700a4ce6cbe 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -43,7 +43,7 @@ try { exit( 1 ); } -const pluginMountDir = normalize( cwd() ); +const pluginMountDir = cwd(); const composeTemplateFile = env.npm_package_wp_env_docker_template ? normalize( cwd() + `/${ env.npm_package_wp_env_docker_template }` ) : fromConfigRoot( 'docker-compose.override.yml.template' ); From 48596994d28e090e3021a710ee0ca2e992af7b7f Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 15:05:41 +1000 Subject: [PATCH 61/91] Use Array.isArray() to test for arrays. --- packages/scripts/scripts/env/connect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index b9700a4ce6cbe..c35fc51998ced 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -81,7 +81,7 @@ function mergeConfigs( originalConfig, newConfig ) { if ( ! originalConfig[ key ] ) { // If the originalConfig object doesn't have this element, we can just add it. originalConfig[ key ] = newConfig[ key ]; - } else if ( newConfig[ key ] instanceof Array ) { + } else if ( Array.isArray( newConfig[ key ] ) ) { // If the newConfig element is an array, we need to try and merge them. // This is intended to merge Docker volume configs, which exist in the form: // /path/to/local/dir:/path/to/container/dir:config:stuff From e8bc7f3ee265e8fbeacf4e67f8e378670b207ea3 Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 15:11:30 +1000 Subject: [PATCH 62/91] Use isPlainObject() to test for objects. --- packages/scripts/package.json | 1 + packages/scripts/scripts/env/connect.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 7a33a8e83e7d5..043c2fec77f2c 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -48,6 +48,7 @@ "jest": "^24.7.1", "jest-puppeteer": "^4.3.0", "js-yaml": "3.13.1", + "lodash": "^4.17.14", "minimist": "^1.2.0", "npm-package-json-lint": "^3.6.0", "puppeteer": "^1.19.0", diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index c35fc51998ced..7fc8a69ab4902 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -2,6 +2,7 @@ * External dependencies */ const yaml = require( 'js-yaml' ); +const { isPlainObject } = require( 'lodash' ); /** * Node dependencies. @@ -93,7 +94,7 @@ function mergeConfigs( originalConfig, newConfig ) { // Append the newConfig to the remaining config. originalConfig[ key ] = [ ...cleanOriginal, ...newConfig[ key ] ]; - } else if ( newConfig[ key ] instanceof Object ) { + } else if ( isPlainObject( newConfig[ key ] ) ) { // If the newConfig element is an object, we need to recursively merge it. originalConfig[ key ] = mergeConfigs( originalConfig[ key ], newConfig[ key ] ); } else { From a6d2e735e4e4bc56c75f02a7648a6f5b2db6e718 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 26 Aug 2019 15:15:48 +1000 Subject: [PATCH 63/91] Make require look a little more like import. Co-Authored-By: Robert Anderson --- packages/scripts/scripts/env/install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index e3cef280d7b86..5cd68af1e28d5 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -1,7 +1,7 @@ /** * External dependencies */ -const commandExistsSync = require( 'command-exists' ).sync; +const { sync: commandExistsSync } = require( 'command-exists' ); const request = require( 'request' ); const DecompressZip = require( 'decompress-zip' ); const chalk = require( 'chalk' ); From a52430d64cea6554b132cdd796a2ff14ab92dea8 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 26 Aug 2019 15:16:38 +1000 Subject: [PATCH 64/91] Make require look a little more like import. Co-Authored-By: Robert Anderson --- packages/scripts/scripts/env/start.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scripts/scripts/env/start.js b/packages/scripts/scripts/env/start.js index 8133f01962233..f20a89b3554ef 100644 --- a/packages/scripts/scripts/env/start.js +++ b/packages/scripts/scripts/env/start.js @@ -1,7 +1,7 @@ /** * External dependencies */ -const commandExistsSync = require( 'command-exists' ).sync; +const { sync: commandExistsSync } = require( 'command-exists' ); /** * Node dependencies. From 92def6a3feedad708c39f995303ec56029b6c48f Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 15:16:49 +1000 Subject: [PATCH 65/91] Make require look a little more like import. --- package-lock.json | 1 + packages/scripts/scripts/env/update.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 85f7ba1c82149..442fe4ca5fc62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5275,6 +5275,7 @@ "jest": "^24.7.1", "jest-puppeteer": "^4.3.0", "js-yaml": "3.13.1", + "lodash": "^4.17.14", "minimist": "^1.2.0", "npm-package-json-lint": "^3.6.0", "puppeteer": "^1.19.0", diff --git a/packages/scripts/scripts/env/update.js b/packages/scripts/scripts/env/update.js index 2829a71b9ea21..3bab464e772c8 100644 --- a/packages/scripts/scripts/env/update.js +++ b/packages/scripts/scripts/env/update.js @@ -1,7 +1,7 @@ /** * External dependencies */ -const commandExistsSync = require( 'command-exists' ).sync; +const { sync: commandExistsSync } = require( 'command-exists' ); const request = require( 'request' ); const DecompressZip = require( 'decompress-zip' ); From 18183eaf0712934b56f6f3db427c9d7db2f7775d Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 26 Aug 2019 15:17:15 +1000 Subject: [PATCH 66/91] Remove a bonus \n Co-Authored-By: Robert Anderson --- packages/scripts/scripts/env/stop.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/scripts/scripts/env/stop.js b/packages/scripts/scripts/env/stop.js index b51e4f2b6b268..f0218c606411d 100644 --- a/packages/scripts/scripts/env/stop.js +++ b/packages/scripts/scripts/env/stop.js @@ -1,4 +1,3 @@ - /** * Node dependencies. */ From 0e1596f9bf2f88a62a762192991e38d6b86ab257 Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 15:22:32 +1000 Subject: [PATCH 67/91] Travis: Rename some environment variables, to make their meaning a little clearer. --- .travis.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index b935b82e23c0f..457f0cb65adfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,13 +26,13 @@ env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - LOCAL_DIR: build - LOCAL_SCRIPT_DEBUG: false - - COMPOSER_INSTALL: false - - WORDPRESS: true + - INSTALL_COMPOSER: false + - INSTALL_WORDPRESS: true before_install: - nvm install - | - if [[ "$WORDPRESS" = "true" ]]; then + if [[ "$INSTALL_WORDPRESS" = "true" ]]; then # upgrade docker-compose sudo rm /usr/local/bin/docker-compose curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose @@ -44,7 +44,7 @@ install: - npm ci - npm run build - | - if [[ "$WORDPRESS" = "true" ]]; then + if [[ "$INSTALL_WORDPRESS" = "true" ]]; then # Install WordPress npm run env install @@ -52,7 +52,7 @@ install: chmod 767 wordpress/build/wp-content/uploads fi - | - if [[ "$COMPOSER_INSTALL" = "true" ]]; then + if [[ "$INSTALL_COMPOSER" = "true" ]]; then npm run env docker-run -- php composer install fi - | @@ -64,12 +64,12 @@ install: jobs: include: - name: Lint - env: COMPOSER_INSTALL=true + env: INSTALL_COMPOSER=true script: - npm run lint - name: Build artifacts - env: WORDPRESS=false + env: INSTALL_WORDPRESS=false install: # A "full" install is executed, since `npm ci` does not always exit # with an error status code if the lock file is inaccurate. @@ -80,12 +80,12 @@ jobs: - npm run check-local-changes - name: License compatibility - env: WORDPRESS=false + env: INSTALL_WORDPRESS=false script: - npm run check-licenses - name: JavaScript unit tests - env: WORDPRESS=false + env: INSTALL_WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -94,7 +94,7 @@ jobs: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests - env: WORDPRESS=false + env: INSTALL_WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -103,12 +103,12 @@ jobs: - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: PHP unit tests - env: COMPOSER_INSTALL=true + env: INSTALL_COMPOSER=true script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - env: COMPOSER_INSTALL=true LOCAL_PHP=5.6-fpm + env: INSTALL_COMPOSER=true LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite From 602bbb7290512d476de426c12b2ea8dff5150616 Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 16:17:20 +1000 Subject: [PATCH 68/91] Refactor repetitive code into util functions. --- packages/scripts/scripts/env/connect.js | 49 +------ packages/scripts/scripts/env/install.js | 83 ++---------- packages/scripts/scripts/env/update.js | 51 ++------ packages/scripts/utils/env.js | 162 ++++++++++++++++++++++++ packages/scripts/utils/index.js | 8 ++ 5 files changed, 198 insertions(+), 155 deletions(-) create mode 100644 packages/scripts/utils/env.js diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 7fc8a69ab4902..38798159fe336 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -2,7 +2,6 @@ * External dependencies */ const yaml = require( 'js-yaml' ); -const { isPlainObject } = require( 'lodash' ); /** * Node dependencies. @@ -15,7 +14,10 @@ const { execSync } = require( 'child_process' ); /** * Internal dependencies */ -const { fromConfigRoot } = require( '../../utils' ); +const { + fromConfigRoot, + mergeYamlConfigs, +} = require( '../../utils' ); const composeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.override.yml` ); let compose = {}; @@ -65,48 +67,7 @@ stdout.write( 'Updating docker-compose.override.yml...\n' ); compose.version = coreCompose.version; -/** - * Merges two YAML configs together. - * - * All new data from newConfig will be added to originalConfig. When arrays in newConfig look like lists of volume - * mount instructions, it will attempt to replace items that mount from the same location. This allows the config - * to be safely updated, and it'll be reflected in the updated config. - * - * @param {Object} originalConfig The original config object that we're overwriting. - * @param {Object} newConfig A new config object to merge into originalConfig. - * @return {Object} The merged config object. - */ -function mergeConfigs( originalConfig, newConfig ) { - // Loop through each element of newConfig, and test what should be done with them. - Object.keys( newConfig ).forEach( ( key ) => { - if ( ! originalConfig[ key ] ) { - // If the originalConfig object doesn't have this element, we can just add it. - originalConfig[ key ] = newConfig[ key ]; - } else if ( Array.isArray( newConfig[ key ] ) ) { - // If the newConfig element is an array, we need to try and merge them. - // This is intended to merge Docker volume configs, which exist in the form: - // /path/to/local/dir:/path/to/container/dir:config:stuff - - // Build an array from the original config, with items that belong to this plugin removed. - const cleanOriginal = originalConfig[ key ].filter( ( element ) => { - return ! element.startsWith( pluginMountDir ); - } ); - - // Append the newConfig to the remaining config. - originalConfig[ key ] = [ ...cleanOriginal, ...newConfig[ key ] ]; - } else if ( isPlainObject( newConfig[ key ] ) ) { - // If the newConfig element is an object, we need to recursively merge it. - originalConfig[ key ] = mergeConfigs( originalConfig[ key ], newConfig[ key ] ); - } else { - // Any other data types are overwritten by the newConfig. - originalConfig[ key ] = newConfig[ key ]; - } - } ); - - return originalConfig; -} - -const mergedCompose = mergeConfigs( compose, pluginCompose ); +const mergedCompose = mergeYamlConfigs( compose, pluginCompose, pluginMountDir ); writeFileSync( composeFile, yaml.safeDump( mergedCompose, { lineWidth: -1 } ) ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 5cd68af1e28d5..770c83695fc2f 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -2,10 +2,6 @@ * External dependencies */ const { sync: commandExistsSync } = require( 'command-exists' ); -const request = require( 'request' ); -const DecompressZip = require( 'decompress-zip' ); -const chalk = require( 'chalk' ); -const { sprintf } = require( 'sprintf-js' ); /** * Node dependencies. @@ -13,8 +9,15 @@ const { sprintf } = require( 'sprintf-js' ); const { execSync } = require( 'child_process' ); const { env, exit, cwd, stdout } = require( 'process' ); const { normalize } = require( 'path' ); -const { createWriteStream, existsSync } = require( 'fs' ); -const { tmpdir } = require( 'os' ); +const { existsSync } = require( 'fs' ); + +/** + * Internal dependencies + */ +const { + buildWordPress, + downloadWordPressZip, +} = require( '../../utils' ); env.WP_DEVELOP_DIR = normalize( cwd() + '/wordpress' ); @@ -28,70 +31,8 @@ if ( commandExistsSync( 'git' ) ) { buildWordPress(); } else { stdout.write( "Git isn't available. Switching to downloading a zip version.\n" ); - const tmpZip = normalize( tmpdir() + '/wordpress-develop.zip' ); - const tmpZipWriter = createWriteStream( tmpZip ); - - // Set up the unzipper to unzip the archive when it finishes downloading. - tmpZipWriter.on( 'finish', () => { - const unzipper = new DecompressZip( tmpZip ); - - unzipper.on( 'extract', buildWordPress ); - - stdout.write( 'Extracting...\n' ); - - unzipper.extract( { - path: env.WP_DEVELOP_DIR, - strip: 1, - filter: ( file ) => file.type !== 'Directory', + downloadWordPressZip() + .then( () => { + buildWordPress(); } ); - } ); - - stdout.write( 'Downloading...\n' ); - // Download the archive. - request( 'https://github.com/WordPress/wordpress-develop/archive/master.zip' ).pipe( tmpZipWriter ); -} - -/** - * Runs the appropriate build/install commands in the WordPress directory. - */ -function buildWordPress() { - execSync( 'npm install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - if ( env.LOCAL_DIR === 'build' ) { - execSync( 'npm run build', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - } else { - execSync( 'npm run build:dev', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - } - execSync( 'npm run env:install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - - // Mount the plugin into the WordPress install. - execSync( 'npm run env connect', { stdio: 'inherit' } ); - execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); - - const currentUrl = execSync( 'npm run --silent env cli option get siteurl' ).toString().trim(); - - stdout.write( chalk.white( '\nWelcome to...\n' ) ); - for ( let ii = 0; env[ `npm_package_wp_env_welcome_logo_${ ii }` ]; ii++ ) { - stdout.write( chalk.green( env[ `npm_package_wp_env_welcome_logo_${ ii }` ] ) + '\n' ); - } - - if ( env.npm_package_wp_env_welcome_build_command ) { - const nextStep = sprintf( - '\nRun %s to build the latest version of %s, then open %s to get started!\n', - chalk.blue( env.npm_package_wp_env_welcome_build_command ), - chalk.green( env.npm_package_wp_env_plugin_name ), - chalk.blue( currentUrl ) - ); - stdout.write( chalk.white( nextStep ) ); - } - - stdout.write( chalk.white( '\nAccess the above install using the following credentials:\n' ) ); - - const access = sprintf( - 'Default username: %s, password: %s\n', - chalk.blue( 'admin' ), - chalk.blue( 'password' ) - ); - - stdout.write( chalk.white( access ) ); } diff --git a/packages/scripts/scripts/env/update.js b/packages/scripts/scripts/env/update.js index 3bab464e772c8..b61d9669273c1 100644 --- a/packages/scripts/scripts/env/update.js +++ b/packages/scripts/scripts/env/update.js @@ -2,8 +2,6 @@ * External dependencies */ const { sync: commandExistsSync } = require( 'command-exists' ); -const request = require( 'request' ); -const DecompressZip = require( 'decompress-zip' ); /** * Node dependencies. @@ -11,8 +9,14 @@ const DecompressZip = require( 'decompress-zip' ); const { execSync } = require( 'child_process' ); const { env, cwd, stdout } = require( 'process' ); const { normalize } = require( 'path' ); -const { createWriteStream } = require( 'fs' ); -const { tmpdir } = require( 'os' ); + +/** + * Internal dependencies + */ +const { + buildWordPress, + downloadWordPressZip, +} = require( '../../utils' ); env.WP_DEVELOP_DIR = normalize( cwd() + '/wordpress' ); @@ -21,41 +25,8 @@ if ( commandExistsSync( 'git' ) ) { buildWordPress(); } else { stdout.write( "Git isn't available. Switching to downloading a zip version.\n" ); - const tmpZip = normalize( tmpdir() + '/wordpress-develop.zip' ); - const tmpZipWriter = createWriteStream( tmpZip ); - - // Set up the unzipper to unzip the archive when it finishes downloading. - tmpZipWriter.on( 'finish', () => { - const unzipper = new DecompressZip( tmpZip ); - - unzipper.on( 'extract', buildWordPress ); - - stdout.write( 'Extracting...\n' ); - - unzipper.extract( { - path: env.WP_DEVELOP_DIR, - strip: 1, - filter: ( file ) => file.type !== 'Directory', + downloadWordPressZip() + .then( () => { + buildWordPress( false ); } ); - } ); - - stdout.write( 'Downloading...\n' ); - // Download the archive. - request( 'https://github.com/WordPress/wordpress-develop/archive/master.zip' ).pipe( tmpZipWriter ); -} - -/** - * Runs the appropriate build/install commands in the WordPress directory. - */ -function buildWordPress() { - execSync( 'npm install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - if ( env.LOCAL_DIR === 'build' ) { - execSync( 'npm run build', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - } else { - execSync( 'npm run build:dev', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - } - - // Ensure the plugin is still mounted. - execSync( 'npm run env connect', { stdio: 'inherit' } ); } diff --git a/packages/scripts/utils/env.js b/packages/scripts/utils/env.js new file mode 100644 index 0000000000000..b4226d0844095 --- /dev/null +++ b/packages/scripts/utils/env.js @@ -0,0 +1,162 @@ +/** + * External dependencies + */ +const { isPlainObject } = require( 'lodash' ); +const request = require( 'request' ); +const DecompressZip = require( 'decompress-zip' ); +const chalk = require( 'chalk' ); +const { sprintf } = require( 'sprintf-js' ); + +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); +const { env, exit, stdout } = require( 'process' ); +const { normalize } = require( 'path' ); +const { createWriteStream } = require( 'fs' ); +const { tmpdir } = require( 'os' ); + +/** + * Merges two YAML configs together. + * + * All new data from newConfig will be added to originalConfig. When arrays in newConfig look like lists of volume + * mount instructions, it will attempt to replace items that mount from the same location. This allows the config + * to be safely updated, and it'll be reflected in the updated config. + * + * @param {Object} originalConfig The original config object that we're overwriting. + * @param {Object} newConfig A new config object to merge into originalConfig. + * @param {string} baseDir The base directory of the plugin, volumes in this directory belong to the plugin. + * @return {Object} The merged config object. + */ +function mergeYamlConfigs( originalConfig, newConfig, baseDir ) { + // Loop through each element of newConfig, and test what should be done with them. + Object.keys( newConfig ).forEach( ( key ) => { + if ( ! originalConfig[ key ] ) { + // If the originalConfig object doesn't have this element, we can just add it. + originalConfig[ key ] = newConfig[ key ]; + } else if ( Array.isArray( newConfig[ key ] ) ) { + // If the newConfig element is an array, we need to try and merge them. + // This is intended to merge Docker volume configs, which exist in the form: + // /path/to/local/dir:/path/to/container/dir:config:stuff + + // Build an array from the original config, with items that belong to this plugin removed. + const cleanOriginal = originalConfig[ key ].filter( ( element ) => { + return ! element.startsWith( baseDir ); + } ); + + // Append the newConfig to the remaining config. + originalConfig[ key ] = [ ...cleanOriginal, ...newConfig[ key ] ]; + } else if ( isPlainObject( newConfig[ key ] ) ) { + // If the newConfig element is an object, we need to recursively merge it. + originalConfig[ key ] = mergeYamlConfigs( originalConfig[ key ], newConfig[ key ], baseDir ); + } else { + // Any other data types are overwritten by the newConfig. + originalConfig[ key ] = newConfig[ key ]; + } + } ); + + return originalConfig; +} + +/** + * Downloads and extracts WordPress from the GitHub repo zip file. + * + * @return {Promise} A promise that resolves when WordPress has been downloaded and extracted. + */ +function downloadWordPressZip() { + return new Promise( ( resolve ) => { + const tmpZip = normalize( tmpdir() + '/wordpress-develop.zip' ); + const tmpZipWriter = createWriteStream( tmpZip ); + + // Set up the unzipper to unzip the archive when it finishes downloading. + tmpZipWriter.on( 'finish', () => { + const unzipper = new DecompressZip( tmpZip ); + + unzipper.on( 'error', ( error ) => { + stdout.write( "ERROR: The zip file couldn't be unzipped.\n" ); + stdout.write( error.toString() ); + exit( 1 ); + } ); + + unzipper.on( 'extract', resolve ); + + stdout.write( 'Extracting...\n' ); + + unzipper.extract( { + path: env.WP_DEVELOP_DIR, + strip: 1, + filter: ( file ) => file.type !== 'Directory', + } ); + } ); + + stdout.write( 'Downloading...\n' ); + // Download the archive. + request + .get( 'https://github.com/WordPress/wordpress-develop/archive/master.zip' ) + .on( 'error', ( error ) => { + stdout.write( "ERROR: The zip file couldn't be downloaded.\n" ); + stdout.write( error.toString() ); + exit( 1 ); + } ) + .pipe( tmpZipWriter ); + } ); +} + +/** + * Runs the appropriate build/install commands in the WordPress directory. + * + * @param {boolean} newInstall Default true. Flag whether to treat this as a new WordPress install or not. + */ +function buildWordPress( newInstall = true ) { + execSync( 'npm install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + if ( env.LOCAL_DIR === 'build' ) { + execSync( 'npm run build', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + } else { + execSync( 'npm run build:dev', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + } + + if ( newInstall ) { + execSync( 'npm run env:install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + } + + // Mount the plugin into the WordPress install. + execSync( 'npm run env connect', { stdio: 'inherit' } ); + + if ( newInstall ) { + execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); + + const currentUrl = execSync( 'npm run --silent env cli option get siteurl' ).toString().trim(); + + stdout.write( chalk.white( '\nWelcome to...\n' ) ); + for ( let ii = 0; env[ `npm_package_wp_env_welcome_logo_${ ii }` ]; ii++ ) { + stdout.write( chalk.green( env[ `npm_package_wp_env_welcome_logo_${ ii }` ] ) + '\n' ); + } + + if ( env.npm_package_wp_env_welcome_build_command ) { + const nextStep = sprintf( + '\nRun %s to build the latest version of %s, then open %s to get started!\n', + chalk.blue( env.npm_package_wp_env_welcome_build_command ), + chalk.green( env.npm_package_wp_env_plugin_name ), + chalk.blue( currentUrl ) + ); + stdout.write( chalk.white( nextStep ) ); + } + + stdout.write( chalk.white( '\nAccess the above install using the following credentials:\n' ) ); + + const access = sprintf( + 'Default username: %s, password: %s\n', + chalk.blue( 'admin' ), + chalk.blue( 'password' ) + ); + + stdout.write( chalk.white( access ) ); + } +} + +module.exports = { + buildWordPress, + downloadWordPressZip, + mergeYamlConfigs, +}; diff --git a/packages/scripts/utils/index.js b/packages/scripts/utils/index.js index c45b1b6abbee1..0d026e299aeef 100644 --- a/packages/scripts/utils/index.js +++ b/packages/scripts/utils/index.js @@ -14,6 +14,11 @@ const { hasBabelConfig, hasJestConfig, } = require( './config' ); +const { + buildWordPress, + downloadWordPressZip, + mergeYamlConfigs, +} = require( './env' ); const { fromConfigRoot, hasProjectFile, @@ -26,6 +31,7 @@ const { } = require( './string' ); module.exports = { + buildWordPress, camelCaseDash, fromConfigRoot, getArgFromCLI, @@ -38,5 +44,7 @@ module.exports = { hasJestConfig, hasPackageProp, hasProjectFile, + downloadWordPressZip, + mergeYamlConfigs, spawnScript, }; From ef7d0b78855ddde614e743152f940966aa4da26b Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 26 Aug 2019 17:12:39 +1000 Subject: [PATCH 69/91] s/mergeYamlConfigs/mergeYAMLConfigs/g --- packages/scripts/scripts/env/connect.js | 4 ++-- packages/scripts/utils/env.js | 6 +++--- packages/scripts/utils/index.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 38798159fe336..a18bdf5c32374 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -16,7 +16,7 @@ const { execSync } = require( 'child_process' ); */ const { fromConfigRoot, - mergeYamlConfigs, + mergeYAMLConfigs, } = require( '../../utils' ); const composeFile = normalize( `${ env.WP_DEVELOP_DIR }/docker-compose.override.yml` ); @@ -67,7 +67,7 @@ stdout.write( 'Updating docker-compose.override.yml...\n' ); compose.version = coreCompose.version; -const mergedCompose = mergeYamlConfigs( compose, pluginCompose, pluginMountDir ); +const mergedCompose = mergeYAMLConfigs( compose, pluginCompose, pluginMountDir ); writeFileSync( composeFile, yaml.safeDump( mergedCompose, { lineWidth: -1 } ) ); diff --git a/packages/scripts/utils/env.js b/packages/scripts/utils/env.js index b4226d0844095..d28afbfb2970e 100644 --- a/packages/scripts/utils/env.js +++ b/packages/scripts/utils/env.js @@ -28,7 +28,7 @@ const { tmpdir } = require( 'os' ); * @param {string} baseDir The base directory of the plugin, volumes in this directory belong to the plugin. * @return {Object} The merged config object. */ -function mergeYamlConfigs( originalConfig, newConfig, baseDir ) { +function mergeYAMLConfigs( originalConfig, newConfig, baseDir ) { // Loop through each element of newConfig, and test what should be done with them. Object.keys( newConfig ).forEach( ( key ) => { if ( ! originalConfig[ key ] ) { @@ -48,7 +48,7 @@ function mergeYamlConfigs( originalConfig, newConfig, baseDir ) { originalConfig[ key ] = [ ...cleanOriginal, ...newConfig[ key ] ]; } else if ( isPlainObject( newConfig[ key ] ) ) { // If the newConfig element is an object, we need to recursively merge it. - originalConfig[ key ] = mergeYamlConfigs( originalConfig[ key ], newConfig[ key ], baseDir ); + originalConfig[ key ] = mergeYAMLConfigs( originalConfig[ key ], newConfig[ key ], baseDir ); } else { // Any other data types are overwritten by the newConfig. originalConfig[ key ] = newConfig[ key ]; @@ -158,5 +158,5 @@ function buildWordPress( newInstall = true ) { module.exports = { buildWordPress, downloadWordPressZip, - mergeYamlConfigs, + mergeYAMLConfigs, }; diff --git a/packages/scripts/utils/index.js b/packages/scripts/utils/index.js index 0d026e299aeef..3d5e3bd7ac438 100644 --- a/packages/scripts/utils/index.js +++ b/packages/scripts/utils/index.js @@ -17,7 +17,7 @@ const { const { buildWordPress, downloadWordPressZip, - mergeYamlConfigs, + mergeYAMLConfigs, } = require( './env' ); const { fromConfigRoot, @@ -45,6 +45,6 @@ module.exports = { hasPackageProp, hasProjectFile, downloadWordPressZip, - mergeYamlConfigs, + mergeYAMLConfigs, spawnScript, }; From 13c1f9071255a65615d3dcc7ddc22c289eaf24f4 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 10:51:02 +1000 Subject: [PATCH 70/91] Reset the database before running e2e tests. --- package.json | 1 + packages/scripts/scripts/env.js | 1 + packages/scripts/scripts/env/install.js | 10 ++++++++-- packages/scripts/scripts/env/reinstall.js | 10 ++++++++++ packages/scripts/scripts/env/update.js | 4 ++-- packages/scripts/utils/env.js | 19 +++++++++++-------- 6 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 packages/scripts/scripts/env/reinstall.js diff --git a/package.json b/package.json index 2cfec6e1cb235..238c6a0dc1be3 100644 --- a/package.json +++ b/package.json @@ -206,6 +206,7 @@ "publish:dev": "npm run build:packages && lerna publish --npm-tag next", "publish:prod": "npm run build:packages && lerna publish", "test": "npm run lint && npm run test-unit", + "pretest-e2e": "npm run env reinstall", "test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js", "test-e2e:watch": "npm run test-e2e -- --watch", "test-performance": "wp-scripts test-e2e --config packages/e2e-tests/jest.performance.config.js", diff --git a/packages/scripts/scripts/env.js b/packages/scripts/scripts/env.js index b626304f33add..000a4fca2e270 100644 --- a/packages/scripts/scripts/env.js +++ b/packages/scripts/scripts/env.js @@ -27,6 +27,7 @@ if ( ! args.length ) { start: "This will start a container that you've already installed and connected to.", stop: "And this will stop it when you're done!", update: 'If you used ' + chalk.blue( 'npm run env install' ) + ' to setup WordPress, run this command to update it.', + reinstall: 'Resets the database and re-configures WordPress again.', cli: 'Run WP-CLI commands against the WordPress install.', 'lint-php': 'Run PHPCS linting on the plugin.', 'test-php': "Run the plugin's PHPUnit tests.", diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 770c83695fc2f..7eee086a05d84 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -18,9 +18,15 @@ const { buildWordPress, downloadWordPressZip, } = require( '../../utils' ); +const { hasArgInCLI } = require( '../../utils' ); env.WP_DEVELOP_DIR = normalize( cwd() + '/wordpress' ); +if ( hasArgInCLI( '--fast' ) ) { + buildWordPress( true, true ); + return; +} + if ( existsSync( normalize( cwd() + '/wordpress/wp-config-sample.php' ) ) ) { stdout.write( 'It looks like WordPress is already installed, please delete the `wordpress` directory for a fresh install, or run `npm run env start` to start the existing environment.\n' ); exit( 1 ); @@ -28,11 +34,11 @@ if ( existsSync( normalize( cwd() + '/wordpress/wp-config-sample.php' ) ) ) { if ( commandExistsSync( 'git' ) ) { execSync( 'git clone --depth=1 git://develop.git.wordpress.org/ wordpress', { stdio: 'inherit' } ); - buildWordPress(); + buildWordPress( true, false ); } else { stdout.write( "Git isn't available. Switching to downloading a zip version.\n" ); downloadWordPressZip() .then( () => { - buildWordPress(); + buildWordPress( true, false ); } ); } diff --git a/packages/scripts/scripts/env/reinstall.js b/packages/scripts/scripts/env/reinstall.js new file mode 100644 index 0000000000000..a2cfc8cbadf1a --- /dev/null +++ b/packages/scripts/scripts/env/reinstall.js @@ -0,0 +1,10 @@ +/** + * Node dependencies. + */ +const { execSync } = require( 'child_process' ); + +// Reset the database. +execSync( 'npm run env cli db reset -- --yes --quiet', { stdio: 'inherit' } ); + +// Do a fast install, no need to re-run the build commands again. +execSync( 'npm run env install -- --fast', { stdio: 'inherit' } ); diff --git a/packages/scripts/scripts/env/update.js b/packages/scripts/scripts/env/update.js index b61d9669273c1..f912992f0b115 100644 --- a/packages/scripts/scripts/env/update.js +++ b/packages/scripts/scripts/env/update.js @@ -22,11 +22,11 @@ env.WP_DEVELOP_DIR = normalize( cwd() + '/wordpress' ); if ( commandExistsSync( 'git' ) ) { execSync( 'git pull', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - buildWordPress(); + buildWordPress( false, false ); } else { stdout.write( "Git isn't available. Switching to downloading a zip version.\n" ); downloadWordPressZip() .then( () => { - buildWordPress( false ); + buildWordPress( false, false ); } ); } diff --git a/packages/scripts/utils/env.js b/packages/scripts/utils/env.js index d28afbfb2970e..7b2f6d46d6ec8 100644 --- a/packages/scripts/utils/env.js +++ b/packages/scripts/utils/env.js @@ -105,15 +105,18 @@ function downloadWordPressZip() { /** * Runs the appropriate build/install commands in the WordPress directory. * - * @param {boolean} newInstall Default true. Flag whether to treat this as a new WordPress install or not. + * @param {boolean} newInstall Flag whether to treat this as a new WordPress install or not. + * @param {boolean} fastInstall When set, assumes NPM dependencies are already downloaded, and build commands have been run. */ -function buildWordPress( newInstall = true ) { - execSync( 'npm install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - if ( env.LOCAL_DIR === 'build' ) { - execSync( 'npm run build', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); - } else { - execSync( 'npm run build:dev', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); +function buildWordPress( newInstall, fastInstall ) { + if ( ! fastInstall ) { + execSync( 'npm install', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + execSync( 'npm run env:start', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + if ( env.LOCAL_DIR === 'build' ) { + execSync( 'npm run build', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + } else { + execSync( 'npm run build:dev', { cwd: env.WP_DEVELOP_DIR, stdio: 'inherit' } ); + } } if ( newInstall ) { From bd9018203f45b7c87c82813852bccfdbe3fa9919 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 12:13:05 +1000 Subject: [PATCH 71/91] Try using Travis build stages to cache the slow parts. --- .travis.yml | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 457f0cb65adfd..d9334bce04c8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,10 @@ cache: - $HOME/.npm - $HOME/.nvm/.cache - $HOME/.phpbrew + - wordpress + - node_modules + - vendor + - build branches: only: @@ -26,34 +30,33 @@ env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - LOCAL_DIR: build - LOCAL_SCRIPT_DEBUG: false - - INSTALL_COMPOSER: false - - INSTALL_WORDPRESS: true + - INSTALL_AND_BUILD: false before_install: - nvm install - | - if [[ "$INSTALL_WORDPRESS" = "true" ]]; then - # upgrade docker-compose - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin - fi + # upgrade docker-compose + sudo rm /usr/local/bin/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin install: - - npm ci - - npm run build - | - if [[ "$INSTALL_WORDPRESS" = "true" ]]; then + if [[ "$INSTALL_AND_BUILD" = "true" ]]; then + # Build Gutenberg + npm ci + npm run build + # Install WordPress npm run env install mkdir -p wordpress/build/wp-content/uploads chmod 767 wordpress/build/wp-content/uploads - fi - - | - if [[ "$INSTALL_COMPOSER" = "true" ]]; then + npm run env docker-run -- php composer install + else + npm run env reinstall fi - | if [[ "$E2E_ROLE" = "author" ]]; then @@ -63,13 +66,12 @@ install: jobs: include: - - name: Lint - env: INSTALL_COMPOSER=true - script: - - npm run lint + - stage: Pre-tests + name: Warm up cache + env: INSTALL_AND_BUILD=true + script: true - name: Build artifacts - env: INSTALL_WORDPRESS=false install: # A "full" install is executed, since `npm ci` does not always exit # with an error status code if the lock file is inaccurate. @@ -79,13 +81,12 @@ jobs: script: - npm run check-local-changes - - name: License compatibility - env: INSTALL_WORDPRESS=false + - stage: Tests + name: License compatibility script: - npm run check-licenses - name: JavaScript unit tests - env: INSTALL_WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -94,7 +95,6 @@ jobs: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests - env: INSTALL_WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -102,13 +102,16 @@ jobs: - npx lerna run build - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" + - name: Lint + script: + - npm run lint + - name: PHP unit tests - env: INSTALL_COMPOSER=true script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - env: INSTALL_COMPOSER=true LOCAL_PHP=5.6-fpm + env: LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite From 12c52bb9059c0e1d74932f24c226f31e78f7f33c Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 12:34:16 +1000 Subject: [PATCH 72/91] Tweak the Travis caching. --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9334bce04c8e..a474beec39c0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ cache: - $HOME/.jest-cache - $HOME/.npm - $HOME/.nvm/.cache - - $HOME/.phpbrew - wordpress - node_modules - vendor @@ -71,7 +70,8 @@ jobs: env: INSTALL_AND_BUILD=true script: true - - name: Build artifacts + - stage: Tests + name: Build artifacts install: # A "full" install is executed, since `npm ci` does not always exit # with an error status code if the lock file is inaccurate. @@ -81,8 +81,7 @@ jobs: script: - npm run check-local-changes - - stage: Tests - name: License compatibility + - name: License compatibility script: - npm run check-licenses From 50748b9f51889d1942b294ae2148196c6fb9d6e0 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 13:28:45 +1000 Subject: [PATCH 73/91] Try to share the cache between builds. --- .travis.yml | 56 +++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index a474beec39c0f..da16c80b17768 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,10 +26,9 @@ branches: env: global: - - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - LOCAL_DIR: build - LOCAL_SCRIPT_DEBUG: false - - INSTALL_AND_BUILD: false + - FORCE_REDUCED_MOTION: true before_install: - nvm install @@ -41,33 +40,22 @@ before_install: sudo mv docker-compose /usr/local/bin install: - - | - if [[ "$INSTALL_AND_BUILD" = "true" ]]; then - # Build Gutenberg - npm ci - npm run build - - # Install WordPress - npm run env install - - mkdir -p wordpress/build/wp-content/uploads - chmod 767 wordpress/build/wp-content/uploads - - npm run env docker-run -- php composer install - else - npm run env reinstall - fi - - | - if [[ "$E2E_ROLE" = "author" ]]; then - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build - npm run env cli -- post update 1 --post_author=2 --path=build - fi + - npm run env install -- --fast jobs: include: - stage: Pre-tests name: Warm up cache - env: INSTALL_AND_BUILD=true + install: + # Build Gutenberg + - npm ci + - npm run build + # Install WordPress + - npm run env install + - mkdir -p wordpress/build/wp-content/uploads + - chmod 767 wordpress/build/wp-content/uploads + # Install Composer dependencies + - npm run env docker-run -- php composer install script: true - stage: Tests @@ -115,49 +103,53 @@ jobs: - npm run test-php && npm run test-unit-php-multisite - name: E2E tests (Admin) (1/4) - env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (2/4) - env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (3/4) - env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (4/4) - env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + before_script: + - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build + - npm run env cli -- post update 1 --post_author=2 --path=build script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + before_script: + - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build + - npm run env cli -- post update 1 --post_author=2 --path=build script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + before_script: + - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build + - npm run env cli -- post update 1 --post_author=2 --path=build script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + before_script: + - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build + - npm run env cli -- post update 1 --post_author=2 --path=build script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) From 8b356eb94af2af3a8dc6ca2dc28291cf40398a53 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 13:46:23 +1000 Subject: [PATCH 74/91] Speed up the cache warmup --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index da16c80b17768..f5db69cd116d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,7 @@ before_install: sudo mv docker-compose /usr/local/bin install: + - npm run env start - npm run env install -- --fast jobs: @@ -51,7 +52,11 @@ jobs: - npm ci - npm run build # Install WordPress - - npm run env install + - git clone --depth=1 git://develop.git.wordpress.org/ wordpress + - cd wordpress + - npm install + - npm run build + - cd .. - mkdir -p wordpress/build/wp-content/uploads - chmod 767 wordpress/build/wp-content/uploads # Install Composer dependencies @@ -98,7 +103,6 @@ jobs: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - env: LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite From 0903b9c6e19e4389095bee58e54aa1a7a271f183 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 13:57:03 +1000 Subject: [PATCH 75/91] Don't clone the repo if it's already cached. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f5db69cd116d5..b603024d359aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,8 +52,9 @@ jobs: - npm ci - npm run build # Install WordPress - - git clone --depth=1 git://develop.git.wordpress.org/ wordpress + - [ ! -d "wordpress/.git" ] && git clone --depth=1 git://develop.git.wordpress.org/ wordpress - cd wordpress + - git pull - npm install - npm run build - cd .. From e64edb81a4a9308ba533ff29c6c6b1e2da303686 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 14:28:03 +1000 Subject: [PATCH 76/91] Set the PHP version for PHP 5.6 tests. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index b603024d359aa..fcd1ab609f0ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -104,6 +104,9 @@ jobs: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) + install: + - export LOCAL_PHP=5.6-fpm + - npm run env start script: - npm run test-php && npm run test-unit-php-multisite From a6cf935e535ba7db6bbb59b60e59923bffd76d2a Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 14:34:11 +1000 Subject: [PATCH 77/91] Fix a .travis.yml parse error. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fcd1ab609f0ca..f38e9ce7e9f7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,10 @@ jobs: - npm ci - npm run build # Install WordPress - - [ ! -d "wordpress/.git" ] && git clone --depth=1 git://develop.git.wordpress.org/ wordpress + - | + if [ ! -d "wordpress/.git" ]; then + git clone --depth=1 git://develop.git.wordpress.org/ wordpress + fi - cd wordpress - git pull - npm install From 62e035c8951c4f5b2565bf5e52a5ddc4fa9ae077 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 14:51:50 +1000 Subject: [PATCH 78/91] Give MySQL some time to start. --- .travis.yml | 1 + packages/scripts/scripts/env/start.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f38e9ce7e9f7c..3b827fc605a49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,7 @@ before_install: install: - npm run env start + - sleep 30 - npm run env install -- --fast jobs: diff --git a/packages/scripts/scripts/env/start.js b/packages/scripts/scripts/env/start.js index f20a89b3554ef..b563b897ba0c8 100644 --- a/packages/scripts/scripts/env/start.js +++ b/packages/scripts/scripts/env/start.js @@ -14,10 +14,10 @@ const { statSync } = require( 'fs' ); if ( env.MANAGED_WP ) { // We're running in our managed WordPress environment, so check if we need to update. let stat; - if ( commandExistsSync( 'git' ) ) { + if ( false && commandExistsSync( 'git' ) ) { stat = statSync( normalize( env.WP_DEVELOP_DIR + '/.git' ) ); } else { - stat = statSync( normalize( env.WP_DEVELOP_DIR + '/.wp-config-sample.php' ) ); + stat = statSync( normalize( env.WP_DEVELOP_DIR + '/wp-config-sample.php' ) ); } const lastUpdated = new Date( stat.mtimeMs ); From 472ca3893f1e98bb25d08113d11746714fa37fbe Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 15:25:48 +1000 Subject: [PATCH 79/91] No need to cache wordpress/node_modules. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3b827fc605a49..c6754a3a7131f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -169,6 +169,9 @@ jobs: allow_failures: - name: JavaScript native mobile tests +before_cache: + - rm -rf wordpress/node_modules + before_deploy: - npm install - npm run playground:build -- --public-url '/gutenberg' From 4cdf186619103b33263f06129c728bde3c362e22 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 15:39:53 +1000 Subject: [PATCH 80/91] More Travis tweaking. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index c6754a3a7131f..838fd7466dd89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,7 @@ before_install: sudo mv docker-compose /usr/local/bin install: + - npm ci - npm run env start - sleep 30 - npm run env install -- --fast @@ -75,6 +76,7 @@ jobs: # with an error status code if the lock file is inaccurate. # # See: https://github.com/WordPress/gutenberg/issues/16157 + - rm -rf node_modules - npm install script: - npm run check-local-changes @@ -111,6 +113,7 @@ jobs: install: - export LOCAL_PHP=5.6-fpm - npm run env start + - sleep 30 script: - npm run test-php && npm run test-unit-php-multisite From 1b2cba5a6fff503d112f35c3be257d27f9d00cd0 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Aug 2019 16:12:59 +1000 Subject: [PATCH 81/91] Try not caching node_modules --- .travis.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 838fd7466dd89..09abbcda29e06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ cache: - $HOME/.npm - $HOME/.nvm/.cache - wordpress - - node_modules - vendor - build @@ -42,7 +41,7 @@ before_install: install: - npm ci - npm run env start - - sleep 30 + - sleep 10 - npm run env install -- --fast jobs: @@ -60,7 +59,7 @@ jobs: fi - cd wordpress - git pull - - npm install + - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm ci - npm run build - cd .. - mkdir -p wordpress/build/wp-content/uploads @@ -76,16 +75,17 @@ jobs: # with an error status code if the lock file is inaccurate. # # See: https://github.com/WordPress/gutenberg/issues/16157 - - rm -rf node_modules - npm install script: - npm run check-local-changes - name: License compatibility + install: npm ci script: - npm run check-licenses - name: JavaScript unit tests + install: npm ci script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -94,6 +94,7 @@ jobs: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests + install: npm ci script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -102,18 +103,24 @@ jobs: - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: Lint + install: npm ci script: - npm run lint - name: PHP unit tests + install: + - npm ci + - npm run env start + - sleep 10 script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) install: + - npm ci - export LOCAL_PHP=5.6-fpm - npm run env start - - sleep 30 + - sleep 10 script: - npm run test-php && npm run test-unit-php-multisite From 495766762a8c9fe494bf8f7bf2537c66b822ac03 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 10:16:10 +1000 Subject: [PATCH 82/91] Try manually downloading the built version of WordPress. --- .travis.yml | 147 ++++++++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 68 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09abbcda29e06..c6cf8dd2ada2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,7 @@ cache: - $HOME/.jest-cache - $HOME/.npm - $HOME/.nvm/.cache - - wordpress - - vendor - - build + - $HOME/.phpbrew branches: only: @@ -25,51 +23,83 @@ branches: env: global: + - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true + - WP_DEVELOP_DIR: ./wordpress - LOCAL_DIR: build - LOCAL_SCRIPT_DEBUG: false - - FORCE_REDUCED_MOTION: true + - INSTALL_COMPOSER: false + - INSTALL_WORDPRESS: true before_install: - nvm install - | - # upgrade docker-compose - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin + if [[ "$INSTALL_WORDPRESS" = "true" ]]; then + # Upgrade docker-compose. + sudo rm /usr/local/bin/docker-compose + curl -sL https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + fi install: + # Build Gutenberg. - npm ci - - npm run env start - - sleep 10 - - npm run env install -- --fast + - npm run build + - | + if [[ "$INSTALL_WORDPRESS" = "true" ]]; then + # Download and unpack WordPress. + curl s-L https://wordpress.org/nightly-builds/wordpress-latest.zip -o /tmp/wordpress-latest.zip + unzip /tmp/wordpress-latest.zip -d /tmp + mkdir -p wordpress/src + mkdir -p wordpress/build + mv /tmp/wordpress/* wordpress/build + + # Create the upload directory with permissions that Travis can handle. + mkdir -p wordpress/build/wp-content/uploads + chmod 767 wordpress/build/wp-content/uploads + + # Grab the tools we need for WordPress' local-env. + curl -sL https://github.com/WordPress/wordpress-develop/archive/master.zip -o /tmp/wordpress-develop.zip + unzip /tmp/wordpress-develop.zip -d /tmp + mv + /tmp/wordpress-develop-master/tools \ + /tmp/wordpress-develop-master/.env \ + /tmp/wordpress-develop-master/docker-compose.yml \ + /tmp/wordpress-develop-master/wp-cli.yml \ + /tmp/wordpress-develop-master/*config-sample.php \ + /tmp/wordpress-develop-master/package.json wordpress + + # Install WordPress. + cd wordpress + npm install dotenv wait-on + npm run env:start + sleep 10 + npm run env:install + cd .. + + # Connect Gutenberg to WordPress. + npm run env connect + npm run env cli plugin activate gutenberg + fi + - | + if [[ "$INSTALL_COMPOSER" = "true" ]]; then + composer install + fi + - | + if [[ "$E2E_ROLE" = "author" ]]; then + npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build + npm run env cli -- post update 1 --post_author=2 --path=build + fi jobs: include: - - stage: Pre-tests - name: Warm up cache - install: - # Build Gutenberg - - npm ci - - npm run build - # Install WordPress - - | - if [ ! -d "wordpress/.git" ]; then - git clone --depth=1 git://develop.git.wordpress.org/ wordpress - fi - - cd wordpress - - git pull - - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm ci - - npm run build - - cd .. - - mkdir -p wordpress/build/wp-content/uploads - - chmod 767 wordpress/build/wp-content/uploads - # Install Composer dependencies - - npm run env docker-run -- php composer install - script: true - - - stage: Tests - name: Build artifacts + - name: Lint + env: INSTALL_WORDPRESS=false INSTALL_COMPOSER=true + script: + - npm run lint + + - name: Build artifacts + env: INSTALL_WORDPRESS=false install: # A "full" install is executed, since `npm ci` does not always exit # with an error status code if the lock file is inaccurate. @@ -80,12 +110,12 @@ jobs: - npm run check-local-changes - name: License compatibility - install: npm ci + env: INSTALL_WORDPRESS=false script: - npm run check-licenses - name: JavaScript unit tests - install: npm ci + env: INSTALL_WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -94,7 +124,7 @@ jobs: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests - install: npm ci + env: INSTALL_WORDPRESS=false script: # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom @@ -102,76 +132,60 @@ jobs: - npx lerna run build - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - - name: Lint - install: npm ci - script: - - npm run lint - - name: PHP unit tests - install: - - npm ci - - npm run env start - - sleep 10 + env: INSTALL_COMPOSER=true script: - npm run test-php && npm run test-unit-php-multisite - name: PHP unit tests (PHP 5.6) - install: - - npm ci - - export LOCAL_PHP=5.6-fpm - - npm run env start - - sleep 10 + env: INSTALL_COMPOSER=true LOCAL_PHP=5.6-fpm script: - npm run test-php && npm run test-unit-php-multisite - name: E2E tests (Admin) (1/4) + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (2/4) + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (3/4) + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Admin) (4/4) + env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (1/4) - before_script: - - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build - - npm run env cli -- post update 1 --post_author=2 --path=build + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (2/4) - before_script: - - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build - - npm run env cli -- post update 1 --post_author=2 --path=build + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (3/4) - before_script: - - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build - - npm run env cli -- post update 1 --post_author=2 --path=build + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests ) - name: E2E tests (Author) (4/4) - before_script: - - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build - - npm run env cli -- post update 1 --post_author=2 --path=build + env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= script: - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests ) @@ -179,9 +193,6 @@ jobs: allow_failures: - name: JavaScript native mobile tests -before_cache: - - rm -rf wordpress/node_modules - before_deploy: - npm install - npm run playground:build -- --public-url '/gutenberg' From 81598015f0b70d98797d85aff4bf4d0800565da3 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 10:22:12 +1000 Subject: [PATCH 83/91] Fix up some Travis bugs. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6cf8dd2ada2c..89954f4585c23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ install: - | if [[ "$INSTALL_WORDPRESS" = "true" ]]; then # Download and unpack WordPress. - curl s-L https://wordpress.org/nightly-builds/wordpress-latest.zip -o /tmp/wordpress-latest.zip + curl -sL https://wordpress.org/nightly-builds/wordpress-latest.zip -o /tmp/wordpress-latest.zip unzip /tmp/wordpress-latest.zip -d /tmp mkdir -p wordpress/src mkdir -p wordpress/build @@ -83,7 +83,7 @@ install: fi - | if [[ "$INSTALL_COMPOSER" = "true" ]]; then - composer install + npm run env docker-run -- php composer install fi - | if [[ "$E2E_ROLE" = "author" ]]; then @@ -94,7 +94,7 @@ install: jobs: include: - name: Lint - env: INSTALL_WORDPRESS=false INSTALL_COMPOSER=true + env: INSTALL_WORDPRESS=false script: - npm run lint From 1c582cecb56970092b08d0bcaa26c315c05204f6 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 10:29:19 +1000 Subject: [PATCH 84/91] Add some debugging. --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 89954f4585c23..0adb9be1776a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,7 @@ install: if [[ "$INSTALL_WORDPRESS" = "true" ]]; then # Download and unpack WordPress. curl -sL https://wordpress.org/nightly-builds/wordpress-latest.zip -o /tmp/wordpress-latest.zip - unzip /tmp/wordpress-latest.zip -d /tmp + unzip -q /tmp/wordpress-latest.zip -d /tmp mkdir -p wordpress/src mkdir -p wordpress/build mv /tmp/wordpress/* wordpress/build @@ -60,7 +60,7 @@ install: # Grab the tools we need for WordPress' local-env. curl -sL https://github.com/WordPress/wordpress-develop/archive/master.zip -o /tmp/wordpress-develop.zip - unzip /tmp/wordpress-develop.zip -d /tmp + unzip -q /tmp/wordpress-develop.zip -d /tmp mv /tmp/wordpress-develop-master/tools \ /tmp/wordpress-develop-master/.env \ @@ -71,6 +71,8 @@ install: # Install WordPress. cd wordpress + pwd + ls -lah npm install dotenv wait-on npm run env:start sleep 10 From f8e5524efc8da36b32de07bf2d8818711e367e25 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 10:37:42 +1000 Subject: [PATCH 85/91] Travis: HALP HOW DO I mv --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0adb9be1776a6..e53113af0b288 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,7 @@ install: # Grab the tools we need for WordPress' local-env. curl -sL https://github.com/WordPress/wordpress-develop/archive/master.zip -o /tmp/wordpress-develop.zip unzip -q /tmp/wordpress-develop.zip -d /tmp - mv + mv \ /tmp/wordpress-develop-master/tools \ /tmp/wordpress-develop-master/.env \ /tmp/wordpress-develop-master/docker-compose.yml \ @@ -71,8 +71,6 @@ install: # Install WordPress. cd wordpress - pwd - ls -lah npm install dotenv wait-on npm run env:start sleep 10 From 84035b11ea5a78d45ff35d209253e9ea4a42966b Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 10:43:17 +1000 Subject: [PATCH 86/91] A little more tweaking. --- .travis.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index e53113af0b288..f089d5cc07e69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,6 @@ env: global: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - WP_DEVELOP_DIR: ./wordpress - - LOCAL_DIR: build - LOCAL_SCRIPT_DEBUG: false - INSTALL_COMPOSER: false - INSTALL_WORDPRESS: true @@ -51,12 +50,11 @@ install: curl -sL https://wordpress.org/nightly-builds/wordpress-latest.zip -o /tmp/wordpress-latest.zip unzip -q /tmp/wordpress-latest.zip -d /tmp mkdir -p wordpress/src - mkdir -p wordpress/build - mv /tmp/wordpress/* wordpress/build + mv /tmp/wordpress/* wordpress/src # Create the upload directory with permissions that Travis can handle. - mkdir -p wordpress/build/wp-content/uploads - chmod 767 wordpress/build/wp-content/uploads + mkdir -p wordpress/src/wp-content/uploads + chmod 767 wordpress/src/wp-content/uploads # Grab the tools we need for WordPress' local-env. curl -sL https://github.com/WordPress/wordpress-develop/archive/master.zip -o /tmp/wordpress-develop.zip @@ -87,8 +85,8 @@ install: fi - | if [[ "$E2E_ROLE" = "author" ]]; then - npm run env cli -- user create author author@example.com --role=author --user_pass=authpass --path=build - npm run env cli -- post update 1 --post_author=2 --path=build + npm run env cli -- user create author author@example.com --role=author --user_pass=authpass + npm run env cli -- post update 1 --post_author=2 fi jobs: @@ -116,20 +114,24 @@ jobs: - name: JavaScript unit tests env: INSTALL_WORDPRESS=false - script: + install: + - npm ci # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom # build tasks, however. These must be run. - npx lerna run build + script: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests env: INSTALL_WORDPRESS=false - script: + install: + - npm ci # It's not necessary to run the full build, since Jest can interpret # source files with `babel-jest`. Some packages have their own custom # build tasks, however. These must be run. - npx lerna run build + script: - npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: PHP unit tests From f36fb000a4a48bac13b60c94ce6ed156cc0caba8 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 11:18:14 +1000 Subject: [PATCH 87/91] Copy the tests directory from WP, too. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f089d5cc07e69..9354ecefd320b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,6 +61,7 @@ install: unzip -q /tmp/wordpress-develop.zip -d /tmp mv \ /tmp/wordpress-develop-master/tools \ + /tmp/wordpress-develop-master/tests \ /tmp/wordpress-develop-master/.env \ /tmp/wordpress-develop-master/docker-compose.yml \ /tmp/wordpress-develop-master/wp-cli.yml \ From a09be70adeed33fa3828732ab6aed135fa51f1d5 Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 11:22:10 +1000 Subject: [PATCH 88/91] Improve performance of lint and license tests. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9354ecefd320b..249abf1355440 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,12 +93,12 @@ install: jobs: include: - name: Lint - env: INSTALL_WORDPRESS=false + install: + - npm ci script: - npm run lint - name: Build artifacts - env: INSTALL_WORDPRESS=false install: # A "full" install is executed, since `npm ci` does not always exit # with an error status code if the lock file is inaccurate. @@ -109,7 +109,8 @@ jobs: - npm run check-local-changes - name: License compatibility - env: INSTALL_WORDPRESS=false + install: + - npm ci script: - npm run check-licenses @@ -125,7 +126,6 @@ jobs: - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - name: JavaScript native mobile tests - env: INSTALL_WORDPRESS=false install: - npm ci # It's not necessary to run the full build, since Jest can interpret From a47f54cc37dd473392458fe9e22af1eaa134b84d Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 11:48:49 +1000 Subject: [PATCH 89/91] Add documentation to README.md. --- packages/scripts/README.md | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/scripts/README.md b/packages/scripts/README.md index 50b95ff07c5e3..ff62c86c3352d 100644 --- a/packages/scripts/README.md +++ b/packages/scripts/README.md @@ -117,6 +117,56 @@ _Flags_: - `--gpl2`: Validates against [GPLv2 license compatibility](https://www.gnu.org/licenses/license-list.en.html) - `--ignore=a,b,c`: A comma-separated set of package names to ignore for validation. This is intended to be used primarily in cases where a dependency’s `license` field is malformed. It’s assumed that any `ignored` package argument would be manually vetted for compatibility by the project owner. +### `env` + +`env` is a family of scripts for setting up a local Docker-based development environment that plugin contributors can work in. + +To get started, it requires some configuration in your `package.json`: + +_Example:_ + +```json +{ + "scripts": { + "env": "wp-scripts env" + }, + "wp-env": { + "plugin-dir": "gutenberg", + "plugin-name": "Gutenberg", + "docker-template": "./bin/docker-compose.override.yml.template", + "welcome-logo": [ + ",⁻⁻⁻· . |", + "| ،⁓’. . |--- ,---. ,---. |---. ,---. ,---. ,---.", + "| | | | | |---' | | | | |---' | | |", + "`---' `---' `---’ `---’ ' ` `---' `---’ ` `---|", + " `---'" + ], + "welcome-build-command": "npm run dev" + } +} +``` + +In the `wp-env` config block, each entry can be configured like so: +- `plugin-dir`: Required. The name of the plugin directory within `wp-content/plugins` that this plugin will be mounted in. +- `plugin-name`: Required. The display name for this plugin. +- `docker-template`: Optional. If you need to customize the default `docker-compose.override.yml.template`, this is the path to your customized version. +- `welcome-logo`: Optional. An ASCII art logo to show after `npm run env install` finishes. +- `welcome-build-command`: Optional. The build command to show after `npm run env install` finishes, helping contributors move on to the next step. + +#### Available Sub-Scripts + +- `install`: Automatically downloads, builds, and installs a copy of WordPress to work with. This will be installed in the `wordpress` folder inside your project. You should add `wordpress` to your `.gitignore` file. +- `connect`: For contributors that have a WordPress respository already, they can define the `WP_DEVELOP_DIR` environment variable with the path to their repository, then run this command to add your plugin to it. +- `start`: Starts the Docker containers. +- `stop`: Stops the Docker containers. +- `update`: For contributors that used `npm run env install` to setup WordPress, running this command will update it to the latest checkout. +- `reinstall`: Resets the database and re-configures WordPress again. +- `cli`: Runs WP-CLI commands against the WordPress install. +- `lint-php`: Run PHPCS linting on your plugin. You will need to have `composer.json` configured to install PHPCS, with a `lint` script that runs your linting. You will also need to have an appropriately configured `phpcs.xml.dist` file. +- `test-php`: Runs your plugin's PHPUnit tests. You will need to have an appropriately configured `phpunit.xml.dist` file. +- `docker-run`: For more advanced debugging, contributors may sometimes need to run commands in the Docker containers. This is the equivalent of running `docker-compose run` within the WordPress directory. + + ### `lint-js` Helps enforce coding style guidelines for your JavaScript files. From bc69eda9391b7519048a88103869a778ce2d069a Mon Sep 17 00:00:00 2001 From: Gary Date: Wed, 28 Aug 2019 11:52:27 +1000 Subject: [PATCH 90/91] Travis: Cache the cacheable bits of Composer. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 249abf1355440..2fc9a43a3a61c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,10 @@ notifications: cache: directories: + - $HOME/.composer/cache - $HOME/.jest-cache - $HOME/.npm - $HOME/.nvm/.cache - - $HOME/.phpbrew branches: only: From ab6f7e04baf8f2ab58851d3a7af1cc2abb493537 Mon Sep 17 00:00:00 2001 From: Gary Date: Fri, 30 Aug 2019 09:56:10 +1000 Subject: [PATCH 91/91] Update the @wordpress/scripts changelog. --- packages/scripts/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 0558ef4dc33ab..8817e8a699bfa 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### New Features + +- Add the new `env` family of scripts [(#17004](https://github.com/WordPress/gutenberg/pull/17004/)). + ## 4.0.0 (2019-08-29) ### Breaking Changes