idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
5,200
|
public function checkUrl ( $ url ) { try { $ client = new Client ( ) ; $ res = $ client -> request ( 'GET' , $ url , [ 'connection_timeout' => 2 , 'timeout' => 2 , 'exceptions' => FALSE , ] ) ; if ( $ res -> getStatusCode ( ) && substr ( $ res -> getStatusCode ( ) , 0 , 1 ) != '5' ) { return TRUE ; } else { $ this -> logger -> debug ( $ res -> getBody ( ) ) ; return FALSE ; } } catch ( \ Exception $ e ) { $ this -> logger -> debug ( $ e -> getMessage ( ) ) ; } return FALSE ; }
|
Checks a URL for a non - 50x response .
|
5,201
|
protected function checkDevDesktop ( ) { if ( $ this -> getInspector ( ) -> isDevDesktopInitialized ( ) ) { if ( empty ( $ _ENV [ 'DEVDESKTOP_DRUPAL_SETTINGS_DIR' ] ) ) { $ this -> logProblem ( __FUNCTION__ , [ "DevDesktop usage is enabled, but \$DEVDESKTOP_DRUPAL_SETTINGS_DIR is not set in your environmental variables." , "" , "Add `export DEVDESKTOP_DRUPAL_SETTINGS_DIR=\"\$HOME/.acquia/DevDesktop/DrupalSettings\"` to ~/.bash_profile or equivalent for your system.`" , ] , 'error' ) ; } elseif ( strstr ( $ _ENV [ 'DEVDESKTOP_DRUPAL_SETTINGS_DIR' ] , '~' ) ) { $ this -> logProblem ( __FUNCTION__ , [ "\$DEVDESKTOP_DRUPAL_SETTINGS_DIR contains a '~'. This does not always expand to your home directory." , "" , "Add `export DEVDESKTOP_DRUPAL_SETTINGS_DIR=\"\$HOME/.acquia/DevDesktop/DrupalSettings\"` to ~/.bash_profile or equivalent for your system.`" , ] , 'error' ) ; } $ variables_order = ini_get ( 'variables_order' ) ; $ php_ini_file = php_ini_loaded_file ( ) ; if ( ! strstr ( $ variables_order , 'E' ) ) { $ this -> logProblem ( __FUNCTION__ , [ "DevDesktop usage is enabled, but variables_order does support environmental variables." , "" , "Define variables_order = \"EGPCS\" in $php_ini_file" , ] , 'error' ) ; } } }
|
Checks that Dev Desktop is configured correctly .
|
5,202
|
public function registerFilesets ( ) { $ classes = [ \ Acquia \ Blt \ Robo \ Filesets \ Filesets :: class , \ Acquia \ Blt \ Custom \ Filesets :: class , ] ; $ fileset_annotations = $ this -> getAllFilesetAnnotations ( $ classes ) ; $ filesets = $ this -> getFilesetsFromAnnotations ( $ fileset_annotations ) ; $ this -> filesets = $ filesets ; }
|
Registers filesets .
|
5,203
|
protected function getFilesetsFromAnnotations ( $ fileset_annotations ) { $ filesets = [ ] ; $ this -> logger -> debug ( "Gathering filesets from annotated methods..." ) ; ; foreach ( $ fileset_annotations as $ class => $ fileset ) { if ( class_exists ( $ class ) ) { $ fileset_class = new $ class ( ) ; $ fileset_class -> setConfig ( $ this -> config ) ; foreach ( $ fileset as $ id => $ method_name ) { $ this -> logger -> debug ( "Calling $method_name on $class object..." ) ; if ( method_exists ( $ fileset_class , $ method_name ) ) { $ filesets [ $ id ] = call_user_func_array ( [ $ fileset_class , $ method_name ] , [ ] ) ; } } } } return $ filesets ; }
|
Gets an array of instantiated filesets given an array of annotations .
|
5,204
|
protected function yell ( $ text , $ length = 40 , $ color = 'green' ) { $ format = "<fg=white;bg=$color;options=bold>%s</fg=white;bg=$color;options=bold>" ; $ this -> formattedOutput ( $ text , $ length , $ format ) ; }
|
Writes text to screen with big loud decoration .
|
5,205
|
protected function askChoice ( $ question , $ options , $ default = NULL ) { return $ this -> doAsk ( new ChoiceQuestion ( $ this -> formatQuestion ( $ question ) , $ options , $ default ) ) ; }
|
Asks the user a multiple - choice question .
|
5,206
|
protected function askRequired ( $ message ) { $ question = new Question ( $ this -> formatQuestion ( $ message ) ) ; $ question -> setValidator ( function ( $ answer ) { if ( empty ( $ answer ) ) { throw new \ RuntimeException ( 'You must enter a value!' ) ; } return $ answer ; } ) ; return $ this -> doAsk ( $ question ) ; }
|
Asks a required question .
|
5,207
|
protected function printArrayAsTable ( array $ array , array $ headers = [ 'Property' , 'Value' ] ) { $ table = new Table ( $ this -> output ) ; $ table -> setHeaders ( $ headers ) -> setRows ( ArrayManipulator :: convertArrayToFlatTextArray ( $ array ) ) -> render ( ) ; }
|
Writes an array to the screen as a formatted table .
|
5,208
|
protected function logConfig ( array $ array , $ prefix = '' , $ verbosity = OutputInterface :: VERBOSITY_VERY_VERBOSE ) { if ( $ this -> output ( ) -> getVerbosity ( ) >= $ verbosity ) { if ( $ prefix ) { $ this -> output ( ) -> writeln ( "<comment>Configuration for $prefix:</comment>" ) ; foreach ( $ array as $ key => $ value ) { $ array [ "$prefix.$key" ] = $ value ; unset ( $ array [ $ key ] ) ; } } $ this -> printArrayAsTable ( $ array ) ; } }
|
Writes a particular configuration key s value to the log .
|
5,209
|
private function addBuiltInCommandsAndHooks ( ) { $ commands = $ this -> getCommands ( [ 'path' => __DIR__ . '/Commands' , 'namespace' => 'Acquia\Blt\Robo\Commands' , ] ) ; $ hooks = $ this -> getHooks ( [ 'path' => __DIR__ . '/Hooks' , 'namespace' => 'Acquia\Blt\Robo\Hooks' , ] ) ; $ this -> commands = array_merge ( $ commands , $ hooks ) ; }
|
Add the commands and hooks which are shipped with core BLT .
|
5,210
|
private function getCommands ( array $ options = [ 'path' => NULL , 'namespace' => NULL ] ) { $ discovery = new CommandFileDiscovery ( ) ; $ discovery -> setSearchPattern ( '*Command.php' ) -> setSearchLocations ( [ ] ) -> addExclude ( 'Internal' ) ; return $ discovery -> discover ( $ options [ 'path' ] , $ options [ 'namespace' ] ) ; }
|
Discovers command classes using CommandFileDiscovery .
|
5,211
|
private function getHooks ( array $ options = [ 'path' => NULL , 'namespace' => NULL ] ) { $ discovery = new CommandFileDiscovery ( ) ; $ discovery -> setSearchPattern ( '*Hook.php' ) -> setSearchLocations ( [ ] ) ; return $ discovery -> discover ( $ options [ 'path' ] , $ options [ 'namespace' ] ) ; }
|
Discovers hooks using CommandFileDiscovery .
|
5,212
|
private function addDefaultArgumentsAndOptions ( Application $ app ) { $ app -> getDefinition ( ) -> addOption ( new InputOption ( '--define' , '-D' , InputOption :: VALUE_REQUIRED | InputOption :: VALUE_IS_ARRAY , 'Define a configuration item value.' , [ ] ) ) ; $ app -> getDefinition ( ) -> addOption ( new InputOption ( '--environment' , NULL , InputOption :: VALUE_REQUIRED , 'Set the environment to load config from blt/[env].yml file.' , [ ] ) ) ; $ app -> getDefinition ( ) -> addOption ( new InputOption ( '--site' , NULL , InputOption :: VALUE_REQUIRED , 'The multisite to execute this command against.' , [ ] ) ) ; }
|
Add any global arguments or options that apply to all commands .
|
5,213
|
public function configureContainer ( $ container ) { $ container -> share ( 'logStyler' , BltLogStyle :: class ) ; $ blt_tasks = new BltTasks ( ) ; $ builder = new CollectionBuilder ( $ blt_tasks ) ; $ blt_tasks -> setBuilder ( $ builder ) ; $ container -> add ( 'builder' , $ builder ) ; $ container -> add ( 'executor' , Executor :: class ) -> withArgument ( 'builder' ) ; $ container -> share ( 'inspector' , Inspector :: class ) -> withArgument ( 'executor' ) ; $ container -> inflector ( InspectorAwareInterface :: class ) -> invokeMethod ( 'setInspector' , [ 'inspector' ] ) ; $ container -> add ( SetupWizard :: class ) -> withArgument ( 'executor' ) ; $ container -> add ( TestsWizard :: class ) -> withArgument ( 'executor' ) ; $ container -> share ( 'filesetManager' , FilesetManager :: class ) ; $ updater = new Updater ( 'Acquia\Blt\Update\Updates' , $ this -> getConfig ( ) -> get ( 'repo.root' ) ) ; $ container -> share ( 'updater' , $ updater ) ; $ factory = $ container -> get ( 'commandFactory' ) ; $ factory -> setIncludeAllPublicMethods ( FALSE ) ; $ factory -> addCommandInfoAlterer ( new BltCommandInfoAlterer ( ) ) ; }
|
Register the necessary classes for BLT .
|
5,214
|
public function run ( InputInterface $ input , OutputInterface $ output ) { $ application = $ this -> getContainer ( ) -> get ( 'application' ) ; $ status_code = $ this -> runner -> run ( $ input , $ output , $ application , $ this -> commands ) ; return $ status_code ; }
|
Runs the instantiated BLT application .
|
5,215
|
public function expandFileProperties ( $ filename ) { $ expanded_contents = Expander :: expandArrayProperties ( file ( $ filename ) , $ this -> export ( ) ) ; file_put_contents ( $ filename , implode ( "" , $ expanded_contents ) ) ; }
|
Expands YAML placeholders in a given file using config object .
|
5,216
|
public function set ( $ key , $ value ) { if ( $ value === 'false' ) { $ value = FALSE ; } elseif ( $ value === 'true' ) { $ value = TRUE ; } if ( is_string ( $ value ) && strstr ( $ value , '$' ) ) { $ expanded = Expander :: expandArrayProperties ( [ $ value ] , $ this -> export ( ) ) ; $ value = $ expanded [ 0 ] ; } return parent :: set ( $ key , $ value ) ; }
|
Set a config value .
|
5,217
|
public function get ( $ key , $ defaultOverride = NULL ) { $ value = parent :: get ( $ key , $ defaultOverride ) ; if ( is_string ( $ value ) && strstr ( $ value , '$' ) ) { $ expanded = Expander :: expandArrayProperties ( [ $ value ] , $ this -> export ( ) ) ; $ value = $ expanded [ 0 ] ; } return $ value ; }
|
Fetch a configuration value .
|
5,218
|
public function deploy ( $ options = [ 'branch' => InputOption :: VALUE_REQUIRED , 'tag' => InputOption :: VALUE_REQUIRED , 'commit-msg' => InputOption :: VALUE_REQUIRED , 'ignore-dirty' => FALSE , 'dry-run' => FALSE , 'ignore-platform-reqs' => FALSE , ] ) { if ( $ options [ 'dry-run' ] ) { $ this -> logger -> warning ( "This will be a dry run, the artifact will not be pushed." ) ; } $ this -> checkDirty ( $ options ) ; if ( isset ( $ options [ 'ignore-platform-reqs' ] ) ) { $ this -> ignorePlatformReqs = $ options [ 'ignore-platform-reqs' ] ; } if ( ! $ options [ 'tag' ] && ! $ options [ 'branch' ] ) { $ this -> createTag = $ this -> confirm ( "Would you like to create a tag?" , $ this -> createTag ) ; } $ this -> commitMessage = $ this -> getCommitMessage ( $ options ) ; if ( $ options [ 'tag' ] || $ this -> createTag ) { if ( ! $ this -> tagSource ) { $ this -> say ( "Config option deploy.tag_source if FALSE. The source repo will not be tagged." ) ; } $ this -> deployToTag ( $ options ) ; } else { $ this -> deployToBranch ( $ options ) ; } }
|
Builds separate artifact and pushes to git . remotes defined blt . yml .
|
5,219
|
protected function getCommitMessage ( $ options ) { if ( ! $ options [ 'commit-msg' ] ) { chdir ( $ this -> getConfigValue ( 'repo.root' ) ) ; $ log = explode ( ' ' , shell_exec ( "git log --oneline -1" ) , 2 ) ; $ git_last_commit_message = trim ( $ log [ 1 ] ) ; return $ this -> askDefault ( 'Enter a valid commit message' , $ git_last_commit_message ) ; } else { $ this -> say ( "Commit message is set to <comment>{$options['commit-msg']}</comment>." ) ; return $ options [ 'commit-msg' ] ; } }
|
Gets the commit message to be used for committing deployment artifact .
|
5,220
|
protected function getBranchName ( $ options ) { if ( $ options [ 'branch' ] ) { $ this -> say ( "Branch is set to <comment>{$options['branch']}</comment>." ) ; return $ options [ 'branch' ] ; } else { return $ this -> askDefault ( 'Enter the branch name for the deployment artifact' , $ this -> getDefaultBranchName ( ) ) ; } }
|
Gets the branch name for the deployment artifact .
|
5,221
|
protected function getTagName ( $ options ) { if ( $ options [ 'tag' ] ) { $ tag_name = $ options [ 'tag' ] ; } else { $ tag_name = $ this -> ask ( 'Enter the tag name for the deployment artifact, e.g., 1.0.0-build' ) ; } if ( empty ( $ tag_name ) ) { throw new BltException ( "You must enter a valid tag name." ) ; } else { $ this -> say ( "Tag is set to <comment>$tag_name</comment>." ) ; } return $ tag_name ; }
|
Gets the name of the tag to cut .
|
5,222
|
protected function getDefaultBranchName ( ) { chdir ( $ this -> getConfigValue ( 'repo.root' ) ) ; $ git_current_branch = trim ( shell_exec ( "git rev-parse --abbrev-ref HEAD" ) ) ; $ default_branch = $ git_current_branch . '-build' ; return $ default_branch ; }
|
Gets the default branch name for the deployment artifact .
|
5,223
|
protected function deployToTag ( $ options ) { $ this -> tagName = $ this -> getTagName ( $ options ) ; $ this -> branchName = $ this -> getDefaultBranchName ( ) . '-temp' ; $ this -> prepareDir ( ) ; $ this -> addGitRemotes ( ) ; $ this -> checkoutLocalDeployBranch ( ) ; $ this -> build ( ) ; $ this -> commit ( ) ; $ this -> cutTag ( 'build' ) ; if ( $ this -> tagSource ) { $ this -> cutTag ( 'source' ) ; } $ this -> push ( $ this -> tagName , $ options ) ; }
|
Creates artifact cuts new tag and pushes .
|
5,224
|
protected function deployToBranch ( $ options ) { $ this -> branchName = $ this -> getBranchName ( $ options ) ; $ this -> prepareDir ( ) ; $ this -> addGitRemotes ( ) ; $ this -> checkoutLocalDeployBranch ( ) ; $ this -> mergeUpstreamChanges ( ) ; $ this -> build ( ) ; $ this -> commit ( ) ; $ this -> push ( $ this -> branchName , $ options ) ; }
|
Creates artifact on branch and pushes .
|
5,225
|
protected function prepareDir ( ) { $ this -> say ( "Preparing artifact directory..." ) ; $ deploy_dir = $ this -> deployDir ; $ this -> taskDeleteDir ( $ deploy_dir ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; $ this -> taskFilesystemStack ( ) -> mkdir ( $ this -> deployDir ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> stopOnFail ( ) -> run ( ) ; $ this -> taskExecStack ( ) -> dir ( $ deploy_dir ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> stopOnFail ( ) -> exec ( "git init" ) -> exec ( "git config --local core.excludesfile false" ) -> exec ( "git config --local core.fileMode true" ) -> run ( ) ; $ this -> say ( "Global .gitignore file is being disabled for this repository to prevent unexpected behavior." ) ; }
|
Deletes the existing deploy directory and initializes git repo .
|
5,226
|
protected function checkoutLocalDeployBranch ( ) { $ this -> taskExecStack ( ) -> dir ( $ this -> deployDir ) -> stopOnFail ( FALSE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> exec ( "git checkout -b {$this->branchName}" ) -> run ( ) ; }
|
Checks out a new local branch for artifact .
|
5,227
|
protected function mergeUpstreamChanges ( ) { $ git_remotes = $ this -> getConfigValue ( 'git.remotes' ) ; $ remote_url = reset ( $ git_remotes ) ; $ remote_name = md5 ( $ remote_url ) ; $ this -> say ( "Merging upstream changes into local artifact..." ) ; $ this -> taskExecStack ( ) -> dir ( $ this -> deployDir ) -> stopOnFail ( FALSE ) -> exec ( "git fetch $remote_name {$this->branchName} --depth=1" ) -> exec ( "git merge $remote_name/{$this->branchName}" ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; }
|
Merges upstream changes into deploy branch .
|
5,228
|
public function build ( ) { $ this -> say ( "Generating build artifact..." ) ; $ this -> say ( "For more detailed output, use the -v flag." ) ; $ commands = [ 'source:build:frontend' , 'drupal:hash-salt:init' , ] ; if ( ! empty ( $ this -> tagName ) ) { $ commands [ 'drupal:deployment-identifier:init' ] = [ '--id' => $ this -> tagName ] ; } else { $ commands [ ] = 'drupal:deployment-identifier:init' ; } $ this -> invokeCommands ( $ commands ) ; $ this -> buildCopy ( ) ; $ this -> composerInstall ( ) ; $ this -> sanitize ( ) ; $ this -> deploySamlConfig ( ) ; $ this -> invokeHook ( "post-deploy-build" ) ; $ this -> say ( "<info>The deployment artifact was generated at {$this->deployDir}.</info>" ) ; }
|
Builds deployment artifact .
|
5,229
|
protected function buildCopy ( ) { $ exclude_list_file = $ this -> getExcludeListFile ( ) ; $ source = $ this -> getConfigValue ( 'repo.root' ) ; $ dest = $ this -> deployDir ; $ this -> setMultisiteFilePermissions ( 0777 ) ; $ this -> say ( "Rsyncing files from source repo into the build artifact..." ) ; $ this -> taskExecStack ( ) -> exec ( "rsync -a --no-g --delete --delete-excluded --exclude-from='$exclude_list_file' '$source/' '$dest/' --filter 'protect /.git/'" ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> stopOnFail ( ) -> dir ( $ this -> getConfigValue ( 'repo.root' ) ) -> run ( ) ; $ this -> setMultisiteFilePermissions ( 0755 ) ; $ this -> taskFilesystemStack ( ) -> remove ( $ this -> excludeFileTemp ) -> copy ( $ this -> getConfigValue ( 'deploy.gitignore_file' ) , $ this -> deployDir . '/.gitignore' , TRUE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; }
|
Copies files from source repo into artifact .
|
5,230
|
protected function composerInstall ( ) { if ( ! $ this -> getConfigValue ( 'deploy.build-dependencies' ) ) { $ this -> logger -> warning ( "Dependencies will not be built because deploy.build-dependencies is not enabled" ) ; $ this -> logger -> warning ( "You should define a custom deploy.exclude_file to ensure that dependencies are copied from the root repository." ) ; return FALSE ; } $ this -> say ( "Rebuilding composer dependencies for production..." ) ; $ this -> taskDeleteDir ( [ $ this -> deployDir . '/vendor' ] ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; $ this -> taskFilesystemStack ( ) -> copy ( $ this -> getConfigValue ( 'repo.root' ) . '/composer.json' , $ this -> deployDir . '/composer.json' , TRUE ) -> copy ( $ this -> getConfigValue ( 'repo.root' ) . '/composer.lock' , $ this -> deployDir . '/composer.lock' , TRUE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; $ command = 'composer install --no-dev --no-interaction --optimize-autoloader' ; if ( $ this -> ignorePlatformReqs ) { $ command .= ' --ignore-platform-reqs' ; } $ this -> taskExecStack ( ) -> exec ( $ command ) -> stopOnFail ( ) -> dir ( $ this -> deployDir ) -> run ( ) ; }
|
Installs composer dependencies for artifact .
|
5,231
|
protected function sanitize ( ) { $ this -> say ( "Sanitizing artifact..." ) ; $ this -> logger -> info ( "Find Drupal core text files..." ) ; $ sanitizeFinder = Finder :: create ( ) -> files ( ) -> name ( '*.txt' ) -> notName ( 'LICENSE.txt' ) -> in ( "{$this->deployDir}/docroot/core" ) ; $ this -> logger -> info ( 'Find VCS directories...' ) ; $ vcsFinder = Finder :: create ( ) -> ignoreDotFiles ( FALSE ) -> ignoreVCS ( FALSE ) -> directories ( ) -> in ( [ "{$this->deployDir}/docroot" , "{$this->deployDir}/vendor" ] ) -> name ( '.git' ) ; if ( $ vcsFinder -> hasResults ( ) ) { $ sanitizeFinder -> append ( $ vcsFinder ) ; } $ this -> logger -> info ( "Find Github directories..." ) ; $ githubFinder = Finder :: create ( ) -> ignoreDotFiles ( FALSE ) -> directories ( ) -> in ( [ "{$this->deployDir}/docroot" , "{$this->deployDir}/vendor" ] ) -> name ( '.github' ) ; if ( $ githubFinder -> hasResults ( ) ) { $ sanitizeFinder -> append ( $ githubFinder ) ; } $ this -> logger -> info ( 'Find INSTALL database text files...' ) ; $ dbInstallFinder = Finder :: create ( ) -> files ( ) -> in ( [ "{$this->deployDir}/docroot" ] ) -> name ( '/INSTALL\.[a-z]+\.(md|txt)$/' ) ; if ( $ dbInstallFinder -> hasResults ( ) ) { $ sanitizeFinder -> append ( $ dbInstallFinder ) ; } $ this -> logger -> info ( 'Find other common text files...' ) ; $ filenames = [ 'AUTHORS' , 'CHANGELOG' , 'CONDUCT' , 'CONTRIBUTING' , 'INSTALL' , 'MAINTAINERS' , 'PATCHES' , 'TESTING' , 'UPDATE' , ] ; $ textFileFinder = Finder :: create ( ) -> files ( ) -> in ( [ "{$this->deployDir}/docroot" ] ) -> name ( '/(' . implode ( '|' , $ filenames ) . ')\.(md|txt)$/' ) ; if ( $ textFileFinder -> hasResults ( ) ) { $ sanitizeFinder -> append ( $ textFileFinder ) ; } $ this -> logger -> info ( "Remove sanitized files from build..." ) ; $ taskFilesystemStack = $ this -> taskFilesystemStack ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) ; foreach ( $ sanitizeFinder -> getIterator ( ) as $ fileInfo ) { $ taskFilesystemStack -> remove ( $ fileInfo -> getRealPath ( ) ) ; } $ taskFilesystemStack -> run ( ) ; }
|
Removes sensitive files from the deploy dir .
|
5,232
|
protected function getExcludeListFile ( ) { $ exclude_file = $ this -> getConfigValue ( 'deploy.exclude_file' ) ; $ exclude_additions = $ this -> getConfigValue ( 'deploy.exclude_additions_file' ) ; if ( file_exists ( $ exclude_additions ) ) { $ this -> say ( "Combining exclusions from deploy.deploy-exclude-additions and deploy.deploy-exclude files..." ) ; $ exclude_file = $ this -> mungeExcludeLists ( $ exclude_file , $ exclude_additions ) ; } return $ exclude_file ; }
|
Gets the file that lists the excludes for the artifact .
|
5,233
|
protected function mungeExcludeLists ( $ file1 , $ file2 ) { $ file1_contents = file ( $ file1 ) ; $ file2_contents = file ( $ file2 ) ; $ merged = array_merge ( $ file1_contents , $ file2_contents ) ; $ merged_without_dups = array_unique ( $ merged ) ; file_put_contents ( $ this -> excludeFileTemp , $ merged_without_dups ) ; return $ this -> excludeFileTemp ; }
|
Combines deploy . exclude_file with deploy . exclude_additions_file .
|
5,234
|
protected function setMultisiteFilePermissions ( $ perms ) { $ taskFilesystemStack = $ this -> taskFilesystemStack ( ) ; $ multisites = $ this -> getConfigValue ( 'multisites' ) ; foreach ( $ multisites as $ multisite ) { $ multisite_dir = $ this -> getConfigValue ( 'docroot' ) . '/sites/' . $ multisite ; $ taskFilesystemStack -> chmod ( $ multisite_dir , $ perms ) ; } $ taskFilesystemStack -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) ; $ taskFilesystemStack -> run ( ) ; }
|
Sets permissions for all multisite directories .
|
5,235
|
protected function commit ( ) { $ this -> say ( "Committing artifact to <comment>{$this->branchName}</comment>..." ) ; $ result = $ this -> taskGit ( ) -> dir ( $ this -> deployDir ) -> exec ( "git rm -r --cached --ignore-unmatch --quiet ." ) -> add ( '-A' ) -> commit ( $ this -> commitMessage , '--quiet' ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Failed to commit deployment artifact!" ) ; } }
|
Creates a commit on the artifact .
|
5,236
|
protected function push ( $ identifier , $ options ) { if ( $ options [ 'dry-run' ] ) { $ this -> logger -> warning ( "Skipping push of deployment artifact. deploy.dryRun is set to true." ) ; return FALSE ; } else { $ this -> say ( "Pushing artifact to git.remotes..." ) ; } $ task = $ this -> taskExecStack ( ) -> dir ( $ this -> deployDir ) ; foreach ( $ this -> getConfigValue ( 'git.remotes' ) as $ remote ) { $ remote_name = md5 ( $ remote ) ; $ task -> exec ( "git push $remote_name $identifier" ) ; } $ result = $ task -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Failed to push deployment artifact!" ) ; } }
|
Pushes the artifact to git . remotes .
|
5,237
|
protected function cutTag ( $ repo = 'build' ) { $ taskGit = $ this -> taskGit ( ) -> tag ( $ this -> tagName , $ this -> commitMessage ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> stopOnFail ( ) ; if ( $ repo == 'build' ) { $ taskGit -> dir ( $ this -> deployDir ) ; } $ result = $ taskGit -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Failed to create Git tag!" ) ; } $ this -> say ( "The tag {$this->tagName} was created on the {$repo} repository." ) ; }
|
Creates a tag on the build repository .
|
5,238
|
public function updateAll ( ) { $ this -> config -> set ( 'drush.alias' , '' ) ; foreach ( $ this -> getConfigValue ( 'multisites' ) as $ multisite ) { $ this -> updateSite ( $ multisite ) ; } }
|
Update the database to reflect the state of the Drupal file system .
|
5,239
|
public function syncRefresh ( ) { $ this -> config -> set ( 'drush.alias' , '' ) ; $ this -> config -> set ( 'sync.files' , TRUE ) ; foreach ( $ this -> getConfigValue ( 'multisites' ) as $ multisite ) { $ this -> say ( "Syncing $multisite..." ) ; if ( ! $ this -> config -> get ( 'drush.uri' ) ) { $ this -> config -> set ( 'drush.uri' , $ multisite ) ; } $ this -> invokeCommand ( 'drupal:sync:db' ) ; $ this -> invokeCommand ( 'drupal:sync:files' ) ; $ this -> invokeCommand ( 'drupal:update' ) ; $ this -> say ( "Finished syncing $multisite." ) ; } }
|
Syncs database and files and runs updates .
|
5,240
|
public function update_8006000 ( ) { $ this -> updater -> moveFile ( 'project.yml' , 'blt/project.yml' , TRUE ) ; $ this -> updater -> moveFile ( 'project.local.yml' , 'blt/project.local.yml' , TRUE ) ; $ this -> updater -> moveFile ( 'example.project.local.yml' , 'blt/example.project.local.yml' , TRUE ) ; $ this -> updater -> deleteFile ( '.git/hooks' ) ; $ this -> updater -> getOutput ( ) -> writeln ( '.git/hooks was deleted. Please re-run blt:init:git-hooks to install git hooks locally.' ) ; $ this -> updater -> removeComposerRepository ( 'https://github.com/mortenson/composer-patches' ) ; $ this -> updater -> removeComposerScript ( 'post-create-project-cmd' ) ; $ project_config = $ this -> updater -> getProjectYml ( ) ; if ( ! empty ( $ project_config [ 'modules' ] [ 'deploy' ] ) ) { $ project_config [ 'modules' ] [ 'prod' ] = $ project_config [ 'modules' ] [ 'deploy' ] ; unset ( $ project_config [ 'modules' ] [ 'deploy' ] ) ; } $ this -> updater -> getOutput ( ) -> writeln ( "<comment>You MUST remove .travis.yml and re-initialize Travis CI support with `blt recipes:ci:travis:init`.</comment>" ) ; }
|
8 . 6 . 0 .
|
5,241
|
public function update_8006002 ( ) { $ composer_json = $ this -> updater -> getComposerJson ( ) ; $ composer_json = DoPackagistConverter :: convertComposerJson ( $ composer_json ) ; unset ( $ composer_json [ 'require' ] [ 'drupal-composer/drupal-security-advisories' ] ) ; $ this -> updater -> writeComposerJson ( $ composer_json ) ; }
|
8 . 6 . 2 .
|
5,242
|
public function update_8006004 ( ) { $ composer_json = $ this -> updater -> getComposerJson ( ) ; $ remove_packages = [ 'drupal/coder' , 'drupal-composer/drupal-security-advisories' , 'phing/phing' , 'phpunit/phpunit' , 'behat/mink-extension' , 'behat/mink-goutte-driver' , 'behat/mink-browserkit-driver' , ] ; foreach ( $ remove_packages as $ package ) { unset ( $ composer_json [ 'require' ] [ $ package ] ) ; unset ( $ composer_json [ 'require-dev' ] [ $ package ] ) ; } $ this -> updater -> writeComposerJson ( $ composer_json ) ; }
|
8 . 5 . 4 .
|
5,243
|
public function update_8006006 ( ) { $ composer_json = $ this -> updater -> getComposerJson ( ) ; unset ( $ composer_json [ 'require-dev' ] [ 'drush/drush' ] ) ; $ this -> updater -> writeComposerJson ( $ composer_json ) ; }
|
8 . 6 . 6 .
|
5,244
|
public function update_8006007 ( ) { $ composer_json = $ this -> updater -> getComposerJson ( ) ; if ( ! empty ( $ composer_json [ 'extra' ] [ 'drupal-scaffold' ] [ 'excludes' ] ) ) { $ composer_json [ 'extra' ] [ 'drupal-scaffold' ] [ 'excludes' ] = array_unique ( array_values ( $ composer_json [ 'extra' ] [ 'drupal-scaffold' ] [ 'excludes' ] ) ) ; } $ this -> updater -> writeComposerJson ( $ composer_json ) ; }
|
8 . 6 . 7 .
|
5,245
|
public function update_8009000 ( ) { $ project_yml = $ this -> updater -> getProjectYml ( ) ; if ( ! empty ( $ project_yml [ 'behat' ] [ 'launch-phantomjs' ] ) && $ project_yml [ 'behat' ] [ 'launch-phantomjs' ] ) { $ project_yml [ 'behat' ] [ 'web-driver' ] = 'phantomjs' ; } else { $ project_yml [ 'behat' ] [ 'web-driver' ] = 'selenium' ; } unset ( $ project_yml [ 'behat' ] [ 'launch-selenium' ] ) ; unset ( $ project_yml [ 'behat' ] [ 'launch-phantomjs' ] ) ; if ( ! empty ( $ project_yml [ 'multisite.name' ] ) ) { $ project_yml [ 'multisites' ] [ ] = $ project_yml [ 'multisite.name' ] ; unset ( $ project_yml [ 'multisite.name' ] ) ; } unset ( $ project_yml [ 'import' ] ) ; if ( file_exists ( $ this -> updater -> getRepoRoot ( ) . '/Vagrantfile' ) ) { $ project_yml [ 'vm' ] [ 'enable' ] = TRUE ; } $ this -> updater -> writeProjectYml ( $ project_yml ) ; $ messages = [ "You have updated to a new major version of BLT, which introduces backwards-incompatible changes." , "You may need to perform the following manual update steps:" , " - View the full list of commands via `blt list`, <comment>BLT commands have changed</comment>" , " - Re-initialize default Travis CI configuration via `blt recipes:ci:travis:init`. - Re-initialize default Acquia Pipelines configuration via `blt recipes:ci:pipelines:init`." , " - Port custom Phing commands to Robo. All Phing commands are now obsolete. See:" , " http://blt.readthedocs.io/en/9.x/readme/extending-blt/" , ] ; if ( file_exists ( $ this -> updater -> getRepoRoot ( ) . '/blt/composer.overrides.json' ) ) { $ messages [ ] = " - <comment>blt/composer.overrides.json</comment> is no longer necessary." ; $ messages [ ] = " - Move your overrides to your root composer.json, and set extra.merge-plugin.ignore-duplicates to true." ; } $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; }
|
8 . 9 . 0 .
|
5,246
|
public function update_8009001 ( ) { $ project_yml = $ this -> updater -> getProjectYml ( ) ; unset ( $ project_yml [ 'phpcs' ] [ 'filesets' ] [ 'files.php.custom.modules' ] ) ; unset ( $ project_yml [ 'phpcs' ] [ 'filesets' ] [ 'files.php.custom.themes' ] ) ; unset ( $ project_yml [ 'phpcs' ] [ 'filesets' ] [ 'files.php.tests' ] ) ; $ this -> updater -> writeProjectYml ( $ project_yml ) ; }
|
8 . 9 . 1 .
|
5,247
|
public function update_8009003 ( ) { $ composer_json = $ this -> updater -> getComposerJson ( ) ; $ composer_json [ 'extra' ] [ 'installer-types' ] [ ] = 'bower-asset' ; $ composer_json [ 'extra' ] [ 'installer-types' ] [ ] = 'npm-asset' ; $ composer_json [ 'extra' ] [ 'installer-paths' ] [ 'docroot/libraries/{$name}' ] [ ] = 'type:bower-asset' ; $ composer_json [ 'extra' ] [ 'installer-paths' ] [ 'docroot/libraries/{$name}' ] [ ] = 'type:npm-asset' ; if ( isset ( $ composer_json [ 'repositories' ] ) ) { $ repository_key = NULL ; foreach ( $ composer_json [ 'repositories' ] as $ key => $ repository ) { if ( $ repository [ 'type' ] == 'composer' && strpos ( $ repository [ 'url' ] , 'https://asset-packagist.org' ) === 0 ) { $ repository_key = $ key ; break ; } } if ( is_null ( $ repository_key ) ) { $ composer_json [ 'repositories' ] [ 'asset-packagist' ] = [ 'type' => 'composer' , 'url' => 'https://asset-packagist.org' , ] ; } } $ projectAcsfHooks = $ this -> updater -> getRepoRoot ( ) . '/factory-hooks' ; $ acsf_inited = file_exists ( $ projectAcsfHooks ) ; if ( $ acsf_inited ) { $ composer_json [ 'config' ] [ 'platform' ] [ 'php' ] = '5.6' ; } $ this -> updater -> writeComposerJson ( $ composer_json ) ; $ messages = [ "Your composer.json file has been modified to be compatible with Lightning 2.1.8+." , "You must execute `composer update` to update your lock file." , ] ; $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; }
|
8 . 9 . 3 .
|
5,248
|
public function update_8009007 ( ) { $ this -> updater -> deleteFile ( 'drush.wrapper' ) ; $ this -> updater -> deleteFile ( '.drush-use' ) ; $ messages = [ "You should replace your local global installation of drush with drush launcher:" , "https://github.com/drush-ops/drush-launcher" , ] ; $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; }
|
8 . 9 . 7 .
|
5,249
|
public function update_8009011 ( ) { $ project_yml = $ this -> updater -> getProjectYml ( ) ; if ( isset ( $ project_yml [ 'vm' ] [ 'enable' ] ) ) { $ project_local_yml = $ this -> updater -> getProjectLocalYml ( ) ; $ project_local_yml [ 'vm' ] [ 'enable' ] = $ project_yml [ 'vm' ] [ 'enable' ] ; $ this -> updater -> writeProjectLocalYml ( $ project_local_yml ) ; unset ( $ project_yml [ 'vm' ] ) ; $ this -> updater -> writeProjectYml ( $ project_yml ) ; } }
|
8 . 9 . 11 .
|
5,250
|
public function update_9001000 ( ) { $ this -> updater -> syncWithTemplate ( '.gitignore' , TRUE ) ; $ messages = [ '.gitignore has been updated. Review it for any custom changes that may have been overwritten.' ] ; $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> syncWithTemplate ( 'blt/ci.blt.yml' , TRUE ) ; $ messages = [ 'blt/ci.blt.yml has been updated. Review it for any custom changes that may have been overwritten.' ] ; $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ project_composer_json = $ this -> updater -> getRepoRoot ( ) . '/composer.json' ; $ template_composer_json = $ this -> updater -> getBltRoot ( ) . '/subtree-splits/blt-project/composer.json' ; $ munged_json = ComposerMunge :: mungeFiles ( $ project_composer_json , $ template_composer_json ) ; $ bytes = file_put_contents ( $ project_composer_json , $ munged_json ) ; if ( ! $ bytes ) { $ messages = [ "Could not update $project_composer_json." ] ; } else { $ messages = [ "Updated $project_composer_json. Review changes, then re-run composer update." ] ; } $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; }
|
9 . 1 . 0 - alpha1 .
|
5,251
|
public function update_9001001 ( ) { $ this -> updater -> syncWithTemplate ( '.gitignore' , TRUE ) ; $ composer_json = $ this -> updater -> getComposerJson ( ) ; if ( isset ( $ composer_json [ 'extra' ] [ 'installer-paths' ] [ 'drush/contrib/{$name}' ] ) ) { unset ( $ composer_json [ 'extra' ] [ 'installer-paths' ] [ 'drush/contrib/{$name}' ] ) ; } $ composer_json [ 'extra' ] [ 'installer-paths' ] [ 'drush/Commands/{$name}' ] [ ] = 'type:drupal-drush' ; $ this -> updater -> writeComposerJson ( $ composer_json ) ; $ messages = [ "Your composer.json file has been modified to be compatible with Drush 9." , "You must execute `composer update --lock` to update your lock file." , ] ; $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; }
|
9 . 1 . 0 .
|
5,252
|
public function update_9002000 ( ) { if ( file_exists ( $ this -> updater -> getRepoRoot ( ) . '/factory-hooks' ) ) { $ messages = [ "This update will update the files in your existing factory hooks directory." , "Review the resulting files and ensure that any customizations have been re-added." , ] ; $ this -> updater -> executeCommand ( "./vendor/bin/blt recipes:acsf:init:hooks" ) ; $ formattedBlock = $ this -> updater -> getFormatter ( ) -> formatBlock ( $ messages , 'ice' ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; $ this -> updater -> getOutput ( ) -> writeln ( $ formattedBlock ) ; $ this -> updater -> getOutput ( ) -> writeln ( "" ) ; } }
|
9 . 2 . 0 .
|
5,253
|
public function lintFileSets ( ) { $ this -> say ( "Validating yaml syntax for all custom modules and exported config..." ) ; $ fileset_manager = $ this -> getContainer ( ) -> get ( 'filesetManager' ) ; $ fileset_ids = $ this -> getConfigValue ( 'validate.yaml.filesets' ) ; $ filesets = $ fileset_manager -> getFilesets ( $ fileset_ids , TRUE ) ; $ bin = $ this -> getConfigValue ( 'composer.bin' ) ; $ command = "'$bin/yaml-cli' lint '%s'" ; $ this -> executeCommandAgainstFilesets ( $ filesets , $ command , TRUE ) ; }
|
Executes YAML validator against all validate . yaml . filesets files .
|
5,254
|
public function lintFileList ( $ file_list ) { $ this -> say ( "Linting YAML files..." ) ; $ files = explode ( "\n" , $ file_list ) ; $ fileset_manager = $ this -> getContainer ( ) -> get ( 'filesetManager' ) ; $ fileset_ids = $ this -> getConfigValue ( 'validate.yaml.filesets' ) ; $ filesets = $ fileset_manager -> getFilesets ( $ fileset_ids ) ; $ bin = $ this -> getConfigValue ( 'composer.bin' ) ; $ command = "'$bin/yaml-cli' lint '%s'" ; foreach ( $ filesets as $ fileset_id => $ fileset ) { $ filesets [ $ fileset_id ] = $ fileset_manager -> filterFilesByFileset ( $ files , $ fileset ) ; } $ this -> executeCommandAgainstFilesets ( $ filesets , $ command ) ; }
|
Executes YAML validator against files if in validate . yaml . filesets .
|
5,255
|
public function initializeSimpleSamlPhp ( ) { $ this -> requireModule ( ) ; $ this -> initializeConfig ( ) ; $ this -> setSimpleSamlPhpInstalled ( ) ; $ this -> symlinkDocrootToLibDir ( ) ; $ this -> addHtaccessPatch ( ) ; $ this -> outputCompleteSetupInstructions ( ) ; }
|
Initializes SimpleSAMLphp for project .
|
5,256
|
protected function initializeConfig ( ) { $ destinationDirectory = "{$this->repoRoot}/simplesamlphp/config" ; $ this -> say ( "Copying config files to ${destinationDirectory}..." ) ; $ result = $ this -> taskFileSystemStack ( ) -> copy ( "{$this->repoRoot}/vendor/simplesamlphp/simplesamlphp/config-templates/authsources.php" , "${destinationDirectory}/authsources.php" , TRUE ) -> copy ( "{$this->repoRoot}/vendor/simplesamlphp/simplesamlphp/config-templates/config.php" , "${destinationDirectory}/config.php" , TRUE ) -> copy ( "{$this->bltRoot}/scripts/simplesamlphp/acquia_config.php" , "${destinationDirectory}/acquia_config.php" , TRUE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to copy SimpleSamlPhp config files." ) ; } $ config_file = "{$this->repoRoot}/simplesamlphp/config/config.php" ; $ result = $ this -> taskWriteToFile ( $ config_file ) -> text ( "include 'acquia_config.php';" ) -> append ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable modify $config_file." ) ; } $ this -> say ( "Copying config files to {$this->repoRoot}/simplesamlphp/metadata..." ) ; $ result = $ this -> taskFileSystemStack ( ) -> copy ( "{$this->repoRoot}/vendor/simplesamlphp/simplesamlphp/metadata-templates/saml20-idp-remote.php" , "{$this->repoRoot}/simplesamlphp/metadata/saml20-idp-remote.php" , TRUE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to initialize SimpleSamlPhp configuration." ) ; } }
|
Copies configuration templates from SimpleSamlPHP to the repo root .
|
5,257
|
protected function setSimpleSamlPhpInstalled ( ) { $ project_yml = $ this -> getConfigValue ( 'blt.config-files.project' ) ; $ this -> say ( "Updating ${project_yml}..." ) ; $ project_config = YamlMunge :: parseFile ( $ project_yml ) ; $ project_config [ 'simplesamlphp' ] = TRUE ; try { YamlMunge :: writeFile ( $ project_yml , $ project_config ) ; } catch ( \ Exception $ e ) { throw new BltException ( "Unable to update $project_yml." ) ; } }
|
Sets value in blt . yml to let targets know simplesamlphp is installed .
|
5,258
|
protected function symlinkDocrootToLibDir ( ) { $ docroot = $ this -> getConfigValue ( 'docroot' ) ; $ this -> say ( "Creating a symbolic link from ${docroot}/simplesaml to web accessible directory in the simplesamlphp library..." ) ; $ result = $ this -> taskFileSystemStack ( ) -> symlink ( "../vendor/simplesamlphp/simplesamlphp/www" , "${docroot}/simplesaml" ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable create symlink." ) ; } }
|
Creates a symlink from the docroot to the web accessible library dir .
|
5,259
|
public function simpleSamlPhpBuildConfig ( ) { $ this -> say ( 'Copying config files to the appropriate place in simplesamlphp library...' ) ; $ result = $ this -> taskCopyDir ( [ "{$this->repoRoot}/simplesamlphp" => "{$this->repoRoot}/vendor/simplesamlphp/simplesamlphp" ] ) -> overwrite ( TRUE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to copy configuration into SimpleSamlPhp." ) ; } $ result = $ this -> taskFileSystemStack ( ) -> copy ( "{$this->bltRoot}/scripts/simplesamlphp/gitignore.txt" , "{$this->repoRoot}/vendor/simplesamlphp/simplesamlphp/.gitignore" , TRUE ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to copy .gitignore into SimpleSamlPhp." ) ; } }
|
Copies customized config files into vendored SimpleSamlPHP .
|
5,260
|
protected function outputCompleteSetupInstructions ( ) { $ instructions = [ 'To complete the setup you must manually modify several files:' , '' , "* {$this->repoRoot}/simplesamlphp/config/acquia_config.php" , "* {$this->repoRoot}/simplesamlphp/config/authsources.php" , "* {$this->repoRoot}/simplesamlphp/metadata/saml20-idp-remote.php" , '' , 'After editing these files execute the following command to copy the modified files to the correct location in the SimpleSAMLphp library:' , '' , "'blt source:build:simplesamlphp-config'" , '' , "See http://blt.readthedocs.io/en/latest/readme/simplesamlphp-setup/ for details on how to modify the files." , ] ; $ formattedBlock = $ this -> formatter -> formatBlock ( $ instructions , 'comment' , TRUE ) ; $ this -> writeln ( $ formattedBlock ) ; }
|
Outputs a message to edit the new config files .
|
5,261
|
protected function addHtaccessPatch ( ) { $ this -> taskFilesystemStack ( ) -> copy ( $ this -> bltRoot . "/scripts/simplesamlphp/htaccess-saml.patch" , $ this -> repoRoot . "/patches/htaccess-saml.patch" ) -> run ( ) ; $ composer_json = json_decode ( file_get_contents ( $ this -> getConfigValue ( 'repo.root' ) . '/composer.json' ) ) ; $ composer_json -> scripts -> { "post-drupal-scaffold-cmd" } [ ] = "cd docroot && patch -p1 <../patches/htaccess-saml.patch" ; file_put_contents ( $ this -> getConfigValue ( 'repo.root' ) . '/composer.json' , json_encode ( $ composer_json , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ) ; $ this -> taskExecStack ( ) -> dir ( $ this -> getConfigValue ( 'repo.roou' ) ) -> exec ( "composer post-drupal-scaffold-cmd" ) -> run ( ) ; }
|
Add a patch to . htaccess .
|
5,262
|
protected function invokeCommands ( array $ commands ) { foreach ( $ commands as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ command = $ value ; $ args = [ ] ; } else { $ command = $ key ; $ args = $ value ; } $ this -> invokeCommand ( $ command , $ args ) ; } }
|
Invokes an array of Symfony commands .
|
5,263
|
protected function invokeCommand ( $ command_name , array $ args = [ ] ) { $ this -> invokeDepth ++ ; if ( ! $ this -> isCommandDisabled ( $ command_name ) ) { $ application = $ this -> getContainer ( ) -> get ( 'application' ) ; $ command = $ application -> find ( $ command_name ) ; $ input = new ArrayInput ( $ args ) ; $ input -> setInteractive ( $ this -> input ( ) -> isInteractive ( ) ) ; $ prefix = str_repeat ( ">" , $ this -> invokeDepth ) ; $ this -> output -> writeln ( "<comment>$prefix $command_name</comment>" ) ; $ exit_code = $ application -> runCommand ( $ command , $ input , $ this -> output ( ) ) ; $ this -> invokeDepth -- ; if ( $ exit_code ) { throw new BltException ( "Command `$command_name {$input->__toString()}` exited with code $exit_code." ) ; } } }
|
Invokes a single Symfony command .
|
5,264
|
protected function getDisabledCommands ( ) { $ disabled_commands_config = $ this -> getConfigValue ( 'disable-targets' ) ; if ( $ disabled_commands_config ) { $ disabled_commands = ArrayManipulator :: flattenMultidimensionalArray ( $ disabled_commands_config , ':' ) ; return $ disabled_commands ; } return [ ] ; }
|
Gets an array of commands that have been configured to be disabled .
|
5,265
|
protected function isCommandDisabled ( $ command ) { $ disabled_commands = $ this -> getDisabledCommands ( ) ; if ( is_array ( $ disabled_commands ) && array_key_exists ( $ command , $ disabled_commands ) && $ disabled_commands [ $ command ] ) { $ this -> logger -> warning ( "The $command command is disabled." ) ; return TRUE ; } return FALSE ; }
|
Determines if a command has been disabled via disable - targets .
|
5,266
|
protected function invokeHook ( $ hook ) { if ( $ this -> getConfig ( ) -> has ( "command-hooks.$hook.command" ) && $ this -> getConfigValue ( "command-hooks.$hook.command" ) ) { $ this -> say ( "Executing $hook target hook..." ) ; $ result = $ this -> taskExecStack ( ) -> exec ( $ this -> getConfigValue ( "command-hooks.$hook.command" ) ) -> dir ( $ this -> getConfigValue ( "command-hooks.$hook.dir" ) ) -> interactive ( $ this -> input ( ) -> isInteractive ( ) ) -> printOutput ( TRUE ) -> printMetadata ( TRUE ) -> stopOnFail ( ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Executing target-hook $hook failed." ) ; } } else { $ this -> logger -> info ( "Skipped $hook target hook. No hook is defined." ) ; return 0 ; } }
|
Invokes a given command - hooks hook typically defined in blt . yml .
|
5,267
|
protected function installVagrantPlugin ( $ plugin ) { if ( ! $ this -> getInspector ( ) -> isVagrantPluginInstalled ( $ plugin ) ) { $ this -> logger -> warning ( "The $plugin plugin is not installed! Attempting to install it..." ) ; $ this -> taskExec ( "vagrant plugin install $plugin" ) -> run ( ) ; } }
|
Installs a vagrant plugin if it is not already installed .
|
5,268
|
protected function executeCommandAgainstFilesets ( array $ filesets , $ command , $ parallel = FALSE ) { $ passed = TRUE ; $ failed_filesets = [ ] ; foreach ( $ filesets as $ fileset_id => $ fileset ) { if ( ! is_null ( $ fileset ) && iterator_count ( $ fileset ) ) { $ this -> say ( "Iterating over fileset $fileset_id..." ) ; $ files = iterator_to_array ( $ fileset ) ; $ result = $ this -> executeCommandAgainstFiles ( $ files , $ command , $ parallel ) ; if ( ! $ result -> wasSuccessful ( ) ) { $ passed = FALSE ; $ failed_filesets [ ] = $ fileset_id ; } } else { $ this -> logger -> info ( "No files were found in fileset $fileset_id. Skipped." ) ; } } if ( ! $ passed ) { throw new BltException ( "Executing `$command` against fileset(s) " . implode ( ', ' , $ failed_filesets ) . " returned a non-zero exit code.`" ) ; } }
|
Executes a given command against multiple filesets .
|
5,269
|
protected function executeCommandAgainstFiles ( $ files , $ command , $ parallel = FALSE ) { if ( $ parallel ) { return $ this -> executeCommandAgainstFilesInParallel ( $ files , $ command ) ; } else { return $ this -> executeCommandAgainstFilesProcedurally ( $ files , $ command ) ; } }
|
Executes a given command against an array of files .
|
5,270
|
public function switchSiteContext ( $ site_name ) { $ this -> logger -> debug ( "Switching site context to <comment>$site_name</comment>." ) ; $ config_initializer = new ConfigInitializer ( $ this -> getConfigValue ( 'repo.root' ) , $ this -> input ( ) ) ; $ config_initializer -> setSite ( $ site_name ) ; $ new_config = $ config_initializer -> initialize ( ) ; $ this -> getConfig ( ) -> import ( $ new_config -> export ( ) ) ; }
|
Sets multisite context by settings site - specific config values .
|
5,271
|
public function generateConfigSplits ( ) { $ this -> say ( "This command will generate configuration and directories for the following environment based splits: Local, CI, Dev, Stage, and Prod." ) ; $ default_splits = [ 'Local' , 'CI' , 'Dev' , 'Stage' , 'Prod' ] ; foreach ( $ default_splits as $ split ) { $ this -> createSplitConfig ( $ split ) ; } }
|
Generates empty config_split splits for the selected environments .
|
5,272
|
protected function createSplitConfig ( $ name ) { $ id = strtolower ( $ name ) ; $ split_config_file = $ this -> configSyncDir . "/config_split.config_split.{$id}.yml" ; if ( file_exists ( $ split_config_file ) ) { $ this -> say ( "The config_split file for $name already exists. Skipping." ) ; } else { $ uuid = $ this -> uuidGenerator -> generate ( ) ; $ config = $ this -> twig -> render ( 'config_split.config_split.env.yml.twig' , [ 'uuid' => $ uuid , 'name' => $ name , 'id' => $ id , ] ) ; $ this -> createSplitDir ( $ name ) ; $ this -> writeSplitConfig ( $ split_config_file , $ config ) ; } }
|
Create a config_split configuration and directory for the given split .
|
5,273
|
protected function createSplitDir ( $ split ) { $ split_dir = $ this -> configSplitDir . '/' . strtolower ( $ split ) ; $ result = $ this -> taskFilesystemStack ( ) -> mkdir ( $ split_dir ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to create $split_dir." ) ; } if ( ! file_exists ( $ split_dir . '/README.md' ) ) { $ readme = $ this -> twig -> render ( 'README.md.twig' , [ 'name' => $ split , ] ) ; file_put_contents ( $ split_dir . '/README.md' , $ readme ) ; } }
|
Creates the config directory for the given config_split .
|
5,274
|
protected function writeSplitConfig ( $ file_path , $ config ) { $ result = $ this -> taskWriteToFile ( $ file_path ) -> text ( $ config ) -> run ( ) ; if ( ! $ result ) { throw new BltException ( "Unable to write $file_path." ) ; } }
|
Write the config_split configuration YAML file in the given directory .
|
5,275
|
public function populateHelperConfig ( ) { $ this -> set ( 'drush.alias' , $ this -> get ( 'drush.default_alias' ) ) ; if ( ! $ this -> get ( 'multisites' ) ) { $ this -> set ( 'multisites' , $ this -> getSiteDirs ( ) ) ; } $ multisites = $ this -> get ( 'multisites' ) ; $ first_multisite = reset ( $ multisites ) ; $ site = $ this -> get ( 'site' , $ first_multisite ) ; $ this -> setSite ( $ site ) ; }
|
Populates configuration settings not available during construction .
|
5,276
|
protected function getSiteDirs ( ) { $ sites_dir = $ this -> get ( 'docroot' ) . '/sites' ; $ sites = [ ] ; if ( ! file_exists ( $ sites_dir ) ) { return $ sites ; } $ finder = new Finder ( ) ; $ dirs = $ finder -> in ( $ sites_dir ) -> directories ( ) -> depth ( '< 1' ) -> exclude ( [ 'g' , 'settings' ] ) -> sortByName ( ) ; foreach ( $ dirs -> getIterator ( ) as $ dir ) { $ sites [ ] = $ dir -> getRelativePathname ( ) ; } return $ sites ; }
|
Gets an array of sites for the Drupal application .
|
5,277
|
public function init ( ) { $ result = $ this -> taskFilesystemStack ( ) -> copy ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/blt/examples/Commands/ExampleCommands.php' , $ this -> getConfigValue ( 'repo.root' ) . '/blt/src/Blt/Plugin/Commands/ExampleCommands.php' , FALSE ) -> copy ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/blt/examples/Test/ExampleTest.php' , $ this -> getConfigValue ( 'repo.root' ) . '/tests/phpunit/ExampleTest.php' , FALSE ) -> copy ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/blt/examples/Test/Examples.feature' , $ this -> getConfigValue ( 'repo.root' ) . '/tests/behat/features/Examples.feature' , FALSE ) -> copy ( $ this -> getConfigValue ( 'blt.root' ) . '/scripts/blt/examples/Filesets.php' , $ this -> getConfigValue ( 'repo.root' ) . '/blt/src/Filesets.php' , FALSE ) -> stopOnFail ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Could not copy example files into the repository root." ) ; } $ this -> say ( "<info>Example commands and hooks were copied to your repository root.</info>" ) ; }
|
Generates example files for writing custom commands and hooks .
|
5,278
|
protected function checkSimpleSamlPhp ( ) { if ( $ this -> getConfig ( ) -> has ( 'simplesamlphp' ) ) { $ lib_root = $ this -> getConfigValue ( 'repo.root' ) . '/vendor/simplesamlphp/simplesamlphp' ; $ config_root = $ this -> getConfigValue ( 'repo.root' ) . '/simplesamlphp' ; if ( ! file_exists ( $ config_root ) ) { $ this -> logProblem ( __FUNCTION__ , [ "Simplesamlphp config directory is missing. $config_root" , "" , "Run `blt simplesamlphp:config:init` to create a config directory." , ] , 'error' ) ; } if ( ! file_exists ( $ lib_root ) ) { $ this -> logProblem ( __FUNCTION__ , [ "The SimpleSAMLphp library was not found in the vendor directory." , " Run `blt simplesamlphp:config:init` to add the library as a dependency." , ] , 'error' ) ; } if ( file_exists ( $ lib_root ) && file_exists ( $ config_root ) ) { $ config_files = [ '/config/config.php' , '/config/authsources.php' , '/metadata/saml20-idp-remote.php' , ] ; foreach ( $ config_files as $ config_file ) { if ( file_exists ( $ lib_root . $ config_file ) && file_exists ( $ config_root . $ config_file ) ) { $ config_file_content = file_get_contents ( $ config_root . $ config_file ) ; $ lib_file_content = file_get_contents ( $ lib_root . $ config_file ) ; if ( strcmp ( $ config_file_content , $ lib_file_content ) !== 0 ) { $ this -> logProblem ( __FUNCTION__ , [ "The configuration file: $config_file in $config_root does not match the one in $lib_root." , " Run `blt source:build:simplesamlphp-config` to copy the files from the repo root to the library." , ] , 'error' ) ; } } else { $ lib_file_path = $ lib_root . $ config_file ; $ this -> logProblem ( __FUNCTION__ , [ "$lib_file_path is missing. Run `blt source:build:simplesamlphp-config`." , ] , 'error' ) ; } } } if ( ! file_exists ( $ this -> getConfigValue ( 'docroot' ) . '/simplesaml' ) ) { $ this -> logProblem ( __FUNCTION__ , [ "The symlink to the SimpleSAMLphp library is missing from your docroot." , " Run `blt recipes:simplesamlphp:init`" , ] , 'error' ) ; } $ htaccess = file_get_contents ( $ this -> getConfigValue ( 'docroot' ) . '/.htaccess' ) ; if ( ! strstr ( $ htaccess , 'simplesaml' ) ) { $ this -> logProblem ( __FUNCTION__ , [ "Access to {$this->getConfigValue('docroot')}/simplesaml is blocked by .htaccess" , " Add the snippet in simplesamlphp-setup.md readme to your .htaccess file." , ] , 'error' ) ; } } }
|
Performs a high level check of SimpleSAMLphp installation .
|
5,279
|
public function generateAliasesAcquia ( ) { $ this -> cloudConfDir = $ _SERVER [ 'HOME' ] . '/.acquia' ; $ this -> setAppId ( ) ; $ this -> cloudConfFileName = 'cloud_api.conf' ; $ this -> cloudConfFilePath = $ this -> cloudConfDir . '/' . $ this -> cloudConfFileName ; $ this -> siteAliasDir = $ this -> getConfigValue ( 'drush.alias-dir' ) ; $ cloudApiConfig = $ this -> loadCloudApiConfig ( ) ; $ this -> setCloudApiClient ( $ cloudApiConfig [ 'key' ] , $ cloudApiConfig [ 'secret' ] ) ; $ this -> say ( "<info>Gathering site info from Acquia Cloud.</info>" ) ; $ site = $ this -> cloudApiClient -> application ( $ this -> appId ) ; $ error = FALSE ; try { $ this -> getSiteAliases ( $ site ) ; } catch ( \ Exception $ e ) { $ error = TRUE ; $ this -> logger -> error ( "Did not write aliases for $site->name. Error: " . $ e -> getMessage ( ) ) ; } if ( ! $ error ) { $ this -> say ( "<info>Aliases were written, type 'drush sa' to see them.</info>" ) ; } }
|
Generates new Acquia site aliases for Drush .
|
5,280
|
protected function setAppId ( ) { if ( $ app_id = $ this -> getConfigValue ( 'cloud.appId' ) ) { $ this -> appId = $ app_id ; } else { $ this -> say ( "<info>To generate an alias for the Acquia Cloud, BLT require's your Acquia Cloud application ID.</info>" ) ; $ this -> say ( "<info>See https://docs.acquia.com/acquia-cloud/manage/applications.</info>" ) ; $ this -> appId = $ this -> askRequired ( 'Please enter your Acquia Cloud application ID' ) ; $ this -> writeAppConfig ( $ this -> appId ) ; } }
|
Sets the Acquia application ID from config and prompt .
|
5,281
|
protected function writeAppConfig ( $ app_id ) { $ project_yml = $ this -> getConfigValue ( 'blt.config-files.project' ) ; $ this -> say ( "Updating ${project_yml}..." ) ; $ project_config = YamlMunge :: parseFile ( $ project_yml ) ; $ project_config [ 'cloud' ] [ 'appId' ] = $ app_id ; try { YamlMunge :: writeFile ( $ project_yml , $ project_config ) ; } catch ( \ Exception $ e ) { throw new BltException ( "Unable to update $project_yml." ) ; } }
|
Sets appId value in blt . yml to disable interative prompt .
|
5,282
|
protected function askForCloudApiCredentials ( ) { $ this -> say ( "You may generate new API tokens at <comment>https://cloud.acquia.com/app/profile/tokens</comment>" ) ; $ key = $ this -> askRequired ( 'Please enter your Acquia cloud API key:' ) ; $ secret = $ this -> askRequired ( 'Please enter your Acquia cloud API secret:' ) ; do { $ this -> setCloudApiClient ( $ key , $ secret ) ; $ cloud_api_client = $ this -> getCloudApiClient ( ) ; } while ( ! $ cloud_api_client ) ; $ config = array ( 'key' => $ key , 'secret' => $ secret , ) ; $ this -> writeCloudApiConfig ( $ config ) ; return $ config ; }
|
Interactive prompt to get Cloud API credentials .
|
5,283
|
protected function writeCloudApiConfig ( array $ config ) { if ( ! is_dir ( $ this -> cloudConfDir ) ) { mkdir ( $ this -> cloudConfDir ) ; } file_put_contents ( $ this -> cloudConfFilePath , json_encode ( $ config ) ) ; $ this -> say ( "Credentials were written to {$this->cloudConfFilePath}." ) ; }
|
Writes configuration to local file .
|
5,284
|
protected function setCloudApiClient ( $ key , $ secret ) { try { $ connector = new Connector ( array ( 'key' => $ key , 'secret' => $ secret , ) ) ; $ cloud_api = Client :: factory ( $ connector ) ; $ cloud_api -> applications ( ) ; $ this -> cloudApiClient = $ cloud_api ; return $ cloud_api ; } catch ( \ Exception $ e ) { $ this -> logger -> error ( 'Failed to authenticate with Acquia Cloud API.' ) ; $ this -> logger -> error ( 'Exception was thrown: ' . $ e -> getMessage ( ) ) ; return NULL ; } }
|
Tests CloudAPI client authentication credentials .
|
5,285
|
protected function getAliases ( $ uri , $ envName , $ remoteHost , $ remoteUser , $ siteID ) { $ alias = array ( ) ; $ skip_site = FALSE ; if ( strpos ( $ uri , ':*' ) !== FALSE ) { $ skip_site = TRUE ; } if ( ! $ skip_site ) { $ docroot = '/var/www/html/' . $ remoteUser . '/docroot' ; $ alias [ $ envName ] [ 'uri' ] = $ uri ; $ alias [ $ envName ] [ 'host' ] = $ remoteHost ; $ alias [ $ envName ] [ 'options' ] = [ ] ; $ alias [ $ envName ] [ 'paths' ] = [ 'dump-dir' => '/mnt/tmp' ] ; $ alias [ $ envName ] [ 'root' ] = $ docroot ; $ alias [ $ envName ] [ 'user' ] = $ remoteUser ; $ alias [ $ envName ] [ 'ssh' ] = [ 'options' => '-p 22' ] ; return $ alias ; } }
|
Generates a site alias for valid domains .
|
5,286
|
protected function getSitesJson ( $ sshFull , $ remoteUser ) { $ this -> say ( 'Getting ACSF sites.json information...' ) ; $ result = $ this -> taskRsync ( ) -> fromPath ( '/mnt/files/' . $ remoteUser . '/files-private/sites.json' ) -> fromHost ( $ sshFull ) -> toPath ( $ this -> cloudConfDir ) -> remoteShell ( 'ssh -A -p 22' ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new \ Exception ( "Unable to rsync ACSF sites.json" ) ; } $ fullPath = $ this -> cloudConfDir . '/sites.json' ; $ response_body = file_get_contents ( $ fullPath ) ; $ sites_json = json_decode ( $ response_body , TRUE ) ; return $ sites_json ; }
|
Gets ACSF sites info without secondary API calls or Drupal bootstrap .
|
5,287
|
protected function writeSiteAliases ( $ site_id , array $ aliases ) { if ( ! is_dir ( $ this -> siteAliasDir ) ) { mkdir ( $ this -> siteAliasDir ) ; } $ filePath = $ this -> siteAliasDir . '/' . $ site_id . '.site.yml' ; if ( file_exists ( $ filePath ) ) { if ( ! $ this -> confirm ( "File $filePath already exists and will be overwritten. Continue?" ) ) { throw new \ Exception ( "Aborted at user request" ) ; } } file_put_contents ( $ filePath , Yaml :: dump ( $ aliases ) ) ; return $ filePath ; }
|
Writes site aliases to disk .
|
5,288
|
public function copy ( ) { $ destination = $ this -> getConfigValue ( 'repo.root' ) . '/hooks' ; $ this -> say ( "Copying default Acquia cloud hooks into $destination..." ) ; $ result = $ this -> taskCopyDir ( [ $ this -> getConfigValue ( 'blt.root' ) . '/scripts/cloud-hooks/hooks' => $ destination , ] ) -> run ( ) ; $ this -> taskFilesystemStack ( ) -> chmod ( $ destination , 0755 , 0000 , TRUE ) -> run ( ) ; return $ result ; }
|
Installs Acquia cloud hooks .
|
5,289
|
protected function checkDrupalVm ( ) { $ drupal_vm_config_file = $ this -> getConfigValue ( 'vm.config' ) ; if ( ! file_exists ( $ drupal_vm_config_file ) ) { $ this -> logProblem ( __FUNCTION__ . ':init' , "You have DrupalVM initialized, but $drupal_vm_config_file is missing." , 'error' ) ; return FALSE ; } $ drupal_vm_config = Yaml :: parse ( file_get_contents ( $ drupal_vm_config_file ) ) ; $ result = $ this -> getExecutor ( ) -> drush ( 'site:alias --format=json' ) -> silent ( TRUE ) -> run ( ) ; $ drush_aliases = json_decode ( $ result -> getMessage ( ) , TRUE ) ; $ local_alias_id = '@' . $ this -> getConfigValue ( 'drush.aliases.local' ) ; if ( $ local_alias_id !== '@self' ) { if ( empty ( $ drush_aliases [ $ local_alias_id ] ) ) { $ this -> logProblem ( __FUNCTION__ . ":alias" , [ "The drush alias assigned to drush.aliases.local does not exist in your drush aliases file." , " drush.aliases.local is set to @$local_alias_id" , ] , 'error' ) ; } else { $ local_alias = $ drush_aliases [ $ local_alias_id ] ; $ this -> checkHost ( $ local_alias , $ drupal_vm_config , $ local_alias_id ) ; $ this -> checkUri ( $ local_alias , $ drupal_vm_config , $ local_alias_id ) ; $ this -> checkRoot ( $ drupal_vm_config , $ local_alias , $ local_alias_id ) ; } } }
|
Checks Drupal VM configuration .
|
5,290
|
public function createFromSymlink ( $ options = [ 'project-dir' => self :: BLT_PROJECT_DIR , 'vm' => TRUE , ] ) { $ test_project_dir = $ this -> bltRoot . "/" . $ options [ 'project-dir' ] ; $ bin = $ test_project_dir . "/vendor/bin" ; $ this -> prepareTestProjectDir ( $ test_project_dir ) ; $ this -> taskFilesystemStack ( ) -> mkdir ( $ test_project_dir ) -> copy ( $ this -> bltRoot . '/subtree-splits/blt-project/composer.json' , $ test_project_dir . '/composer.json' ) -> run ( ) ; $ template_composer_json_filepath = $ test_project_dir . '/composer.json' ; $ template_composer_json = json_decode ( file_get_contents ( $ template_composer_json_filepath ) ) ; $ template_composer_json -> repositories -> blt = [ 'type' => 'path' , 'url' => '../blt' , 'options' => [ 'symlink' => TRUE , ] , ] ; $ template_composer_json -> require -> { 'acquia/blt' } = '*@dev' ; file_put_contents ( $ template_composer_json_filepath , json_encode ( $ template_composer_json , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ) ; $ this -> taskExecStack ( ) -> dir ( $ test_project_dir ) -> exec ( "git init" ) -> exec ( "git add -A" ) -> exec ( "git commit -m \"Initial commit.\"" ) -> run ( ) ; if ( ! $ options [ 'vm' ] ) { $ this -> taskReplaceInFile ( $ test_project_dir . "/composer.json" ) -> from ( "../blt" ) -> to ( $ this -> bltRoot ) -> run ( ) ; } $ task = $ this -> taskExecStack ( ) -> dir ( $ test_project_dir ) -> exec ( "composer install" ) ; if ( $ options [ 'vm' ] ) { $ task -> exec ( "$bin/blt vm --no-boot --no-interaction -v" ) -> exec ( "$bin/yaml-cli update:value box/config.yml vagrant_synced_folders.1.local_path '../blt'" ) -> exec ( "$bin/yaml-cli update:value box/config.yml vagrant_synced_folders.1.destination '/var/www/blt'" ) -> exec ( "$bin/yaml-cli update:value box/config.yml vagrant_synced_folders.1.type nfs" ) ; } $ task -> run ( ) ; }
|
Create a new project via symlink from current checkout of BLT .
|
5,291
|
public function bltRelease ( $ tag , $ github_token , $ options = [ 'prev-tag' => NULL , ] ) { $ this -> stopOnFail ( ) ; $ current_branch = $ this -> getCurrentBranch ( ) ; $ this -> checkDirty ( ) ; $ this -> printReleasePreamble ( $ tag , $ current_branch ) ; $ this -> assertBranchMatchesUpstream ( $ current_branch ) ; $ this -> resetLocalBranch ( $ current_branch ) ; $ this -> updateBltVersionConstant ( $ tag ) ; $ prev_tag = $ this -> getPrevTag ( $ options , $ current_branch ) ; $ release_notes = $ this -> generateReleaseNotes ( $ prev_tag , $ tag , $ github_token ) ; $ this -> updateChangelog ( $ tag , $ release_notes ) ; $ this -> _exec ( "git add CHANGELOG.md $this->bltRoot/src/Robo/Blt.php" ) ; $ this -> _exec ( "git commit -m 'Updating CHANGELOG.md and setting version for $tag.' -n" ) ; $ this -> _exec ( "git push upstream $current_branch" ) ; $ this -> createGitHubRelease ( $ current_branch , $ tag , $ release_notes , $ github_token ) ; return 0 ; }
|
Generates release notes and cuts a new tag on GitHub .
|
5,292
|
public function releaseNotes ( $ tag , $ github_token , $ options = [ 'prev-tag' => NULL , ] ) { $ current_branch = $ this -> getCurrentBranch ( ) ; $ prev_tag = $ this -> getPrevTag ( $ options , $ current_branch ) ; $ changes = $ this -> generateReleaseNotes ( $ tag , $ prev_tag , $ github_token ) ; $ this -> updateChangelog ( $ tag , $ changes ) ; }
|
Update CHANGELOG . md with notes for new release .
|
5,293
|
public function fixCode ( ) { $ command = "'{$this->bin}/phpcbf'" ; $ task = $ this -> taskExecStack ( ) -> dir ( $ this -> bltRoot ) -> exec ( $ command ) ; $ result = $ task -> run ( ) ; return $ result -> getExitCode ( ) ; }
|
Fixes BLT internal code via PHPCBF .
|
5,294
|
public function sniffCode ( ) { $ task = $ this -> taskExecStack ( ) -> dir ( $ this -> bltRoot ) -> exec ( "{$this->bin}/phpcs" ) -> exec ( "composer validate" ) ; $ result = $ task -> run ( ) ; return $ result -> getExitCode ( ) ; }
|
Sniffs BLT internal code via PHPCS .
|
5,295
|
protected function updateBltVersionConstant ( $ tag ) { $ this -> taskReplaceInFile ( $ this -> bltRoot . '/src/Robo/Blt.php' ) -> regex ( '/(const VERSION = \')[0-9]{1,2}\.[0-9x]{1,2}(\.[0-9x](-(alpha|beta|rc|dev)[0-9]{0,2})?|-dev?)(\';)/' ) -> to ( '${1}' . $ tag . '${5}' ) -> run ( ) ; }
|
Updates the version constant in Blt . php .
|
5,296
|
protected function sortChanges ( $ log_entries , $ github_token ) { $ client = new Client ( ) ; $ client -> authenticate ( $ github_token , NULL , Client :: AUTH_URL_TOKEN ) ; $ issue_api = $ client -> api ( 'issue' ) ; $ changes = [ 'breaking' => [ ] , 'enhancements' => [ ] , 'bugs' => [ ] , 'misc' => [ ] , ] ; foreach ( $ log_entries as $ log_entry ) { $ changes = $ this -> sortLogEntry ( $ log_entry , $ issue_api , $ changes ) ; } return $ changes ; }
|
Sorts an array of log changes based on GitHub issue labels .
|
5,297
|
protected function sortLogEntry ( $ log_entry , $ issue_api , $ changes ) { $ sorted = FALSE ; $ github_issue_number = $ this -> parseGitHubIssueNumber ( $ log_entry ) ; if ( $ github_issue_number ) { $ labels = $ this -> getGitHubIssueLabels ( $ issue_api , $ github_issue_number ) ; if ( $ labels ) { foreach ( $ labels as $ label ) { if ( strtolower ( $ label [ 'name' ] ) == 'change record' ) { $ changes [ 'breaking' ] [ ] = $ log_entry ; $ sorted = TRUE ; break ; } elseif ( strtolower ( $ label [ 'name' ] ) == 'enhancement' ) { $ changes [ 'enhancements' ] [ ] = $ log_entry ; $ sorted = TRUE ; break ; } elseif ( strtolower ( $ label [ 'name' ] ) == 'bug' ) { $ changes [ 'bugs' ] [ ] = $ log_entry ; $ sorted = TRUE ; break ; } } } } if ( ! $ sorted ) { $ changes [ 'misc' ] [ ] = $ log_entry ; } return $ changes ; }
|
Sorts log entry according to GitHub label .
|
5,298
|
public function allSites ( ) { $ multisites = $ this -> getConfigValue ( 'multisites' ) ; $ this -> printSyncMap ( $ multisites ) ; $ continue = $ this -> confirm ( "Continue?" , TRUE ) ; if ( ! $ continue ) { return 0 ; } foreach ( $ multisites as $ multisite ) { $ this -> say ( "Refreshing site <comment>$multisite</comment>..." ) ; $ this -> switchSiteContext ( $ multisite ) ; $ this -> sync ( ) ; } }
|
Synchronize each multisite .
|
5,299
|
public function syncFiles ( ) { $ local_alias = '@' . $ this -> getConfigValue ( 'drush.aliases.local' ) ; $ remote_alias = '@' . $ this -> getConfigValue ( 'drush.aliases.remote' ) ; $ site_dir = $ this -> getConfigValue ( 'site' ) ; $ task = $ this -> taskDrush ( ) -> alias ( '' ) -> uri ( '' ) -> drush ( 'rsync' ) -> arg ( $ remote_alias . ':%files/' ) -> arg ( $ this -> getConfigValue ( 'docroot' ) . "/sites/$site_dir/files" ) -> option ( 'exclude-paths' , implode ( ':' , $ this -> getConfigValue ( 'sync.exclude-paths' ) ) ) ; $ result = $ task -> run ( ) ; return $ result ; }
|
Copies remote files to local machine .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.