Repository: shaal/DrupalPod Branch: main Commit: ada1cad5dd5b Files: 82 Total size: 93.5 KB Directory structure: gitextract_g_zia96e/ ├── .ddev/ │ ├── commands/ │ │ ├── host/ │ │ │ └── exec_dir │ │ └── web/ │ │ ├── nightwatch │ │ └── phpunit │ ├── config.yaml │ ├── docker-compose.ports.yaml │ └── docker-compose.testing.yaml ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── Bug_report.md │ │ ├── Feature_request.md │ │ └── Support_request.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── RELEASE_NOTES_TEMPLATE.md │ ├── move.yml │ └── workflows/ │ ├── codesee-arch-diagram.yml │ ├── mirror.yml │ ├── vscode-extension.build.yml │ └── vscode-extension.release.yml ├── .gitignore ├── .gitpod/ │ ├── README.md │ ├── drupal/ │ │ ├── drupalpod-setup/ │ │ │ ├── cleanup.sh │ │ │ ├── composer_setup.sh │ │ │ ├── contrib_modules_setup.sh │ │ │ ├── ddev_setup.sh │ │ │ ├── drupal_setup_contrib.sh │ │ │ ├── drupal_setup_core.sh │ │ │ ├── drupalpod-setup.md │ │ │ ├── drupalpod-setup.sh │ │ │ ├── fallback_setup.sh │ │ │ └── git_setup.sh │ │ ├── install-essential-packages.sh │ │ ├── ssh/ │ │ │ ├── 00-interactive-ssh-setup.sh │ │ │ ├── 01-check-private-ssh.sh │ │ │ ├── 02-setup-private-ssh.sh │ │ │ ├── 03-generate-drupal-ssh-instructions.sh │ │ │ ├── 04-confirm-ssh-setup.sh │ │ │ ├── 05-set-repo-as-ssh.sh │ │ │ └── instructions-template.md │ │ └── templates/ │ │ └── git-exclude.template │ ├── images/ │ │ ├── Dockerfile │ │ └── push.sh │ └── utils/ │ ├── ddev-in-gitpod-setup.sh │ ├── env-setup.sh │ ├── script-templates/ │ │ ├── ddev-composer.template.sh │ │ ├── ddev-drush.template.sh │ │ ├── ddev-node.template.sh │ │ ├── ddev-npx.template.sh │ │ ├── ddev-nvm.template.sh │ │ ├── ddev-php.template.sh │ │ ├── ddev-yarn.template.sh │ │ ├── phpstorm.template.sh │ │ ├── preview.template.sh │ │ └── protect-my-git.template.sh │ ├── send-a-message-gcs.sh │ ├── send-a-message-gitpod.sh │ └── set-base-environment.sh ├── .gitpod.yml ├── .vscode/ │ ├── launch.json │ └── settings.json ├── Drupal Core Development Composer Project.md ├── LICENSE ├── README.md ├── recipes/ │ └── .gitignore └── src/ ├── composer-drupal-core-setup/ │ ├── patch-core-index-and-update.sh │ └── scaffold-patch-index-and-update-php.patch ├── drush-commands-core-development/ │ ├── 11/ │ │ └── DevelopmentProjectCommands.php │ ├── 12/ │ │ └── DevelopmentProjectCommands.php │ └── 13/ │ └── DevelopmentProjectCommands.php └── vscode-extension/ └── drupalpod-ext/ ├── .eslintrc.json ├── .vscode/ │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── README.md ├── package.json ├── src/ │ ├── extension.ts │ ├── help-content.ts │ └── test/ │ ├── runTest.ts │ └── suite/ │ ├── extension.test.ts │ └── index.ts └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .ddev/commands/host/exec_dir ================================================ #!/bin/bash ## Description: Run programs in container, based on current host directory ## Usage: exec_d [args] ## Example: "ddev exec_d yarn" if [ -z "$1" ]; then echo "No argument supplied" exit 1 fi ddev exec -d /var/www/html/"$(echo "$PWD" | cut -d'/' -f4-)" "$@" ================================================ FILE: .ddev/commands/web/nightwatch ================================================ #!/bin/bash ## Description: Run Nightwatch ## Usage: nightwatch [flags] [args] ## Example: "ddev nightwatch" or "ddev nightwatch --tag core" # Installs dependencies if not already run. if [ ! -d /var/www/html/web/core/node_modules ]; then yarn --cwd /var/www/html/web/core install fi yarn --cwd /var/www/html/web/core test:nightwatch $@ ================================================ FILE: .ddev/commands/web/phpunit ================================================ #!/bin/bash ## Description: Run PHPUnit ## Usage: phpunit [flags] [args] ## Example: "ddev phpunit --group big_pipe" or "ddev phpunit core/modules/action" mkdir -p /var/www/html/web/sites/simpletest/browser_output cd web BROWSERTEST_OUTPUT_DIRECTORY=/var/www/html/web/sites/simpletest/browser_output \ BROWSERTEST_OUTPUT_BASE_URL=http://localhost:8080 \ SIMPLETEST_DB="mysql://db:db@db/db" \ SIMPLETEST_BASE_URL="http://localhost" \ php ../vendor/bin/phpunit -c core/phpunit.xml.dist $@ ================================================ FILE: .ddev/config.yaml ================================================ name: DrupalPod type: drupal docroot: web php_version: "8.3" webserver_type: nginx-fpm xdebug_enabled: false additional_hostnames: [] additional_fqdns: [] database: type: mariadb version: "10.6" use_dns_when_possible: true composer_version: "2" web_environment: [] corepack_enable: false # Key features of DDEV's config.yaml: # name: # Name of the project, automatically provides # http://projectname.ddev.site and https://projectname.ddev.site # type: # backdrop, cakephp, craftcms, drupal, drupal6, drupal7, drupal8, drupal9, drupal10, drupal11, generic, laravel, magento, magento2, php, shopware6, silverstripe, symfony, typo3, wordpress # See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more # information on the different project types # docroot: # Relative path to the directory containing index.php. # php_version: "8.3" # PHP version to use, "5.6" through "8.4" # You can explicitly specify the webimage but this # is not recommended, as the images are often closely tied to DDEV's' behavior, # so this can break upgrades. # webimage: # nginx/php docker image. # database: # type: # mysql, mariadb, postgres # version: # database version, like "10.11" or "8.0" # MariaDB versions can be 5.5-10.8, 10.11, and 11.4. # MySQL versions can be 5.5-8.0. # PostgreSQL versions can be 9-17. # router_http_port: # Port to be used for http (defaults to global configuration, usually 80) # router_https_port: # Port for https (defaults to global configuration, usually 443) # xdebug_enabled: false # Set to true to enable Xdebug and "ddev start" or "ddev restart" # Note that for most people the commands # "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better, # as leaving Xdebug enabled all the time is a big performance hit. # xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart" # Note that for most people the commands # "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better, # as leaving Xhprof enabled all the time is a big performance hit. # webserver_type: nginx-fpm, apache-fpm, generic # timezone: Europe/Berlin # If timezone is unset, DDEV will attempt to derive it from the host system timezone # using the $TZ environment variable or the /etc/localtime symlink. # This is the timezone used in the containers and by PHP; # it can be set to any valid timezone, # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones # For example Europe/Dublin or MST7MDT # composer_root: # Relative path to the Composer root directory from the project root. This is # the directory which contains the composer.json and where all Composer related # commands are executed. # composer_version: "2" # You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1 # to use the latest major version available at the time your container is built. # It is also possible to use each other Composer version channel. This includes: # - 2.2 (latest Composer LTS version) # - stable # - preview # - snapshot # Alternatively, an explicit Composer version may be specified, for example "2.2.18". # To reinstall Composer after the image was built, run "ddev debug rebuild". # nodejs_version: "22" # change from the default system Node.js version to any other version. # See https://ddev.readthedocs.io/en/stable/users/configuration/config/#nodejs_version for more information # and https://www.npmjs.com/package/n#specifying-nodejs-versions for the full documentation, # Note that using of 'ddev nvm' is discouraged because "nodejs_version" is much easier to use, # can specify any version, and is more robust than using 'nvm'. # corepack_enable: false # Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm # additional_hostnames: # - somename # - someothername # would provide http and https URLs for "somename.ddev.site" # and "someothername.ddev.site". # additional_fqdns: # - example.com # - sub1.example.com # would provide http and https URLs for "example.com" and "sub1.example.com" # Please take care with this because it can cause great confusion. # upload_dirs: "custom/upload/dir" # # upload_dirs: # - custom/upload/dir # - ../private # # would set the destination paths for ddev import-files to /custom/upload/dir # When Mutagen is enabled this path is bind-mounted so that all the files # in the upload_dirs don't have to be synced into Mutagen. # disable_upload_dirs_warning: false # If true, turns off the normal warning that says # "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set" # ddev_version_constraint: "" # Example: # ddev_version_constraint: ">= 1.22.4" # This will enforce that the running ddev version is within this constraint. # See https://github.com/Masterminds/semver#checking-version-constraints for # supported constraint formats # working_dir: # web: /var/www/html # db: /home # would set the default working directory for the web and db services. # These values specify the destination directory for ddev ssh and the # directory in which commands passed into ddev exec are run. # omit_containers: [db, ddev-ssh-agent] # Currently only these containers are supported. Some containers can also be # omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit # the "db" container, several standard features of DDEV that access the # database container will be unusable. In the global configuration it is also # possible to omit ddev-router, but not here. # performance_mode: "global" # DDEV offers performance optimization strategies to improve the filesystem # performance depending on your host system. Should be configured globally. # # If set, will override the global config. Possible values are: # - "global": uses the value from the global config. # - "none": disables performance optimization for this project. # - "mutagen": enables Mutagen for this project. # - "nfs": enables NFS for this project. # # See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs # See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen # fail_on_hook_fail: False # Decide whether 'ddev start' should be interrupted by a failing hook # host_https_port: "59002" # The host port binding for https can be explicitly specified. It is # dynamic unless otherwise specified. # This is not used by most people, most people use the *router* instead # of the localhost port. # host_webserver_port: "59001" # The host port binding for the ddev-webserver can be explicitly specified. It is # dynamic unless otherwise specified. # This is not used by most people, most people use the *router* instead # of the localhost port. # host_db_port: "59002" # The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic # unless explicitly specified. # mailpit_http_port: "8025" # mailpit_https_port: "8026" # The Mailpit ports can be changed from the default 8025 and 8026 # host_mailpit_port: "8025" # The mailpit port is not normally bound on the host at all, instead being routed # through ddev-router, but it can be bound directly to localhost if specified here. # webimage_extra_packages: [php7.4-tidy, php-bcmath] # Extra Debian packages that are needed in the webimage can be added here # dbimage_extra_packages: [telnet,netcat] # Extra Debian packages that are needed in the dbimage can be added here # use_dns_when_possible: true # If the host has internet access and the domain configured can # successfully be looked up, DNS will be used for hostname resolution # instead of editing /etc/hosts # Defaults to true # project_tld: ddev.site # The top-level domain used for project URLs # The default "ddev.site" allows DNS lookup via a wildcard # If you prefer you can change this to "ddev.local" to preserve # pre-v1.9 behavior. # ngrok_args: --basic-auth username:pass1234 # Provide extra flags to the "ngrok http" command, see # https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h" # disable_settings_management: false # If true, DDEV will not create CMS-specific settings files like # Drupal's settings.php/settings.ddev.php or TYPO3's additional.php # In this case the user must provide all such settings. # You can inject environment variables into the web container with: # web_environment: # - SOMEENV=somevalue # - SOMEOTHERENV=someothervalue # no_project_mount: false # (Experimental) If true, DDEV will not mount the project into the web container; # the user is responsible for mounting it manually or via a script. # This is to enable experimentation with alternate file mounting strategies. # For advanced users only! # bind_all_interfaces: false # If true, host ports will be bound on all network interfaces, # not the localhost interface only. This means that ports # will be available on the local network if the host firewall # allows it. # default_container_timeout: 120 # The default time that DDEV waits for all containers to become ready can be increased from # the default 120. This helps in importing huge databases, for example. #web_extra_exposed_ports: #- name: nodejs # container_port: 3000 # http_port: 2999 # https_port: 3000 #- name: something # container_port: 4000 # https_port: 4000 # http_port: 3999 # Allows a set of extra ports to be exposed via ddev-router # Fill in all three fields even if you don’t intend to use the https_port! # If you don’t add https_port, then it defaults to 0 and ddev-router will fail to start. # # The port behavior on the ddev-webserver must be arranged separately, for example # using web_extra_daemons. # For example, with a web app on port 3000 inside the container, this config would # expose that web app on https://.ddev.site:9999 and http://.ddev.site:9998 # web_extra_exposed_ports: # - name: myapp # container_port: 3000 # http_port: 9998 # https_port: 9999 #web_extra_daemons: #- name: "http-1" # command: "/var/www/html/node_modules/.bin/http-server -p 3000" # directory: /var/www/html #- name: "http-2" # command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000" # directory: /var/www/html # override_config: false # By default, config.*.yaml files are *merged* into the configuration # But this means that some things can't be overridden # For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge # and you can't erase existing hooks or all environment variables. # However, with "override_config: true" in a particular config.*.yaml file, # 'use_dns_when_possible: false' can override the existing values, and # hooks: # post-start: [] # or # web_environment: [] # or # additional_hostnames: [] # can have their intended affect. 'override_config' affects only behavior of the # config.*.yaml file it exists in. # Many DDEV commands can be extended to run tasks before or after the # DDEV command is executed, for example "post-start", "post-import-db", # "pre-composer", "post-composer" # See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more # information on the commands that can be extended and the tasks you can define # for them. Example: #hooks: # post-import-db: # - exec: drush sql:sanitize # - exec: drush updatedb # - exec: drush cache:rebuild ================================================ FILE: .ddev/docker-compose.ports.yaml ================================================ # Expose port 3000 and 5000 of DDEV's web container. services: web: # ports are a list of exposed *container* ports ports: - 3000:3000 - 5000:5000 ================================================ FILE: .ddev/docker-compose.testing.yaml ================================================ --- # Adds Chromedriver and Drupal PHPUnit test environment variables for running tests. services: chromedriver: image: drupalci/chromedriver:production container_name: ddev-${DDEV_SITENAME}-chromedriver networks: [default, ddev_default] labels: com.ddev.site-name: ${DDEV_SITENAME} com.ddev.approot: $DDEV_APPROOT web: links: - chromedriver:$DDEV_HOSTNAME environment: # PHPUnit SYMFONY_DEPRECATIONS_HELPER: weak SIMPLETEST_DB: mysql://db:db@db:3306/db SIMPLETEST_BASE_URL: http://localhost BROWSERTEST_OUTPUT_DIRECTORY: /var/www/html/private/browsertest_output BROWSERTEST_OUTPUT_BASE_URL: $DDEV_PRIMARY_URL MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://chromedriver:9515"]' # Nightwatch DRUPAL_TEST_BASE_URL: http://web DRUPAL_TEST_DB_URL: mysql://db:db@db:3306/db DRUPAL_TEST_WEBDRIVER_HOSTNAME: chromedriver DRUPAL_TEST_WEBDRIVER_PORT: 9515 DRUPAL_TEST_CHROMEDRIVER_AUTOSTART: 'false' DRUPAL_TEST_WEBDRIVER_CHROME_ARGS: "--disable-gpu --headless --no-sandbox" DRUPAL_NIGHTWATCH_OUTPUT: reports/nightwatch DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES: node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: shaal patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .github/ISSUE_TEMPLATE/Bug_report.md ================================================ --- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- ## Describe the bug ## To Reproduce ## Expected behavior ## Screenshots ### Version and configuration information (please complete the following information) - **Issue page** - **Issue branch** - **Drupal core version** - **Project type** - [ ] Core - [ ] Module - [ ] Theme ## Additional context ================================================ FILE: .github/ISSUE_TEMPLATE/Feature_request.md ================================================ --- name: Feature request about: Suggest an idea for this project title: '' labels: '' assignees: '' --- ## Is your feature request related to a problem? Please describe ## Describe the solution you'd like ## Describe alternatives you've considered ## Additional context ================================================ FILE: .github/ISSUE_TEMPLATE/Support_request.md ================================================ --- name: Support Request about: Get help with a problem title: '' labels: '' assignees: '' --- ## Describe the problem ## To Reproduce ## Expected behavior ## Screenshots ### Version and configuration information (please complete the following information) - **Issue page** - **Issue branch** - **Drupal core version** - **Project type** - [ ] Core - [ ] Module - [ ] Theme ## Additional context ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ # The Problem/Issue/Bug ## How this PR Solves The Problem ## Manual Testing Instructions ## Related Issue Link(s) ## Release/Deployment notes ================================================ FILE: .github/RELEASE_NOTES_TEMPLATE.md ================================================ # Key changes in _VERSION_: * # Commits since _PREVIOUS VERSION_ # Caveats ================================================ FILE: .github/move.yml ================================================ # Configuration for move-issues - https://github.com/dessant/move-issues # Delete the command comment when it contains no other content deleteCommand: true # Close the source issue after moving closeSourceIssue: true # Lock the source issue after moving lockSourceIssue: false # Mention issue and comment authors mentionAuthors: true # Preserve mentions in the issue content keepContentMentions: false # Set custom aliases for targets # aliases: # r: repo # or: owner/repo ================================================ FILE: .github/workflows/codesee-arch-diagram.yml ================================================ # This workflow was added by CodeSee. Learn more at https://codesee.io/ # This is v2.0 of this workflow file on: push: branches: - main pull_request_target: types: [opened, synchronize, reopened] name: CodeSee permissions: read-all jobs: codesee: runs-on: ubuntu-latest continue-on-error: true name: Analyze the repo with CodeSee steps: - uses: Codesee-io/codesee-action@v2 with: codesee-token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} ================================================ FILE: .github/workflows/mirror.yml ================================================ # This mirrors daily from an upstream repository. # These two things must be set: # UPSTREAM_REPO should be set to something like # https://git.drupalcode.org/issue/drupalpod-3474581.git # WORKFLOW_TOKEN is a secret in the "normal" environment containing # a fine-grained PAT with permissions to read/write content and read/write workflows name: Mirror from Upstream defaults: run: shell: bash on: schedule: - cron: '0 0 * * *' # Runs daily at midnight UTC workflow_dispatch: # Allows manual triggering of the workflow permissions: contents: write jobs: mirror: runs-on: ubuntu-latest env: CLONEDIR: "/tmp/clonedir" # The environment variables will be in the environment "normal" environment: "normal" steps: - name: Set up Git environment run: | git config --global user.name "GitHub Action" git config --global user.email "action@github.com" - name: Clone upstream repository run: | set -x set -eu -o pipefail mkdir -p ${CLONEDIR} # The variable UPSTREAM_REPO must be set in the repository's # "normal" environment git clone --mirror "${{ vars.UPSTREAM_REPO }}" "${{ env.CLONEDIR }}" - name: Remove existing Git credentials run: | git config --global --unset-all http.https://github.com/.extraheader || true - name: Push to GitHub env: # The WORKFLOW_TOKEN is a fine-grained PAT with # contents: read-write and # workflow:read/write perm for this repo WORKFLOW_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} REPO: ${{ github.repository }} run: | set -x cd ${{ env.CLONEDIR }} git remote set-url origin "https://github.com/${REPO}.git" git config --global user.name "GitHub Action" git config --global user.email "action@github.com" git remote set-url origin "https://x-access-token:${WORKFLOW_TOKEN}@github.com/${REPO}.git" git push --mirror ================================================ FILE: .github/workflows/vscode-extension.build.yml ================================================ name: Test VSCode Extension on: - push - pull_request jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: 14.x # @todo https://github.com/actions/setup-node/pull/299 # cache: true - run: yarn install working-directory: ./src/vscode-extension/drupalpod-ext # @todo run tests when "vscode-test" package works in GitPod and/or Actions. # - # run: yarn test # working-directory: ./src/vscode-extension/drupalpod-ext - run: yarn package working-directory: ./src/vscode-extension/drupalpod-ext ================================================ FILE: .github/workflows/vscode-extension.release.yml ================================================ name: Publish VSCode Extension on: release: types: [published] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: 14.x # @todo https://github.com/actions/setup-node/pull/299 # cache: 'yarn' - run: yarn install working-directory: ./src/vscode-extension/drupalpod-ext # @todo bump the version with each DrupalPod release automatically? # This will mean the release doesn't have the new version in repos? # - # run: yarn version --new-version ${{ github.event.release.tag_name }} # working-directory: ./src/vscode-extension/drupalpod-ext #- # run: git push origin - run: npm run ovsx publish -p ${{ secrets.OVSX_TOKEN }} working-directory: ./src/vscode-extension/drupalpod-ext ================================================ FILE: .gitignore ================================================ # Drupal /web/ /vendor/ composer.json composer.lock .editorconfig .gitattributes # DrupalPod .drupalpod_initiated .gitmodules repos/ src/**/node_modules/ src/**/package-lock.json src/**/out/ src/**/*.vsix src/**/.vscode-test/ drush/ .ddev/config.gitpod.yaml ================================================ FILE: .gitpod/README.md ================================================ # Setting up a new version for DrupalPod ## Build custom Gitpod image 1. Update `.gitpod/images/Dockerfile`: 1. Update `ddev` latest version. 1. Update `minio` latest version. 1. Update `gitui` latest version. 1. Update `lazygit` latest version. 1. Generate new custom docker image: 1. Run `docker login` to authenticate and push new images to docker hub. 1. In `/.gitpod/images` run `./push.sh` command to build and push the new custom docker image. 1. Confirm the process run without errors and that the new custom image gets uploaded to . 1. Update `/.gitpod.yml` with the new image file. 1. Push code, and re-open Gitpod workspace, to use latest custom docker image. 1. Run manual prebuild (to load ddev's images) 1. Confirm latest setup 1. Open new workspace. 1. Check if there are any updates (ie. DDEV's default settings files). 1. Test various scenarios with DrupalPod browser extension 1. Confirm core issues work as expected. 1. Confirm contrib issue work as expected. 1. Merge PR into `main` branch 1. Confirm `main` branch work as expected 🎉 ================================================ FILE: .gitpod/drupal/drupalpod-setup/cleanup.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Remove site that was installed before (for debugging) rm -rf "${GITPOD_REPO_ROOT}"/web rm -rf "${GITPOD_REPO_ROOT}"/vendor rm -f "${GITPOD_REPO_ROOT}"/composer.json rm -f "${GITPOD_REPO_ROOT}"/composer.lock ================================================ FILE: .gitpod/drupal/drupalpod-setup/composer_setup.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # For versions end with x - add `-dev` suffix (ie. 9.3.x-dev) # For versions without x - add `~` prefix (ie. ~9.2.0) d="$DP_CORE_VERSION" case $d in *.x) install_version="$d"-dev ;; *) install_version=~"$d" ;; esac # Create required composer.json and composer.lock files cd "$GITPOD_REPO_ROOT" && time ddev . composer create -n --no-install drupal/recommended-project:"$install_version" temp-composer-files cp "$GITPOD_REPO_ROOT"/temp-composer-files/* "$GITPOD_REPO_ROOT"/. rm -rf "$GITPOD_REPO_ROOT"/temp-composer-files # Programmatically fix Composer 2.2 allow-plugins to avoid errors ddev composer config --no-plugins allow-plugins.composer/installers true ddev composer config --no-plugins allow-plugins.drupal/core-project-message true ddev composer config --no-plugins allow-plugins.drupal/core-vendor-hardening true ddev composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true ddev composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true ddev composer config --no-plugins allow-plugins.phpstan/extension-installer true ddev composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true ddev composer config --no-plugins allow-plugins.php-http/discovery true ddev composer config --no-plugins allow-plugins.tbachert/spi true # Add project source code as symlink (to repos/name_of_project) # double quotes explained - https://stackoverflow.com/a/1250279/5754049 if [ -n "$DP_PROJECT_NAME" ]; then cd "${GITPOD_REPO_ROOT}" && ddev composer config \ repositories.core1 \ '{"type": "path", "url": "repos/'"$DP_PROJECT_NAME"'", "options": {"symlink": true}}' cd "$GITPOD_REPO_ROOT" && ddev composer config minimum-stability dev fi ================================================ FILE: .gitpod/drupal/drupalpod-setup/contrib_modules_setup.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Check if additional modules should be installed export DEVEL_NAME="devel" export DEVEL_PACKAGE="drupal/devel" export ADMIN_TOOLBAR_NAME="admin_toolbar_tools" export ADMIN_TOOLBAR_PACKAGE="drupal/admin_toolbar" # TODO: once Drupalpod extension supports additional modules - remove these 2 lines export DP_EXTRA_DEVEL=1 export DP_EXTRA_ADMIN_TOOLBAR=1 # Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient if [[ "$DP_CORE_VERSION" =~ ^10(\..*)?$ ]]; then if [ "$DP_PROJECT_TYPE" != "project_core" ]; then export COMPOSER_DRUPAL_LENIENT=mglaman/composer-drupal-lenient else export COMPOSER_DRUPAL_LENIENT='' fi fi # Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient if [[ "$DP_CORE_VERSION" =~ ^11(\..*)?$ ]]; then # admin_toolbar and devel are not compatible yet with Drupal 11 export DP_EXTRA_ADMIN_TOOLBAR= export DP_EXTRA_DEVEL= if [ "$DP_PROJECT_TYPE" != "project_core" ]; then export COMPOSER_DRUPAL_LENIENT=mglaman/composer-drupal-lenient else export COMPOSER_DRUPAL_LENIENT='' fi fi ================================================ FILE: .gitpod/drupal/drupalpod-setup/ddev_setup.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # set PHP version, based on https://www.drupal.org/docs/getting-started/system-requirements/php-requirements#versions major_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 1) minor_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 2) # Before Drupal 10.2, we should use php 8.2, otherwise use php 8.3 if (( major_version < 10 )) || { (( major_version == 10 )) && (( minor_version < 2 )); }; then php_version="8.2" else php_version="8.3" fi cat < "${GITPOD_REPO_ROOT}"/.ddev/config.gitpod.yaml #ddev-gitpod-generated php_version: "$php_version" CONFIGEND time ddev start ================================================ FILE: .gitpod/drupal/drupalpod-setup/drupal_setup_contrib.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Drupal projects with no composer.json, bypass the symlink config, symlink has to be created manually. if [ "$DP_PROJECT_TYPE" == "project_module" ]; then PROJECT_TYPE=modules elif [ "$DP_PROJECT_TYPE" == "project_theme" ]; then PROJECT_TYPE=themes fi cat <"${GITPOD_REPO_ROOT}"/repos/add-project-as-symlink.sh #!/usr/bin/env bash # This file was dynamically generated by a script echo "Replace project with a symlink" rm -rf web/$PROJECT_TYPE/contrib/$DP_PROJECT_NAME cd web/$PROJECT_TYPE/contrib && ln -s ../../../repos/$DP_PROJECT_NAME . PROJECTASYMLINK chmod +x "${GITPOD_REPO_ROOT}"/repos/add-project-as-symlink.sh if [ -n "$COMPOSER_DRUPAL_LENIENT" ]; then # Add composer_drupal_lenient for modules on Drupal 10 cd "${GITPOD_REPO_ROOT}" && ddev composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/'"$DP_PROJECT_NAME"'"]' cd "${GITPOD_REPO_ROOT}" && time ddev . composer require "$COMPOSER_DRUPAL_LENIENT" --no-install fi # Add the project to composer (it will get the version according to the branch under `/repo/name_of_project`) cd "${GITPOD_REPO_ROOT}" && time ddev . composer require drupal/"$DP_PROJECT_NAME" --no-interaction --no-install ================================================ FILE: .gitpod/drupal/drupalpod-setup/drupal_setup_core.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Add a special path when working on core contributions # (Without it, /web/modules/contrib is not found by website) cd "${GITPOD_REPO_ROOT}" && ddev composer config \ repositories.drupal-core2 \ '{"type": "path", "url": "repos/drupal/core"}' cd "${GITPOD_REPO_ROOT}" && ddev composer config \ repositories.drupal-core3 \ '{"type": "path", "url": "repos/drupal/composer/Metapackage/CoreRecommended"}' cd "${GITPOD_REPO_ROOT}" && ddev composer config \ repositories.drupal-core4 \ '{"type": "path", "url": "repos/drupal/composer/Metapackage/DevDependencies"}' cd "${GITPOD_REPO_ROOT}" && ddev composer config \ repositories.drupal-core5 \ '{"type": "path", "url": "repos/drupal/composer/Plugin/ProjectMessage"}' cd "${GITPOD_REPO_ROOT}" && ddev composer config \ repositories.drupal-core6 \ '{"type": "path", "url": "repos/drupal/composer/Plugin/VendorHardening"}' # Removing the conflict part of composer echo "$(cat composer.json | jq 'del(.conflict)' --indent 4)" >composer.json # If a core issue branch was chosen, we want the version of Drupal core that is in that issue branch # This is very helpful for issues that started with previous Drupal core versions, and the issue version automatically got updated to latest current drupal version if [ "$DP_PROJECT_TYPE" == "project_core" ] && [ -n "$DP_ISSUE_BRANCH" ]; then time composer require drupal/core-recommended:* drupal/core-project-message:* drupal/core-composer-scaffold:* --no-update fi # Only after composer update, /web/core get symlinked to /repos/drupal/core # repos/drupal/core -> web/core time composer update # vendor -> repos/drupal/vendor if [ ! -L "$GITPOD_REPO_ROOT"/repos/drupal/vendor ]; then cd "$GITPOD_REPO_ROOT"/repos/drupal && ln -s ../../vendor . fi # Create folders for running tests mkdir -p "$GITPOD_REPO_ROOT"/web/sites/simpletest mkdir -p "$GITPOD_REPO_ROOT"/web/sites/simpletest/browser_output # Symlink the simpletest folder into the Drupal core git repo. # repos/drupal/sites/simpletest -> ../../../web/sites/simpletest if [ ! -L "$GITPOD_REPO_ROOT"/repos/drupal/sites/simpletest ]; then cd "$GITPOD_REPO_ROOT"/repos/drupal/sites && ln -s ../../../web/sites/simpletest . fi ================================================ FILE: .gitpod/drupal/drupalpod-setup/drupalpod-setup.md ================================================ # File Structure The drupalpod-setup.sh script can be divided into several logical sections based on the tasks it performs. Here are some potential divisions: 1. Environment Setup: This section sets up the environment variables and checks for certain conditions. It includes the loading of default environment variables, setting up the default setup during the prebuild process, and checking if additional modules should be installed. 1. Composer Support: This section adds support for composer-drupal-lenient based on the Drupal core version. 1. Drupal Setup: This section checks if the setup has already run once and if no special setup is set by the DrupalPod extension. If not, it performs a series of setup tasks, including adding git.drupal.org to known hosts, ignoring specific directories during Drupal core development, and getting the required repo ready. 1. Drupal Installation: This section handles the installation of Drupal, including enabling extra modules, setting the default admin theme, enabling the requested module or theme, and updating the database if working on core. 1. Post-Installation: This section takes a snapshot of the database, saves a file to mark the workspace as already initiated, and measures the script time. 1. Sourced Files: - `setup_env.sh`: Sets up default environment variables based on a `.env` file. - `install_modules.sh`: Sets environment variables for installing additional modules in Drupal. - `drupal_version_specifics.sh`: Adds support for the `composer-drupal-lenient` package based on the Drupal core version. ================================================ FILE: .gitpod/drupal/drupalpod-setup/drupalpod-setup.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Initialize all variables with null if they do not exist : "${DEBUG_SCRIPT:=}" : "${GITPOD_HEADLESS:=}" : "${DP_INSTALL_PROFILE:=}" : "${DP_EXTRA_DEVEL:=}" : "${DP_EXTRA_ADMIN_TOOLBAR:=}" : "${DP_PROJECT_TYPE:=}" : "${DEVEL_NAME:=}" : "${DEVEL_PACKAGE:=}" : "${ADMIN_TOOLBAR_NAME:=}" : "${ADMIN_TOOLBAR_PACKAGE:=}" : "${COMPOSER_DRUPAL_LENIENT:=}" : "${DP_CORE_VERSION:=}" : "${DP_ISSUE_BRANCH:=}" : "${DP_ISSUE_FORK:=}" : "${DP_MODULE_VERSION:=}" : "${DP_PATCH_FILE:=}" # Assuming .sh files are in the same directory as this script DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" if [ -n "$DEBUG_SCRIPT" ] || [ -n "$GITPOD_HEADLESS" ]; then set -x fi convert_version() { local version=$1 if [[ $version =~ "-" ]]; then # Remove the part after the dash and replace the last numeric segment with 'x' local base_version=${version%-*} echo "${base_version%.*}.x" else echo "$version" fi } # Test cases # echo $(convert_version "9.2.5-dev1") # Output: 9.2.x # echo $(convert_version "9.2.5") # Output: 9.2.5 # echo $(convert_version "10.1.0-beta1") # Output: 10.1.x # echo $(convert_version "11.0-dev") # Output: 11.x # Skip setup if it already ran once and if no special setup is set by DrupalPod extension if [ ! -f "${GITPOD_REPO_ROOT}"/.drupalpod_initiated ]; then # Set a default setup if project type wasn't specified if [ -z "$DP_PROJECT_TYPE" ]; then source "$DIR/fallback_setup.sh" fi source "$DIR/git_setup.sh" # If this is an issue fork of Drupal core - set the drupal core version based on that issue fork if [ "$DP_PROJECT_TYPE" == "project_core" ] && [ -n "$DP_ISSUE_FORK" ]; then VERSION_FROM_GIT=$(grep 'const VERSION' "${GITPOD_REPO_ROOT}"/repos/drupal/core/lib/Drupal.php | awk -F "'" '{print $2}') DP_CORE_VERSION=$(convert_version "$VERSION_FROM_GIT") export DP_CORE_VERSION fi source "$DIR/ddev_setup.sh" # Measure the time it takes to go through the script script_start_time=$(date +%s) source "$DIR/contrib_modules_setup.sh" source "$DIR/cleanup.sh" source "$DIR/composer_setup.sh" if [ -n "$DP_PATCH_FILE" ]; then echo Applying selected patch "$DP_PATCH_FILE" cd "${WORK_DIR}" && curl "$DP_PATCH_FILE" | patch -p1 fi # Prepare special setup to work with Drupal core if [ "$DP_PROJECT_TYPE" == "project_core" ]; then source "$DIR/drupal_setup_core.sh" # Prepare special setup to work with Drupal contrib elif [ -n "$DP_PROJECT_NAME" ]; then source "$DIR/drupal_setup_contrib.sh" fi time "${GITPOD_REPO_ROOT}"/.gitpod/drupal/install-essential-packages.sh # Configure phpcs for drupal. cd "$GITPOD_REPO_ROOT" && vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer # ddev config auto updates settings.php and generates settings.ddev.php ddev config --auto # New site install time ddev drush si -y --account-pass=admin --site-name="DrupalPod" "$DP_INSTALL_PROFILE" # Install devel and admin_toolbar modules if [ "$DP_EXTRA_DEVEL" != '1' ]; then DEVEL_NAME= fi if [ "$DP_EXTRA_ADMIN_TOOLBAR" != '1' ]; then ADMIN_TOOLBAR_NAME= fi # Enable extra modules cd "${GITPOD_REPO_ROOT}" && ddev drush en -y \ "$ADMIN_TOOLBAR_NAME" \ "$DEVEL_NAME" # Enable the requested module if [ "$DP_PROJECT_TYPE" == "project_module" ]; then cd "${GITPOD_REPO_ROOT}" && ddev drush en -y "$DP_PROJECT_NAME" fi # Enable the requested theme if [ "$DP_PROJECT_TYPE" == "project_theme" ]; then cd "${GITPOD_REPO_ROOT}" && ddev drush then -y "$DP_PROJECT_NAME" cd "${GITPOD_REPO_ROOT}" && ddev drush config-set -y system.theme default "$DP_PROJECT_NAME" fi # Take a snapshot cd "${GITPOD_REPO_ROOT}" && ddev snapshot echo "Your database state was locally saved, you can revert to it by typing:" echo "ddev snapshot restore --latest" # Save a file to mark workspace already initiated touch "${GITPOD_REPO_ROOT}"/.drupalpod_initiated # Finish measuring script time script_end_time=$(date +%s) runtime=$((script_end_time - script_start_time)) echo "drupalpod-setup.sh script ran for" $runtime "seconds" else cd "${GITPOD_REPO_ROOT}" && ddev start fi # Open internal preview browser with current website preview ================================================ FILE: .gitpod/drupal/drupalpod-setup/fallback_setup.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Set a default setup (when project type is not specified) export DP_INSTALL_PROFILE='demo_umami' export DP_PROJECT_TYPE='project_core' export DP_PROJECT_NAME="drupal" export DP_CORE_VERSION='11.1.4' export DP_EXTRA_DEVEL=1 export DP_EXTRA_ADMIN_TOOLBAR=1 ================================================ FILE: .gitpod/drupal/drupalpod-setup/git_setup.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Add git.drupal.org to known_hosts if [ -z "$GITPOD_HEADLESS" ]; then mkdir -p ~/.ssh host=git.drupal.org SSHKey=$(ssh-keyscan $host 2>/dev/null) echo "$SSHKey" >>~/.ssh/known_hosts fi # Ignore specific directories during Drupal core development cp "${GITPOD_REPO_ROOT}"/.gitpod/drupal/templates/git-exclude.template "${GITPOD_REPO_ROOT}"/.git/info/exclude # Get the required repo ready if [ "$DP_PROJECT_TYPE" == "project_core" ]; then # Find if requested core version is dev or stable d="$DP_CORE_VERSION" case $d in *.x) # If dev - use git checkout origin/* checkout_type=origin ;; *) # stable - use git checkout tags/* checkout_type=tags ;; esac # Use origin or tags in git checkout command cd "${GITPOD_REPO_ROOT}"/repos/drupal && git fetch origin && git fetch --all --tags && git checkout "$checkout_type"/"$DP_CORE_VERSION" # Ignore specific directories during Drupal core development cp "${GITPOD_REPO_ROOT}"/.gitpod/drupal/templates/git-exclude.template "${GITPOD_REPO_ROOT}"/repos/drupal/.git/info/exclude else # If not core - clone selected project into /repos and remove drupal core rm -rf "${GITPOD_REPO_ROOT}"/repos/drupal if [ ! -d repos/"${DP_PROJECT_NAME}" ]; then mkdir -p repos cd "${GITPOD_REPO_ROOT}"/repos && time git clone https://git.drupalcode.org/project/"$DP_PROJECT_NAME".git fi fi # Set WORK_DIR export WORK_DIR="${GITPOD_REPO_ROOT}"/repos/$DP_PROJECT_NAME # Dynamically generate .gitmodules file cat <"${GITPOD_REPO_ROOT}"/.gitmodules # This file was dynamically generated by a script [submodule "$DP_PROJECT_NAME"] path = repos/$DP_PROJECT_NAME url = https://git.drupalcode.org/project/$DP_PROJECT_NAME.git ignore = dirty GITMODULESEND # Checkout specific branch only if there's issue_branch if [ -n "$DP_ISSUE_BRANCH" ]; then # If branch already exist only run checkout, if cd "${WORK_DIR}" && git show-ref -q --heads "$DP_ISSUE_BRANCH"; then cd "${WORK_DIR}" && git checkout "$DP_ISSUE_BRANCH" else cd "${WORK_DIR}" && git remote add "$DP_ISSUE_FORK" https://git.drupalcode.org/issue/"$DP_ISSUE_FORK".git cd "${WORK_DIR}" && git fetch "$DP_ISSUE_FORK" cd "${WORK_DIR}" && git checkout -b "$DP_ISSUE_BRANCH" --track "$DP_ISSUE_FORK"/"$DP_ISSUE_BRANCH" fi elif [ -n "$DP_MODULE_VERSION" ] && [ "$DP_PROJECT_TYPE" != "project_core" ]; then cd "${WORK_DIR}" && git checkout "$DP_MODULE_VERSION" fi ================================================ FILE: .gitpod/drupal/install-essential-packages.sh ================================================ #!/usr/bin/env bash set -eu -o pipefail # Initialize all variables with null if they do not exist : "${DEBUG_SCRIPT:=}" : "${GITPOD_HEADLESS:=}" : "${DP_EXTRA_DEVEL:=}" : "${DP_EXTRA_ADMIN_TOOLBAR:=}" : "${DEVEL_PACKAGE:=}" : "${ADMIN_TOOLBAR_PACKAGE:=}" if [ -n "$DEBUG_SCRIPT" ] || [ -n "$GITPOD_HEADLESS" ]; then set -x fi # Install devel and admin_toolbar modules if [ "$DP_EXTRA_DEVEL" != '1' ]; then DEVEL_PACKAGE= fi if [ "$DP_EXTRA_ADMIN_TOOLBAR" != '1' ]; then ADMIN_TOOLBAR_PACKAGE= fi cd "${GITPOD_REPO_ROOT}" && time ddev . composer require --dev "drupal/core-dev":* "phpspec/prophecy-phpunit":^2 -W --no-install cd "${GITPOD_REPO_ROOT}" && time ddev . composer require "drush/drush" "drupal/coder" "$DEVEL_PACKAGE" "$ADMIN_TOOLBAR_PACKAGE" # Only for Drupal core - apply special patch if [ "$DP_PROJECT_TYPE" == "project_core" ]; then # Patch the scaffold index.php and update.php files # See https://www.drupal.org/project/drupal/issues/3188703 # See https://www.drupal.org/project/drupal/issues/1792310 echo "$(cat composer.json | jq '.scripts."post-install-cmd" |= . + ["src/composer-drupal-core-setup/patch-core-index-and-update.sh"]')" >composer.json echo "$(cat composer.json | jq '.scripts."post-update-cmd" |= . + ["src/composer-drupal-core-setup/patch-core-index-and-update.sh"]')" >composer.json # Run the patch once time src/composer-drupal-core-setup/patch-core-index-and-update.sh # Get the major version of 'drush/drush' drush_major_version=$(composer show drush/drush --no-ansi | awk '/versions/ {print $NF}' | cut -d '.' -f1) drush_command_dir="$GITPOD_REPO_ROOT/drush/Commands/core_development" mkdir -p "$drush_command_dir" # Copy the correct version of DevelopmentProjectCommands.php file to the drush commands directory cp "$GITPOD_REPO_ROOT/src/drush-commands-core-development/$drush_major_version/DevelopmentProjectCommands.php" "$drush_command_dir/." else # Only for contrib - add project as symlink echo "$(cat composer.json | jq '.scripts."post-install-cmd" |= . + ["repos/add-project-as-symlink.sh"]')" >composer.json echo "$(cat composer.json | jq '.scripts."post-update-cmd" |= . + ["repos/add-project-as-symlink.sh"]')" >composer.json time repos/add-project-as-symlink.sh fi ================================================ FILE: .gitpod/drupal/ssh/00-interactive-ssh-setup.sh ================================================ #!/bin/bash # Copy your public key # php -S localhost:8000 id_rsa.backup & sleep 3 & gp preview $(gp url 8000) # killall php # while-menu-dialog: a menu driven system information program DIALOG_CANCEL=1 DIALOG_ESC=255 HEIGHT=0 WIDTH=0 display_result() { dialog --title "$1" \ --no-collapse \ --msgbox "$result" 0 0 } while true; do exec 3>&1 selection=$(dialog \ --backtitle "Installer/Services menu" \ --title "Menu" \ --clear \ --cancel-label "Exit" \ --menu "Please select:" $HEIGHT $WIDTH 4 \ "1" "Setup SSH" \ 2>&1 1>&3) exit_status=$? exec 3>&- case $exit_status in $DIALOG_CANCEL) clear echo "Program terminated." exit ;; $DIALOG_ESC) clear echo "Program aborted." >&2 exit 1 ;; esac case $selection in 0 ) clear echo "Program terminated." ;; 1 ) result=$(code .gitpod/drupal/ssh/instructions-template.md) display_result "If you completed the instructions above - click OK" .gitpod/drupal/ssh/04-confirm-ssh-setup.sh # gp preview https://drupal.org/user --external ;; esac done ================================================ FILE: .gitpod/drupal/ssh/01-check-private-ssh.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi # Check if ~/.ssh/id_rsa already exist if [ -f ~/.ssh/id_rsa ]; then echo "No need to setup a key, SSH key already exists." else if [ -z "$DRUPAL_SSH_KEY" ]; then # DRUPAL_SSH_KEY environment variable is not set, check if SSH ley was create during this session if [ -f /workspace/id_rsa ] ; then # Edge case where user already setup key in workspace that timed out. echo "No need to setup a key, SSH key found." mkdir -p ~/.ssh cp /workspace/id_rsa ~/.ssh/. fi else echo "Setting SSH key from environment variable" mkdir -p ~/.ssh printenv DRUPAL_SSH_KEY > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa fi # Ask for SSH keyphrase only once if ssh-add -l > /dev/null ; then eval "$(ssh-agent -s)" > /dev/null ssh-add -q ~/.ssh/id_rsa fi fi ================================================ FILE: .gitpod/drupal/ssh/02-setup-private-ssh.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi SSH_SETUP_REQUIRED=true # Add git.drupal.org to known_hosts mkdir -p ~/.ssh host=git.drupal.org SSHKey=$(ssh-keyscan $host 2> /dev/null) echo "$SSHKey" >> ~/.ssh/known_hosts # Validate private SSH key in Gitpod with public SSH key in drupal.org if ssh -T git@git.drupal.org; then read -r -p "SSH key was already confirmed with Drupal.org, are you sure you want to recreate SSH key? [y/N]" setup_ssh if [ "$setup_ssh" != "y" ] && [ "$setup_ssh" != "Y" ]; then SSH_SETUP_REQUIRED=false fi fi if $SSH_SETUP_REQUIRED; then # Create ssh key pairing + instructions to paste public key in drupal.org ssh-keygen -q -t rsa -b 4096 -f ~/.ssh/id_rsa .gitpod/drupal/ssh/03-generate-drupal-ssh-instructions.sh echo "Follow instructions for copying public key to Drupal" echo "Test SSH by running .gitpod/drupal/ssh/04-confirm-ssh-setup.sh" fi ================================================ FILE: .gitpod/drupal/ssh/03-generate-drupal-ssh-instructions.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi # create instructions file with user's public key cat ~/.ssh/id_rsa.pub > /workspace/public_key.md cat .gitpod/drupal/ssh/instructions-template.md > /workspace/drupal-public-key-setup.md cat ~/.ssh/id_rsa.pub >> /workspace/drupal-public-key-setup.md gp open /workspace/drupal-public-key-setup.md ================================================ FILE: .gitpod/drupal/ssh/04-confirm-ssh-setup.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi # Add git.drupal.org to known_hosts mkdir -p ~/.ssh host=git.drupal.org SSHKey=$(ssh-keyscan $host 2> /dev/null) echo "$SSHKey" >> ~/.ssh/known_hosts # Ask for SSH keyphrase only once if ssh-add -l > /dev/null ; then eval "$(ssh-agent -s)" > /dev/null ssh-add -q ~/.ssh/id_rsa fi # Validate private SSH key in Gitpod with public SSH key in drupal.org if ssh -T git@git.drupal.org; then echo "Setup was succesful, saving your private key in Gitpod" # Set private SSH key as Gitpod variable anvironment gp env "DRUPAL_SSH_KEY=$(cat ~/.ssh/id_rsa)" > /dev/null # Copy key to /workspace in case this workspace times out cp ~/.ssh/id_rsa /workspace/. # Set repo remote branch to SSH (in case it was added as HTTPS) .gitpod/drupal/ssh/05-set-repo-as-ssh.sh else if [ ! -f ~/.ssh/id_rsa.pub ] ; then echo "Setup failed, create private key again" rm -f /workspace/id_rsa rm -rf ~/.ssh .gitpod/drupal/ssh/02-setup-private-ssh.sh else echo "Setup failed, please confirm you copied public key to Drupal" .gitpod/drupal/ssh/03-generate-drupal-ssh-instructions.sh fi fi ================================================ FILE: .gitpod/drupal/ssh/05-set-repo-as-ssh.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi # Set a specific branch if there's issue_fork if [ -n "$DP_ISSUE_FORK" ]; then cd "${GITPOD_REPO_ROOT}"/repos/"$DP_PROJECT_NAME" && git remote set-url "$DP_ISSUE_FORK" git@git.drupal.org:issue/"$DP_ISSUE_FORK".git fi ================================================ FILE: .gitpod/drupal/ssh/instructions-template.md ================================================ # One-time public key setup 1. Press the OK button in the Terminal below and follow the instructions. 2. Open https://www.drupal.org/user 3. Click on "Git Access" 4. Create a Git username if you don't have one. 5. Click on "SSH keys", 6. Click on "Add a public key" 7. Copy the content below 8. Paste it inside "Key" field 9. Click on "Save" button. 10. Run in Gitpod terminal `.gitpod/drupal/ssh/04-confirm-ssh-setup.sh` ================================================ FILE: .gitpod/drupal/templates/git-exclude.template ================================================ # git ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ # Exclude the following directories for Drupal core development vendor sites/simpletest sites/default/settings.php ================================================ FILE: .gitpod/images/Dockerfile ================================================ FROM gitpod/workspace-base as workspace-base SHELL ["/bin/bash", "-c"] RUN sudo apt-get -qq update # Install dialog (interactive script) RUN sudo apt-get -qq install -y dialog # Install DDEV USER gitpod # Add DDEV’s GPG key to your keyring RUN curl -fsSL https://pkg.ddev.com/apt/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/ddev.gpg > /dev/null # Add DDEV releases to your package repository RUN echo "deb [signed-by=/etc/apt/keyrings/ddev.gpg] https://pkg.ddev.com/apt/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list >/dev/null # Update package information and install DDEV RUN sudo apt-get update && sudo apt-get install -y ddev # Install GitUI (terminal-ui for git) ARG GITUI_VERSION=v0.27.0 RUN wget https://github.com/extrawurst/gitui/releases/download/${GITUI_VERSION}/gitui-linux-x86_64.tar.gz -P /tmp RUN sudo tar xzf /tmp/gitui-linux-x86_64.tar.gz -C /usr/bin # Install LazyGit (terminal-ui for git) ARG LAZYGIT_VERSION=0.48.0 RUN wget https://github.com/jesseduffield/lazygit/releases/download/v${LAZYGIT_VERSION}/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz -P /tmp RUN tar -C /tmp -xf /tmp/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz RUN sudo install /tmp/lazygit /usr/local/bin # (get latest Minio version from https://dl.min.io/client/mc/release/linux-amd64/) # Install Minio client ARG MINIO_CLIENT_VERSION=mcli_20250221160046.0.0_amd64.deb RUN wget https://dl.min.io/client/mc/release/linux-amd64/${MINIO_CLIENT_VERSION} RUN sudo dpkg -i ${MINIO_CLIENT_VERSION} RUN sudo mv /usr/local/bin/mcli /usr/local/bin/mc # End workspace-base FROM scratch as drupalpod-gitpod-base SHELL ["/bin/bash", "-c"] COPY --from=workspace-base / / ================================================ FILE: .gitpod/images/push.sh ================================================ #!/bin/bash set -eu -o pipefail # if [ -n "$DEBUG_SCRIPT" ]; then # set -x # fi # Run `docker login` to authenticate and push new images to docker hub # Update /.gitpod.yml with the new image file # "%Y-%m-%d" TODAY=$(date +"%Y%m%d") REPO_NAME=drupalpod/drupalpod-gitpod-base DOCKER_REPO="$REPO_NAME":"$TODAY" DOCKER_REPO_LATEST="$REPO_NAME":latest echo "Pushing ${DOCKER_REPO}" set -x # Build only current architecture and load into docker # docker buildx build -t "${DOCKER_REPO}" --push --target=drupalpod-gitpod-base --platform=linux/amd64 . docker build --target drupalpod-gitpod-base -t "${DOCKER_REPO}" -t "${DOCKER_REPO_LATEST}" . docker image push "${DOCKER_REPO}" docker image push "${DOCKER_REPO_LATEST}" # docker run -it --rm bash # docker image inspect ================================================ FILE: .gitpod/utils/ddev-in-gitpod-setup.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ] || [ -n "$GITPOD_HEADLESS" ]; then set -x fi # Misc housekeeping before start ddev config global --instrumentation-opt-in=true ================================================ FILE: .gitpod/utils/env-setup.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi cd "${GITPOD_REPO_ROOT}"/.gitpod/utils/script-templates || exit # Create a phpstorm command sudo cp phpstorm.template.sh /usr/local/bin/phpstorm # Create a preview command sudo cp preview.template.sh /usr/local/bin/preview # Create a protect-my-git command sudo cp protect-my-git.template.sh /usr/local/bin/protect-my-git # Create php command (run php inside ddev container) sudo cp ddev-php.template.sh /usr/local/bin/php # Create drush command (run drush inside ddev container) sudo cp ddev-drush.template.sh /usr/local/bin/drush # Create yarn command (run yarn inside ddev container) sudo cp ddev-yarn.template.sh /usr/local/bin/yarn # Create composer command (run composer inside ddev container) sudo cp ddev-composer.template.sh /usr/local/bin/composer # Create node command (run composer inside ddev container) sudo cp ddev-node.template.sh /usr/local/bin/node # Create nvm command (run composer inside ddev container) sudo cp ddev-nvm.template.sh /usr/local/bin/nvm # Create npx command (run composer inside ddev container) sudo cp ddev-npx.template.sh /usr/local/bin/npx ================================================ FILE: .gitpod/utils/script-templates/ddev-composer.template.sh ================================================ #!/usr/bin/env bash echo "Notice: running 'composer $*' in ddev" ddev exec_d composer "$@" ================================================ FILE: .gitpod/utils/script-templates/ddev-drush.template.sh ================================================ #!/usr/bin/env bash echo "Notice: running 'drush $*' in ddev" ddev exec_d drush "$@" ================================================ FILE: .gitpod/utils/script-templates/ddev-node.template.sh ================================================ #!/usr/bin/env bash echo "Notice: running 'node $*' in ddev" ddev exec_d node "$@" ================================================ FILE: .gitpod/utils/script-templates/ddev-npx.template.sh ================================================ #!/usr/bin/env bash echo "Notice: running 'npx $*' in ddev" ddev exec_d npx "$@" ================================================ FILE: .gitpod/utils/script-templates/ddev-nvm.template.sh ================================================ #!/usr/bin/env bash echo "Notice: running 'nvm $*' in ddev" ddev exec_d nvm "$@" ================================================ FILE: .gitpod/utils/script-templates/ddev-php.template.sh ================================================ #!/usr/bin/env bash echo "Notice: running 'php $*' in ddev" ddev exec_d php "$@" ================================================ FILE: .gitpod/utils/script-templates/ddev-yarn.template.sh ================================================ #!/usr/bin/env bash echo "Notice: running 'yarn $*' in ddev" ddev exec_d yarn "$@" ================================================ FILE: .gitpod/utils/script-templates/phpstorm.template.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi if [ ! -x ~/.projector/configs/PhpStorm/run.sh ]; then echo "PhpStorm runner not found" && exit 1 fi # When port 9999 is ready - open that port in a new browser tab gp await-port 9999 && gp preview "$(gp url 9999)" --external & # Run PHPStorm ~/.projector/configs/PhpStorm/run.sh "$GITPOD_REPO_ROOT" ================================================ FILE: .gitpod/utils/script-templates/preview.template.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi # Preview port 8080 gp preview "$(gp url 8080)" ================================================ FILE: .gitpod/utils/script-templates/protect-my-git.template.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi # Remove access to user's Git credentials (restore by restart workspace) git config --global --unset credential.helper ================================================ FILE: .gitpod/utils/send-a-message-gcs.sh ================================================ #!/usr/bin/env bash # Get current user and current branch branch_user="$GITPOD_GIT_USER_NAME, $(git branch --show-current)" # Load env vars during prebuild using `gp env` command if [ -z "$IFTTT_TOKEN" ]; then eval "$(gp env -e | grep IFTTT_TOKEN)" fi # Load env vars during prebuild using `gp env` command if [ -z "$DP_GOOGLE_ACCESS_KEY" ]; then eval "$(gp env -e | grep DP_GOOGLE_ACCESS_KEY)" fi # Load env vars during prebuild using `gp env` command if [ -z "$DP_GOOGLE_SECRET" ]; then eval "$(gp env -e | grep DP_GOOGLE_SECRET)" fi # Establish connection with Google Cloud through Minio client mc config host add gcs https://storage.googleapis.com "$DP_GOOGLE_ACCESS_KEY" "$DP_GOOGLE_SECRET" # If there's a problem send the error code if mc find gcs/drupalpod/ready-made-envs.tar.gz; then message="Success: Google Cloud is ready" else message="Error: Envs file wasn't found, it will be recreated" fi # Send a message through IFTTT curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$branch_user\",\"value2\":\"$message\"}" https://maker.ifttt.com/trigger/drupalpod_prebuild_initiated/with/key/"$IFTTT_TOKEN" ================================================ FILE: .gitpod/utils/send-a-message-gitpod.sh ================================================ #!/usr/bin/env bash # Get current user and current branch branch_user="$GITPOD_GIT_USER_NAME, $(git branch --show-current)" # Load env vars during prebuild using `gp env` command if [ -z "$DP_READY_MADE_ENVS_URL" ]; then eval "$(gp env -e | grep DP_READY_MADE_ENVS_URL)" fi # Load env vars during prebuild using `gp env` command if [ -z "$IFTTT_TOKEN" ]; then eval "$(gp env -e | grep IFTTT_TOKEN)" fi # Check the status of ready-made envs file # https://stackoverflow.com/a/53358157/5754049 url_status=$(wget --server-response --spider --quiet "${DP_READY_MADE_ENVS_URL}" 2>&1 | awk 'NR==1{print $2}') # If there's a problem send the error code if [ "$url_status" = '200' ]; then message="100%" else message="Error: $url_status - $DP_READY_MADE_ENVS_URL" fi # Send a message through IFTTT curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$branch_user\",\"value2\":\"$message\"}" https://maker.ifttt.com/trigger/drupalpod_prebuild_initiated/with/key/"$IFTTT_TOKEN" ================================================ FILE: .gitpod/utils/set-base-environment.sh ================================================ #!/usr/bin/env bash if [ -n "$DEBUG_SCRIPT" ]; then set -x fi # Load default envs # export "$(grep -v '^#' "$GITPOD_REPO_ROOT"/.env | xargs -d '\n')" # Clone Drupal core repo mkdir -p "${GITPOD_REPO_ROOT}"/repos cd "${GITPOD_REPO_ROOT}"/repos && time git clone https://git.drupalcode.org/project/drupal.git ================================================ FILE: .gitpod.yml ================================================ image: drupalpod/drupalpod-gitpod-base:20250309 # DDEV and composer are running as part of the prebuild # when starting a workspace all docker images are ready tasks: - init: | .gitpod/utils/send-a-message-gcs.sh > /tmp/output1.txt .gitpod/utils/ddev-in-gitpod-setup.sh .gitpod/utils/set-base-environment.sh command: | # Temporary fix for wrong value of GITPOD_REPO_ROOT when opening a Gitpod snapshot # Todo: remove this when this issue is resolved - https://github.com/gitpod-io/gitpod/issues/9804 if [ "$GITPOD_REPO_ROOT" == '/workspace' ]; then export GITPOD_REPO_ROOT="$THEIA_WORKSPACE_ROOT" fi .gitpod/utils/ddev-in-gitpod-setup.sh .gitpod/utils/env-setup.sh .gitpod/drupal/ssh/01-check-private-ssh.sh .gitpod/drupal/drupalpod-setup/drupalpod-setup.sh # VScode xdebug extension vscode: extensions: # PHP extensions. - felixfbecker.php-debug - wongjn.php-sniffer - neilbrayfield.php-docblocker - bmewburn.vscode-intelephense-client - andrewdavidblum.drupal-smart-snippets # Twig extensions. - mblode.twig-language-2 # Help extensions. - drupal-mentoring.drupalpod-ext # Bash extensions. - timonwong.shellcheck - rogalmic.bash-debug ports: # Used by JS projects - port: 3000 onOpen: ignore # Used by DDEV - local db clients - port: 3306 name: Database description: Access for local database clients onOpen: ignore # Used by JS projects - port: 5000 onOpen: ignore # Used by MailHog - port: 8027 name: MailHog description: MailHog onOpen: ignore # Used by phpMyAdmin - port: 8036 name: phpMyAdmin description: phpMyAdmin onOpen: ignore # Direct-connect DDEV-webserver port that is the main port - port: 8080 name: website description: website onOpen: ignore # Ignore host https port - port: 8443 name: (not used) description: host https port onOpen: ignore # xdebug port - port: 9003 name: xdebug description: xdebug onOpen: ignore ================================================ FILE: .vscode/launch.json ================================================ { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "hostname": "0.0.0.0", "port": 9003, "pathMappings": { "/var/www/html": "${workspaceRoot}" } }, { "type": "bashdb", "request": "launch", "name": "Bash-Debug (simplest configuration)", "program": "${file}" } ] } ================================================ FILE: .vscode/settings.json ================================================ { "breadcrumbs.enabled": true, "css.validate": true, "diffEditor.ignoreTrimWhitespace": false, "editor.tabSize": 2, "editor.autoIndent": "full", "editor.insertSpaces": true, "editor.formatOnPaste": true, "editor.formatOnSave": false, "editor.renderWhitespace": "boundary", "editor.wordWrapColumn": 80, "editor.wordWrap": "off", "editor.detectIndentation": true, "editor.rulers": [ 80 ], "files.associations": { "*.inc": "php", "*.module": "php", "*.install": "php", "*.theme": "php", "*.profile": "php", "*.tpl.php": "php", "*.test": "php", "*.php": "php", "*.info": "ini", "*.html": "twig", }, "emmet.includeLanguages": { "twig": "html" }, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "html.format.enable": true, "html.format.wrapLineLength": 80, "redhat.telemetry.enabled": false, /* PHP Intelephense */ "php.validate.executablePath": "/usr/local/bin/php", "php.suggest.basic": false, /* phpSniffer settings */ "phpSniffer.executablesFolder": "vendor/bin", "phpSniffer.standard": "Drupal", /* php-docblocker settings */ "php-docblocker.gap": true, "php-docblocker.useShortNames": true, // Allow searching files that are in .gitignore "search.useIgnoreFiles": false, // Configure glob patterns for excluding files and folders in fulltext searches and quick open. Inherits all glob patterns from the `files.exclude` setting. "search.exclude": { "**/vendor": true, }, "workbench.startupEditor": "none", } ================================================ FILE: Drupal Core Development Composer Project.md ================================================ # Drupal Core Development Composer Project This is a Composer project template for developing Drupal core. It allows: - a clean git clone of Drupal core. - Composer dependencies of Drupal core are installed, so Drupal can be installed and run as normal. - other Composer packages you might want, such as Drush, Devel module, and Admin Toolbar module, can be installed too, but don't affect the composer files that are part of Drupal core. ## Installation To install a Drupal project for working on Drupal core: ``` $ composer create-project joachim-n/drupal-core-development-project ``` Composer will clone Drupal core into a 'repos/drupal' directory within the project, and then symlink that into the project when it installs Drupal core. Once the installation is complete, you can install Drupal as normal, either with `drush si` or with the web UI. ## Limitations During some Composer commands you may see multiple copies of this error message: > Could not scan for classes inside [Drupal class filename]. These are harmless and can be ignored. ## Developing Drupal core You can use the Drupal core git clone at 'repos/drupal/' in any way you like: create feature branches, clone from drupal.org issue forks, and so on. Changes you make to files in the git clone affect the project, since the git clone is symlinked into it. ### Managing the Composer project You can install any Composer packages you like, including Drupal contrib modules, without affecting the git clone of Drupal core. To work with Composer, you need to be in the root directory of the project. Changes to the git clone's composer.json will be taken into account by Composer. So for example, if pulling from the main branch of Drupal core changes Composer dependencies, and in particular if you change to a different core major or minor branch, you should run `composer update` on the project to install these. ### Running tests The following are required to run tests. #### PHPUnit configuration The simplest way to run tests with this setup is to put the phpunit.xml file in the project root and then run tests from there: $ vendor/bin/phpunit web/core/PATH-TO-TEST-FILE/TestFile.php To set this up, copy Drupal core's sample phpunit.xml file to the project root: $ cp web/core/phpunit.xml.dist phpunit.xml Then change the `bootstrap` attribute so the path is correct: ``` handle($request); diff --git a/update.php b/update.php index b65649c..02ffa22 100644 --- a/update.php +++ b/update.php @@ -21,7 +21,7 @@ if (drupal_valid_test_ua()) { gc_disable(); } -$kernel = new UpdateKernel('prod', $autoloader, FALSE); +$kernel = new UpdateKernel('prod', $autoloader, FALSE, __DIR__); $request = Request::createFromGlobals(); $response = $kernel->handle($request); ================================================ FILE: src/drush-commands-core-development/11/DevelopmentProjectCommands.php ================================================ true]) { if (!$options['cache-clear']) { $this->logger()->info(dt("Skipping cache-clear operation due to --no-cache-clear option.")); return true; } // CHANGE: Get the app root ourselves instead of using DRUPAL_ROOT. $app_root = $this->getAppRoot(); chdir($this->getAppRoot()); // We no longer clear APC and similar caches as they are useless on CLI. // See https://github.com/drush-ops/drush/pull/2450 $autoloader = $this->loadDrupalAutoloader(DRUPAL_ROOT); require_once DRUSH_DRUPAL_CORE . '/includes/utility.inc'; $request = Drush::bootstrap()->getRequest(); DrupalKernel::bootEnvironment(); // Avoid 'Only variables should be passed by reference' // CHANGE: Don't use DRUPAL_ROOT. $root = $app_root; $site_path = DrupalKernel::findSitePath($request); Settings::initialize($root, $site_path, $autoloader); // drupal_rebuild() calls drupal_flush_all_caches() itself, so we don't do it manually. // CHANGE: call our own version of drupal_rebuild(). $this->drupal_rebuild($autoloader, $request); $this->logger()->success(dt('Cache rebuild complete.')); } /** * Replacement for drupal_rebuild(). * * This passes the app root to DrupalKernel. */ function drupal_rebuild($class_loader, Request $request) { // Remove Drupal's error and exception handlers; they rely on a working // service container and other subsystems and will only cause a fatal error // that hides the actual error. restore_error_handler(); restore_exception_handler(); // Invalidate the container. // Bootstrap up to where caches exist and clear them. // CHANGE: Pass the correct app root to DrupalKernel. $kernel = new DrupalKernel('prod', $class_loader, TRUE, $this->getAppRoot()); $kernel->setSitePath(DrupalKernel::findSitePath($request)); $kernel->invalidateContainer(); $kernel->boot(); $kernel->preHandle($request); // Ensure our request includes the session if appropriate. if (PHP_SAPI !== 'cli') { $request->setSession($kernel->getContainer()->get('session')); } drupal_flush_all_caches($kernel); // Disable recording of cached pages. \Drupal::service('page_cache_kill_switch')->trigger(); // Restore Drupal's error and exception handlers. // @see \Drupal\Core\DrupalKernel::boot() set_error_handler('_drupal_error_handler'); set_exception_handler('_drupal_exception_handler'); } /** * Gets the app root. * * @return string * The app root. */ protected function getAppRoot(): string { // This core belongs to the project template, so we can hardcode the // location of this file relative to the project root, and the scaffold // location defined in the project's composer.json. return dirname(__DIR__, 3) . '/web'; } } ================================================ FILE: src/drush-commands-core-development/12/DevelopmentProjectCommands.php ================================================ get('loader') ); return $commandHandler; } /** * @hook replace-command cache:rebuild */ public function rebuild($options = ['cache-clear' => true]) { if (!$options['cache-clear']) { $this->logger()->info(dt("Skipping cache-clear operation due to --no-cache-clear option.")); return true; } // CHANGE: Get the app root ourselves instead of using DRUPAL_ROOT. $app_root = $this->getAppRoot(); chdir($this->getAppRoot()); // We no longer clear APC and similar caches as they are useless on CLI. // See https://github.com/drush-ops/drush/pull/2450 require_once DRUSH_DRUPAL_CORE . '/includes/utility.inc'; $request = Drush::bootstrap()->getRequest(); DrupalKernel::bootEnvironment(); // Avoid 'Only variables should be passed by reference' // CHANGE: Don't use DRUPAL_ROOT. $root = $app_root; $site_path = DrupalKernel::findSitePath($request); Settings::initialize($root, $site_path, $this->autoloader); // drupal_rebuild() calls drupal_flush_all_caches() itself, so we don't do it manually. // CHANGE: call our own version of drupal_rebuild(). $this->drupal_rebuild($this->autoloader, $request); $this->logger()->success(dt('Cache rebuild complete.')); } /** * Replacement for drupal_rebuild(). * * This passes the app root to DrupalKernel. */ function drupal_rebuild($class_loader, Request $request) { // Remove Drupal's error and exception handlers; they rely on a working // service container and other subsystems and will only cause a fatal error // that hides the actual error. restore_error_handler(); restore_exception_handler(); // Invalidate the container. // Bootstrap up to where caches exist and clear them. // CHANGE: Pass the correct app root to DrupalKernel. $kernel = new DrupalKernel('prod', $class_loader, TRUE, $this->getAppRoot()); $kernel->setSitePath(DrupalKernel::findSitePath($request)); $kernel->invalidateContainer(); $kernel->boot(); $kernel->preHandle($request); // Ensure our request includes the session if appropriate. if (PHP_SAPI !== 'cli') { $request->setSession($kernel->getContainer()->get('session')); } drupal_flush_all_caches($kernel); // Disable recording of cached pages. \Drupal::service('page_cache_kill_switch')->trigger(); // Restore Drupal's error and exception handlers. // @see \Drupal\Core\DrupalKernel::boot() set_error_handler('_drupal_error_handler'); set_exception_handler('_drupal_exception_handler'); } /** * Gets the app root. * * @return string * The app root. */ protected function getAppRoot(): string { // This core belongs to the project template, so we can hardcode the // location of this file relative to the project root, and the scaffold // location defined in the project's composer.json. return dirname(__DIR__, 3) . '/web'; } } ================================================ FILE: src/drush-commands-core-development/13/DevelopmentProjectCommands.php ================================================ get('loader') ); return $commandHandler; } /** * @hook replace-command cache:rebuild */ public function rebuild($options = ['cache-clear' => true]) { if (!$options['cache-clear']) { $this->logger()->info(dt("Skipping cache-clear operation due to --no-cache-clear option.")); return true; } // CHANGE: Get the app root ourselves instead of using DRUPAL_ROOT. $app_root = $this->getAppRoot(); chdir($this->getAppRoot()); // We no longer clear APC and similar caches as they are useless on CLI. // See https://github.com/drush-ops/drush/pull/2450 require_once DRUSH_DRUPAL_CORE . '/includes/utility.inc'; $request = Drush::bootstrap()->getRequest(); DrupalKernel::bootEnvironment(); // Avoid 'Only variables should be passed by reference' // CHANGE: Don't use DRUPAL_ROOT. $root = $app_root; $site_path = DrupalKernel::findSitePath($request); Settings::initialize($root, $site_path, $this->autoloader); // drupal_rebuild() calls drupal_flush_all_caches() itself, so we don't do it manually. // CHANGE: call our own version of drupal_rebuild(). $this->drupal_rebuild($this->autoloader, $request); $this->logger()->success(dt('Cache rebuild complete.')); } /** * Replacement for drupal_rebuild(). * * This passes the app root to DrupalKernel. */ function drupal_rebuild($class_loader, Request $request) { // Remove Drupal's error and exception handlers; they rely on a working // service container and other subsystems and will only cause a fatal error // that hides the actual error. restore_error_handler(); restore_exception_handler(); // Invalidate the container. // Bootstrap up to where caches exist and clear them. // CHANGE: Pass the correct app root to DrupalKernel. $kernel = new DrupalKernel('prod', $class_loader, TRUE, $this->getAppRoot()); $kernel->setSitePath(DrupalKernel::findSitePath($request)); $kernel->invalidateContainer(); $kernel->boot(); $kernel->preHandle($request); // Ensure our request includes the session if appropriate. if (PHP_SAPI !== 'cli') { $request->setSession($kernel->getContainer()->get('session')); } drupal_flush_all_caches($kernel); // Disable recording of cached pages. \Drupal::service('page_cache_kill_switch')->trigger(); // Restore Drupal's error and exception handlers. // @see \Drupal\Core\DrupalKernel::boot() set_error_handler('_drupal_error_handler'); set_exception_handler('_drupal_exception_handler'); } /** * Gets the app root. * * @return string * The app root. */ protected function getAppRoot(): string { // This core belongs to the project template, so we can hardcode the // location of this file relative to the project root, and the scaffold // location defined in the project's composer.json. return dirname(__DIR__, 3) . '/web'; } } ================================================ FILE: src/vscode-extension/drupalpod-ext/.eslintrc.json ================================================ { "root": true, "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 6, "sourceType": "module" }, "plugins": [ "@typescript-eslint" ], "rules": { "@typescript-eslint/naming-convention": "warn", "@typescript-eslint/semi": "warn", "curly": "warn", "eqeqeq": "warn", "no-throw-literal": "warn", "semi": "off" }, "ignorePatterns": [ "out", "dist", "**/*.d.ts" ] } ================================================ FILE: src/vscode-extension/drupalpod-ext/.vscode/extensions.json ================================================ { // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ "dbaeumer.vscode-eslint" ] } ================================================ FILE: src/vscode-extension/drupalpod-ext/.vscode/launch.json ================================================ // A launch configuration that compiles the extension and then opens it inside a new window // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 { "version": "0.2.0", "configurations": [ { "name": "Run Extension", "type": "extensionHost", "request": "launch", "args": [ "--extensionDevelopmentPath=${workspaceFolder}" ], "outFiles": [ "${workspaceFolder}/out/**/*.js" ], "preLaunchTask": "${defaultBuildTask}" }, { "name": "Extension Tests", "type": "extensionHost", "request": "launch", "args": [ "--extensionDevelopmentPath=${workspaceFolder}", "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" ], "outFiles": [ "${workspaceFolder}/out/test/**/*.js" ], "preLaunchTask": "${defaultBuildTask}" } ] } ================================================ FILE: src/vscode-extension/drupalpod-ext/.vscode/settings.json ================================================ // Place your settings in this file to overwrite default and user settings. { "files.exclude": { "out": false // set this to true to hide the "out" folder with the compiled JS files }, "search.exclude": { "out": true // set this to false to include "out" folder in search results }, // Turn off tsc task auto detection since we have the necessary tasks as npm scripts "typescript.tsc.autoDetect": "off", "editor.insertSpaces": true } ================================================ FILE: src/vscode-extension/drupalpod-ext/.vscode/tasks.json ================================================ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format { "version": "2.0.0", "tasks": [ { "type": "npm", "script": "watch", "problemMatcher": "$tsc-watch", "isBackground": true, "presentation": { "reveal": "never" }, "group": { "kind": "build", "isDefault": true } } ] } ================================================ FILE: src/vscode-extension/drupalpod-ext/.vscodeignore ================================================ .vscode/** .vscode-test/** out/test/** src/** .gitignore .yarnrc vsc-extension-quickstart.md **/tsconfig.json **/.eslintrc.json **/*.map **/*.ts ================================================ FILE: src/vscode-extension/drupalpod-ext/CHANGELOG.md ================================================ # Change Log All notable changes to the "drupalpod-ext" extension will be documented in this file. Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. ## [Unreleased] - Initial release ================================================ FILE: src/vscode-extension/drupalpod-ext/README.md ================================================ # DrupalPod Extension Provides a Contribution Guide for using [DrupalPod](https://github.com/shaal/DrupalPod) on startup or by using the `drupalpod.ext-start` command in the Command Palette. The extension should be installed automatically by GitPod (once development is complete). To prevent the Contribution Guide from displaying when you start your workspace, you can add `"drupalpod.hideOnStartup": true` to `.vscode/settings.json`. ## Contribute * Run `yarn install` * Make your awesome changes and unit tests. * Run `yarn package` to build the VISX file in the current working directory. * Uninstall the extension completely from your workspace: * Press the "Extensions" button on the left. * Press the "Manage" button (Gear icon). * Click the "Uninstall" option from the context menu. * Reload Gitpod * Install the extension by VISX * Press the "Extensions" button on the left. * Press the "Views and More Actions..." button ("..." icon). * Click "Install from VISX..." option from the context menu. * Browse to or provide the directory path `/workspace/DrupalPod/src/vscode-extension/drupalpod-ext/ and choose the VISX file to install. ## Publish TODO: Should be done via a GitHub Action. * Update the version in package.json * Package a new VISX * Publish the VISX on OpenVsx ================================================ FILE: src/vscode-extension/drupalpod-ext/package.json ================================================ { "name": "drupalpod-ext", "displayName": "DrupalPod", "description": "", "version": "0.0.2", "license": "MIT", "engines": { "vscode": "^1.57.1" }, "categories": [ "Other" ], "activationEvents": [ "onCommand:drupalpod-ext.start", "onStartupFinished" ], "main": "./out/extension.js", "contributes": { "commands": [ { "command": "drupalpod-ext.start", "title": "Getting Started Contributing with DrupalPod", "category": "Drupal" } ], "configuration": { "title": "DrupalPod", "properties": { "drupalpod.hideOnStartup": { "type": "boolean", "default": false, "description": "Hides the Drupal Contributions startup screen from appearing when DrupalPod starts." } } } }, "repository": { "type": "git", "url": "https://github.com/shaal/DrupalPod", "directory": "src/drupalpod-ext" }, "publisher": "drupal-mentoring", "scripts": { "vscode:prepublish": "npm run compile", "package": "vsce package", "compile": "tsc -p ./", "watch": "tsc -watch -p ./", "pretest": "npm run compile && npm run lint", "lint": "eslint src --ext ts", "test": "node ./out/test/runTest.js" }, "devDependencies": { "@types/glob": "^7.1.3", "@types/mocha": "^8.2.2", "@types/node": "14.x", "@types/vscode": "~1.57.1", "@typescript-eslint/eslint-plugin": "^4.26.0", "@typescript-eslint/parser": "^4.26.0", "eslint": "^7.27.0", "glob": "^7.1.7", "mocha": "^8.4.0", "ovsx": "^0.2.0", "typescript": "^4.3.2", "vsce": "^1.95.1", "vscode-test": "^1.5.2" } } ================================================ FILE: src/vscode-extension/drupalpod-ext/src/extension.ts ================================================ import * as vscode from 'vscode'; import { getHelpContent } from './help-content'; export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.commands.registerCommand('drupalpod-ext.start', () => { const panel = vscode.window.createWebviewPanel( 'drupalpod-ext', 'Contribution Guide', vscode.ViewColumn.One, {} ); panel.webview.html = getHelpContent(); }) ); const config = vscode.workspace.getConfiguration('drupalpod'); if (!config.has('hideOnStartup') || !config.get('hideOnStartup')) { await vscode.commands.executeCommand('drupalpod-ext.start'); } } // this method is called when your extension is deactivated export function deactivate() {} ================================================ FILE: src/vscode-extension/drupalpod-ext/src/help-content.ts ================================================ /** * Provides base help content structure as a string. * * @todo refactor this when implementing a javascript tour using messages to invoke vscode commands. */ export function getHelpContent(): string { return ` Getting Started Contributing with DrupalPod

