-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VACMS-15893 Add setup for CM Document export/import.
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ node: 1 | |
paragraph: 1 | ||
taxonomy: 1 | ||
modules: 1 | ||
export_location: va_gov_migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Export directory for Content Model Documentation document exports | ||
|
||
This directory is the temporary storage for CM Documents exported locally and | ||
then imported to Prod. Once they have been imported on prod, they are safe to | ||
be deleted from here. | ||
|
||
We should be "safe" removing anything that is more than 2 weeks old (to cover thngs like Holiday code freezes). |
63 changes: 63 additions & 0 deletions
63
...uments/adminzZzstructurezZzcm-documentzZzprocesszZz125zZzimporting-site-documentation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
uuid: 1b66dd91-8f61-45ec-9d4a-df64c3761a4b | ||
langcode: en | ||
type: cm_document | ||
bundle: cm_document | ||
id: '125' | ||
dependencies: | ||
config: | ||
- cm_document.cm_document_type.cm_document | ||
- field.field.cm_document.cm_document.field_data_pulled_from | ||
- field.field.cm_document.cm_document.field_data_pushed_to | ||
- field.field.cm_document.cm_document.field_diagram | ||
- field.field.cm_document.cm_document.field_links_to_design | ||
- field.field.cm_document.cm_document.field_links_to_research | ||
- field.field.cm_document.cm_document.field_link_to_cms_design_system | ||
- field.field.cm_document.cm_document.field_link_to_va_design_system | ||
- field.field.cm_document.cm_document.field_other_links | ||
- field.field.cm_document.cm_document.field_related_knowledgebase | ||
- field.field.cm_document.cm_document.field_screenshots | ||
- field.field.cm_document.cm_document.field_stakeholders | ||
entity: | ||
- 'user:user:efa9900b-7446-41bf-b6a9-a99287ae2235' | ||
fields: | ||
vid: '183' | ||
revision_created: '1698441703' | ||
revision_user: | ||
target_id: '1215' | ||
_entity: 'user:user:efa9900b-7446-41bf-b6a9-a99287ae2235' | ||
revision_log_message: 'Adding diagram.' | ||
status: '1' | ||
user_id: | ||
target_id: '1215' | ||
_entity: 'user:user:efa9900b-7446-41bf-b6a9-a99287ae2235' | ||
name: 'Importing site documentation' | ||
documented_entity: site.process | ||
notes: | ||
value: "<h3>Exporting</h3>\r\n\r\n<p>Exporting content model documents can be done using Drush to export them as yml files.<br />\r\nThe key to exports is the entity id.</p>\r\n\r\n<ol>\r\n\t<li>Visit the config page for the module and set the machine name for the local<br />\r\n\tcustom module that you want to contain the yml files for any exported CM Documents.</li>\r\n\t<li>Create or edit a CM Document. Save your work</li>\r\n\t<li>Hover over the \"edit\" tab to reveal the id of the CM Document.</li>\r\n\t<li>In your terminal type drush content-model-documentation:export <id><br />\r\n\tA yml file was just created in your local module. at <local>/cm_documents/<page>.yml</li>\r\n\t<li>Commit this export file like any other. (repeat steps as needed)</li>\r\n</ol>\r\n\r\n<h3>Importing</h3>\r\n\r\n<p>The key to importing is the alias of the exported page.</p>\r\n\r\n<h4>Import using hook_update_n()</h4>\r\n\r\n<ol>\r\n\t<li>In your local module (usually the same one that is used for saving the exports)<br />\r\n\tadd or open the .install file.</li>\r\n\t<li>Gather the aliases from the pages you want to import (not including the domain).</li>\r\n\t<li>Add the something similar to this to the .install file.</li>\r\n</ol>\r\n\r\n<blockquote>\r\n<p>/**<br />\r\n * Import some CM Documents.<br />\r\n */<br />\r\nfunction va_gov_migrate_update_9017() {<br />\r\n $cm_documents_to_import = [ '/admin/structure/types/manage/promo_banner/document', '/admin/structure/types/manage/full_width_banner_alert/document',<br />\r\n];</p>\r\n\r\n<p>// Use TRUE if it is a new CM Document.<br />\r\n// Use FALSE if its an update to an existing CM Document<br />\r\n$strict = TRUE;<br />\r\nreturn CmDocumentImport::import($cm_documents_to_import, $strict);<br />\r\n}</p>\r\n</blockquote>\r\n\r\n<p>The $strict determines whether the update is considered a failure if any of the<br />\r\nCM Documents do not import. TRUE will cause the hook_update to consider a failure if any of the imports get rejected. FALSE will allow the rejections to happen but still<br />\r\nconsider the update a success.</p>\r\n\r\n<ol>\r\n\t<li>WHen drush updb is run, the content will create new entities or update existing.</li>\r\n</ol>\r\n\r\n<p>What causes an import to get rejected?</p>\r\n\r\n<ul>\r\n\t<li>Timing. If you export a CM Document on Monday, a coworker edits the same<br />\r\n\tCM Document on Tuesday, and then you try to import your changed on Friday, they will get rejected so that your changes do not overwrite the changes made on Tuesday.</li>\r\n</ul>\r\n\r\n<h4>Import using Drush</h4>\r\n\r\n<p>If you did not want to use a hook_update_n() to deploy your changes, you can use Drush.</p>\r\n\r\n<ol>\r\n\t<li>Find the alias of the CM Document that you want to import.</li>\r\n\t<li>Use the alias in the command drush content-model-documentation:import '/alias/of/the/cm-document'</li>\r\n</ol>\r\n" | ||
format: rich_text | ||
created: '1698441103' | ||
changed: '1698441703' | ||
revision_translation_affected: { } | ||
revision_default: '1' | ||
metatag: { } | ||
field_data_pulled_from: { } | ||
field_data_pushed_to: { } | ||
field_diagram: | ||
- | ||
title: 'Workflow for deploying documentation' | ||
diagram: "flowchart TD\r\n A[Add your code] --> B[Write your CM Document locally]\r\n B --> C[Grab the ID of the document]\r\n C -->D[Use ID in Drush export command]\r\n D -->E[Copy the alias]\r\n E -->F[Add hook_update_n to va_gov_migrate using the alias]\r\n F -->G[Commit your code]" | ||
caption: "The workflow is: \r\nAdd your code. Write your CM Document locally. Grab the ID of the document. Use ID in Drush export command. Copy the alias. Add hook_update_n to va_gov_migrate using the alias. Commit your code." | ||
key: '' | ||
show_code: '1' | ||
field_links_to_design: { } | ||
field_links_to_research: { } | ||
field_link_to_cms_design_system: { } | ||
field_link_to_va_design_system: { } | ||
field_other_links: | ||
- | ||
uri: 'https://www.drupal.org/project/content_model_documentation' | ||
title: 'Content Model Documentation module project page (same as README in the module)' | ||
options: { } | ||
field_related_knowledgebase: { } | ||
field_screenshots: { } | ||
field_stakeholders: { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters