newloong/bedrock

WordPress 模板,配备现代开发工具,易于配置,以及改进的文件夹结构

安装: 4

依赖: 0

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 0

类型:项目


README

有关堆栈的说明,请参阅 roots/bedrock 的 README。

要求

使用 fontawesome 注册表进行身份验证

您需要一个身份验证令牌,我们已经在 LastPass/1Password 中添加了一个共享令牌。

npm config set "//npm.fontawesome.com/:_authToken" <API-KEY>

Visual Studio Code 推荐扩展

使用 DDEV 进行本地项目开发

如果您使用的是 Windows,您应该阅读最新的 DDEV 文档和运行建议。您需要从 DDEV 容器内部运行所有 composer、npm、robo 和 dep 命令。请记住,使用 ddev auth ssh 将您的 SSH 密钥发送到容器。

设置和运行项目

# Clone the repository and install the development dependencies.
git clone --recursive git@github.com:generoi/bedrock.git gdsbedrock
cd gdsbedrock

# Install composer dependencies and development tools (vendor folder)
composer install:development

# The repo uses `npm` workspaces so you you should run commands from root of
# project.
npm run install
npm run build:production

# Start the container
ddev start

# Fetch the remote database
./vendor/bin/robo db:pull @production

# Login as admin
ddev wp login create <user>
wp @production login create <user>

其他有用任务

# Fetch the remote files (we also use a nginx fallback redirect for missing
# files)
./vendor/bin/robo files:pull @production

# Importing database from a sql dump
ddev import-db < dump.sql

# Create a database dump and import it
./vendor/bin/robo db:export @ddev
./vendor/bin/robo db:import @ddev

# Run tests which also prompts attempt to fix lint errors automatically.
./vendor/bin/robo test

# To see all tasks available
./vendor/bin/robo
./vendor/bin/dep
./vendor/bin/wp

NPM

# The root `package.json` delegates all scripts with a `--workspaces` flag
# so no flags is the same as
npm run build:production -ws
npm run build:production -w gds

# To install/remove a package you need to explicitly add the flag
npm install postcss-preset-env --save-dev -ws

使用 GitHub Actions 部署

转到 GitHub Actions deploy_production.yml 工作流程并触发部署。

您还可以从命令行触发工作流程。

./vendor/bin/robo deploy:production
./vendor/bin/robo deploy:staging --branch=patch-1
./vendor/bin/robo deploy:staging --log_level='-vvv'

# You can still use `dep` directly like described in the section below
./vendor/bin/dep cache:clear production

从本地部署

请参阅 deployer-genero 并运行 ./vendor/bin/dep 以查看所有可用命令。

# Deploy to staging/production
./vendor/bin/dep deploy staging
./vendor/bin/dep deploy production

# Clear all caches on production
./vendor/bin/dep cache:clear production
# Clear only WP Super Cache cache
./vendor/bin/dep cache:clear:wpsc production

# Open a shell on production server
./vendor/bin/dep ssh production

# Rollback a failed deploy
./vendor/bin/dep rollback production

测试

PHPUnit 单元测试

测试需要一个数据库,因此它们需要在 ddev 中运行,使用 wp serve 或有可用的本地数据库。

ddev composer phpunit

Playwright E2E 测试

# Install dependencies
npm run e2e:install

# Run against ddev environment
npm run e2e:test

# Run it against production
URL=https://gdsbedrock.kinsta.cloudd npm run e2e:test

创建一个新的项目和 Git 仓库

注意:如果可能,请将项目名称和仓库名设置为使用网站的域名。例如:www.my-site.fi => my-site。这将在未来配置所有不同环境时有所帮助。

  1. 在您的新项目文件夹中创建一个新项目

    # Prompt, create and enter directory
    echo 'Project directory:'; read project; composer create-project --keep-vcs --repository-url="https://packagist.minasithil.genero.fi" generoi/bedrock:dev-master $project; cd $project;
    
    # Just create
    composer create-project --keep-vcs --repository-url="https://packagist.minasithil.genero.fi" generoi/bedrock:dev-master <project-dir>
    
    # If you cloned the repo rather than used `create-project` you'll need to:
    # 1. You need to first install robo.
    composer install:development
    # 2. replace the placeholder names with a project machine name.
    ./vendor/bin/robo search:replace
  2. 设置 DDEV 容器

    ddev start
  3. 设置测试/生产环境

    # Configure the environment
    vim wp-cli.yml
    vim robo.yml
    
    # Prep the remote environment
    ./vendor/bin/dep setup staging
    
    # Make a first deployment (this will fail due to there not being any database)
    ./vendor/bin/dep setup staging
    
    # Deploy your code, files and database
    ./vendor/bin/robo db:push @staging
    ./vendor/bin/robo files:push @staging
    
    # Deploy once more with database available
    ./vendor/bin/dep deploy staging
  4. 设置 GitHub Actions、E2E 测试等。