acobster/wp-cli-yaml-fixtures

定义WordPress数据库快照为简单的YAML文件

安装次数: 3,278

依赖关系: 2

建议者: 0

安全: 0

星星: 3

关注者: 3

分支: 1

开放性问题: 10

类型:wp-cli-command

v0.7.0 2020-08-05 16:45 UTC

README

Build Status

一个WP-CLI命令,用于在YAML文件中描述WordPress数据库内容,并从中导入。专为快速测试和构建脚手架而构建。

入门指南

安装并激活此仓库作为插件。

git clone git@github.com:acobster/wp-yaml-fixtures.git ./wp-content/plugins/yaml-fixtures
wp plugin activate yaml-fixtures

设置YAML文件。

---
# my-example.yaml
name: My Test Site
description: Just another database described in YAML

users:
- email: admin@example.com
  login: admin
  role: administrator
  password: meep

posts:
- title: My Blog Post
  type: post
  
  content: 'Lorem ipsum dolor sit amet'

  terms:
    category:
    - special

taxonomies:
  category:
  - name: Special
  - name: Snowflake
  - name: Unicorn
...

运行WP-CLI命令。

wp fixture install my-example.yaml

💥 现在您的数据库已经清理并填充了新数据。 💥

YAML每日必读!

以下是一个更深入示例,说明您可以在YAML中描述哪些内容

---
name: My Test Site
description: Just another database described in YAML

# tell me what **not** to delete
blank_slate:
  preserve_users:
  - me
  - myself
  - i@email.me
  - 123 # ID

# insert users
users:
- email: admin@example.com
  login: admin
  role: administrator
  password: meep
- email: johndoe@example.com
  login: johndoe
  role: editor
  password: mop
  meta:
    my_info: 'This info is v important'
    moar_info: 'here iz sum moar infoz'

# insert arbitrary post data
posts:
- title: My Blog Post
  type: post

- title: Page with a Custom Slug
  slug: yep-this-heres-a-completely-custom-slug
  type: page
  
  content: |
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    Nunc haec primum fortasse audientis servire debemus.

    Sumenda potius quam expetenda.

    Mihi quidem Homerus huius modi quiddam vidisse videatur in iis,
    quae de Sirenum cantibus finxerit.
    Ut in geometria, prima si dederis, danda sunt omnia.

  # specify any number of terms, across taxonomies
  terms:
    page_type:
    - custom-term-slug
    category:
    - special

- title: A Post with Some Meta Fields
  type: page
  # oh and I want to nest this page
  parent: bar
  
  # specify arbitrary meta fields
  meta:
    my_custom_field: Some custom value

    # specify multiple values for the same key!
    # these will be inserted as three wp_postmeta rows
    another_field:
    - 'value #1'
    - 'value #2'
    - 'value #3'

  terms:
    page_type:
    - custom-term-slug
    - another
    - and-another

# Define taxonomy terms
taxonomies:
  category:
  - name: Special
  - name: Snowflake
  - name: Unicorn
  
  page_type:
  - name: Page Type
    slug: custom-term-slug
  - name: Another Page Type
    slug: another
  - name: And Another
...

支持

WP YAML Fixtures支持WordPress 4.8+和PHP 7.0至7.2.x。PHP 7.3的支持正在开发中。

许可证

MIT