Getting Started with DrupalPod

  1. ⬇️ Wait until the “Terminal” completes its operations. Drupal will open in the panel when it is complete ➡️
  2. ➡️ You can use the “Simple Browser” to use Drupal. Go ahead and install Drupal now if it is not installed.
    • Note: You will use db as the username, password, database name and host (Advanced Options).
  3. ⬅️ Press the “Explorer” button. You can access and modify files in Drupal core and contrib by going expanding the "repos" directory.
  4. ⬅️ Press the “Remote Explorer” button. It shows the services provided by DrupalPod.
    • Find the “8080” item in the list.
    • Press the “Globe" button to open Drupal in a new tab or window.
    • Press the “Open Preview” button to open Drupal in the Simple Browser as a panel in the editor.
  5. ⬇️ You can use the “Terminal” below to run git, ddev and drush. But first we need to setup SSH access if you have not done so already.
    • Run the following command in the Terminal: .gitpod/drupal/ssh/00-interactive-ssh-setup.sh and then follow the instructions in the tab that appears.

What's Next?

  • Create a drupal.org user account.
  • Join us on Drupal Slack in the #contribute channel.
  • Find a Contributor Task such as
    • Manually test an issue
    • Write a patch or contribute to an issue fork
    • Write an automated test
    • Run automated tests:
      • Nightwatch: ddev nightwatch
      • PHPUnit: ddev phpunit
  • Find your role or skill to learn more about how to contribute, or ask if anyone needs some help on an issue in #contribute.
