Skip to content

Commit

Permalink
Merge pull request #3 from netglue/feature/write-types
Browse files Browse the repository at this point in the history
Download, Upload and Diff Document Types
  • Loading branch information
gsteel committed Sep 2, 2021
2 parents 5dd1f9e + 9f029c1 commit 9b5dce7
Show file tree
Hide file tree
Showing 42 changed files with 2,426 additions and 156 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 0.4.0 - TBD

### Added

- `primo:types:download` - A console command that can download all document type definitions to local storage using the Prismic Custom Types API.
- `primo:types:upload` - A console command that can upload local document type definitions to the Prismic Custom Types API.
- `primo:types:diff` - A console command that can show a colour diff between local and remote document type definitions.
- To facilitate the commands above, a new persistence abstraction has been introduced for local and remote storage, including a dependency on [`netglue/prismic-doctype-client`](https://github.com/netglue/prismic-doctype-client).

### Changed

- Factories that produce some kind of HTTP API Client, now make use of [`php-http/discovery`](https://github.com/php-http/discovery) for finding dependencies, but still prefer those that have been configured in the container.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 0.3.0 - 2021-03-03

### Added
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,36 @@ return [
The lib currently lacks documentation and a decent test suite but there is an annotated example in `./example`. When it comes to
configuring as part of a Mezzio app, please examine `./src/ConfigProvider.php` for more information.

### Upload, Download and Diff Document Models Against the Remote Repository

If you have setup the "Custom Types API" and have a valid access token to use it, adding the following to your configuration along with the contents of `CustomTypeApiConfigProvider` will configure 3 additional commands that will enable you to upload, download and diff changes between your local and remote definitions:

```php
<?php
// Local Configuration
return [
'primo' => [

// ...

'custom-type-api' => [
'token' => 'an access token retrieved from repository settings',
'repository' => 'my-repo', // The repo name such as "my-repo" as opposed to the full url or "my-repo.prismic.io"
],

// ...
],
];
```

Once configured, you can issue

- `primo:types:download` to download all JSON definitions to your local dist directory, or add a `type` argument to download just one of them.
- `primo:types:upload` to upload locally defined definitions to the remote types api make them immediately available in your repository. Again, a `type` argument will process a single definition.
- `primo:types:diff` will produce colourised diffs in your console showing the changes between local and remote.

These tools make use of [`netglue/prismic-doctype-client`](https://github.com/netglue/prismic-doctype-client), so check that out if you'd like some more information, also [link to the Prismic Custom Types API Docs](https://prismic.io/docs/technologies/custom-types-api).

### Commands that Query a Repository

Theres also some commands for getting information from a repository. These commands are opt-in. During installation there's a config
Expand Down
17 changes: 14 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,24 @@
"require": {
"php": "^7.3||~8.0",
"ext-json": "*",
"netglue/prismic-client": "^0",
"netglue/prismic-client": "^0.7",
"netglue/prismic-doctype-client": "^0.1.0",
"php-http/discovery": "^1.14",
"psr/container": "^1.0||^2.0",
"symfony/console": "^5.1"
"psr/http-client": "^1.0",
"psr/http-client-implementation": "*",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"sebastian/diff": "^4.0",
"symfony/console": "^5.1",
"webmozart/assert": "^1.10"
},
"require-dev": {
"ext-curl": "*",
"doctrine/coding-standard": "^9.0.0",
"laminas/laminas-config-aggregator": "^1.5",
"laminas/laminas-diactoros": "^2.5",
"laminas/laminas-servicemanager": "^3.7",
"php-http/curl-client": "^2.2",
"phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-master",
Expand All @@ -45,7 +55,8 @@
"laminas": {
"config-provider": [
"Primo\\Cli\\ConfigProvider",
"Primo\\Cli\\ApiToolsConfigProvider"
"Primo\\Cli\\ApiToolsConfigProvider",
"Primo\\Cli\\CustomTypeApiConfigProvider"
]
}
},
Expand Down
Loading

0 comments on commit 9b5dce7

Please sign in to comment.