`; } ================================================ FILE: src/vscode-extension/drupalpod-ext/src/test/runTest.ts ================================================ import * as path from 'path'; import { runTests } from 'vscode-test'; async function main() { try { // The folder containing the Extension Manifest package.json // Passed to `--extensionDevelopmentPath` const extensionDevelopmentPath = path.resolve(__dirname, '../../'); // The path to test runner // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, './suite/index'); // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath }); } catch (err) { console.error('Failed to run tests'); process.exit(1); } } main(); ================================================ FILE: src/vscode-extension/drupalpod-ext/src/test/suite/extension.test.ts ================================================ import * as assert from 'assert'; // You can import and use all API from the 'vscode' module // as well as import your extension to test it import * as vscode from 'vscode'; // import * as myExtension from '../../extension'; suite('Extension Test Suite', () => { vscode.window.showInformationMessage('Start all tests.'); test('Sample test', () => { assert.strictEqual(-1, [1, 2, 3].indexOf(5)); assert.strictEqual(-1, [1, 2, 3].indexOf(0)); }); }); ================================================ FILE: src/vscode-extension/drupalpod-ext/src/test/suite/index.ts ================================================ import * as path from 'path'; import * as Mocha from 'mocha'; import * as glob from 'glob'; export function run(): Promise { // Create the mocha test const mocha = new Mocha({ ui: 'tdd', color: true }); const testsRoot = path.resolve(__dirname, '..'); return new Promise((c, e) => { glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { if (err) { return e(err); } // Add files to the test suite files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); try { // Run the mocha test mocha.run(failures => { if (failures > 0) { e(new Error(`${failures} tests failed.`)); } else { c(); } }); } catch (err) { console.error(err); e(err); } }); }); } ================================================ FILE: src/vscode-extension/drupalpod-ext/tsconfig.json ================================================ { "compilerOptions": { "module": "commonjs", "target": "es6", "outDir": "out", "lib": [ "es6" ], "sourceMap": true, "rootDir": "src", "strict": true /* enable all strict type-checking options */ /* Additional Checks */ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ }, "exclude": [ "node_modules", ".vscode-test" ] }