xmlsquad/xml-authoring-project

结构化的目录,用于创建、读取、更新或删除xml文件。

v0.3.3 2018-10-17 08:14 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:29:28 UTC


README

一个结构化的目录,用于构建和存储xml文件。

这作为一个项目模板,为特定客户的xml-authoring-directory提供了基础。

先决条件

使用命令

创建你的composer.json文件

此项目在项目文件夹的根目录中包含一个默认的依赖项集,在composer.json.dist中。

为下一步制作composer.json.dist文件的副本。

$ cp composer.json.dist composer.json

安装依赖项

对于用户

$ composer install

开发者可能希望使用--prefer-source来使用依赖组件的git仓库)

$ composer install --prefer-source
  • 尝试从xml-authoring-tools中的hello-world命令示例

    # Stream some example content into the config file (creating it if it does not exist) 
    $ pwd
    /Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project
    $ cat vendor/xmlsquad/xmlauthor-example-command/XmlAuthoringProjectSettings.yaml.dist >> XmlAuthoringProjectSettings.yaml
    
    # Try
    bin/console hello-world
  • (可选) 需要额外的命令包

    composer require xmlsquad/some-package

    要研究/尝试所需包中的命令 - 请参阅包的README.md

谁需要这个呢?

因此,您是负责创建和编辑客户Xml文件的员工。

我们有一个客户想要一些Xml文件。我们需要在您的电脑上设置一个文件夹,作为客户Xml项目的“工作目录”。

我们使用Git SCM跟踪此目录中文件的变化。

每个xml-authoring-project实例在根目录都有一个composer.json文件,该文件指定了一系列不断增长的定制软件工具,可以加速您的重复性任务。

定制软件工具

这些工具是为在xml-authoring-project的上下文中工作而构建的。

我们将使用软件工具来

  • 操纵和查询存储在此目录中的Xml文件;
  • Bitbucket Pipelines中运行时,每当提交更改时,都会测试和报告Xml文件的状态。

我们还使用定制工具(以及项目的配置设置)将客户的Google Sheets转换为存储在此处的Xml片段。

入门

我们假设您已安装

导航到您的项目目录

  • 在您的工作站上,打开MacOs终端或Windows Git Bash
  • 导航到您电脑上存储Xml作者项目的文件夹。
$ cd /Users/Bob/Documents/Projects/XmlAuthoring

对于一个客户,我们可能已经将他们的工作目录设置为云中的git仓库。

使用现有的工作目录。

  • 确定客户工作目录的“origin”Git仓库的位置(询问账户经理)。
  • 运行git clone以获取客户工作目录的本地副本
  • 使用cd更改到工作目录。

现在,您应该能够对Xml文件进行工作。

一旦您的编辑完成,使用git将您的更改提交到origin

为客户创建一个新的XML编写项目工作目录

我们创建一个新的基于此xml-authoring-project的git仓库,然后更改远程仓库,并将其推送到我们的git托管解决方案。实际上,我们分叉了它

  • 确保客户有一个为他们创建的空“origin”Git仓库(请咨询客户的账户经理)。
  • 运行git clone以获取https://github.com/xmlsquad/xml-authoring-project的本地副本
  • 使用cd更改到工作目录。
  • 使用git remote set-url命令将origin设置为客户的仓库。例如:
$ git remote set-url origin git@github.com:path/to/git/repo.git

查询设置以确保它已成功

$ git remote -v
origin	git@github.com:path/to/git/repo.git (fetch)
origin	git@github.com:path/to/git/repo.git (push)
  • 使用git push将基本项目推送到客户的origin仓库。

确保工具已安装

  • 运行composer install以确保所有工具都已安装。

现在,您应该能够对Xml文件进行工作。

一旦您的编辑完成,使用git将您的更改提交到origin

配置工具

作为最终用户,您需要将一些配置文件添加到项目的根目录

连接到G Suite

注意:在撰写本文时,我们有2个连接到G Suite的子项目。每个项目的开发人员都被赋予了解决Google API身份验证问题的自由。在接下来的几个小时里,我将查看所有解决方案,并选择一个作为最终方法。

与此同时,您可以复制另一个开发人员使用的模式,以确定您的凭证文件将存储的位置。

检查项目的开发分支和拉取请求。连接到G Suite的是:

  • gsheet-to-xml - 给定Google表格的URL,这个Symfony控制台命令获取Google表格并以XML格式输出。
  • ping-drive - Symfony控制台命令,报告其定位和读取Google Drive文件夹或文件内容的过程。

正在构建一个名为

  • capture-lookups的第三个子项目 - 一个Symfony 3.4控制台命令。当给出包含Google表格URL的配置文件时,它将它们获取并作为CSV文件存储在本地。

我们在以下位置有一个共享代码库:

XmlAuthoringProjectSettings.yaml

为我们的公司每位客户创建一个xml-authoring-project实例。此配置文件用于存储客户端的全局配置,例如客户端在G Suite上的密钥文件和文件夹的位置。

使用工具

请参阅:https://github.com/xmlsquad/xml-authoring-tools

保持工具更新

自定义工具始终在改进。

要将工具更新到最新版本。

  • 首先确保将所有客户文件更改提交并推送到仓库
  • 在命令终端中,导航到客户工作目录的根目录,并运行composer update

已知的错误

我们使用OAuth身份验证来访问Google表格的bin/console inventory:gsheet-to-xml命令。

然而,当您首次运行该命令时,它会要求输入Auth代码,但没有任何关于如何获取Auth代码的提示。

解决方案是运行另一个命令ping-drive来“登录”并保存您的身份验证令牌。完成后,gsheet-to-xml将使用该令牌来访问Google表格。

示例

假设您已拥有Google OAuth密钥,并且XmlAuthoringProjectSettings.yaml定义了OAuth密钥(gApiOAuthSecretFile)的位置以及令牌文件名(gApiAccessTokenFile)。

确保您已导航到项目文件夹

$ pwd
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project

运行ping-drive

$ bin/console ping-drive  https://drive.google.com/drive/folders/<someFolderID> 
You need to authenticate to your Google account to proceed
Open the following URL in a browser, get an auth code and paste it below:

<UrlToGetTheAuthCode>

Auth code: <AuthCode>

现在您可以使用令牌运行inventory:gsheet-to-xml

开发笔记

Composer验证通知是正常的

在2019年11月3日之前,团队使用了一种技巧来检查依赖关系。这种技巧在项目composer.json文件通过composer validate检查时留下验证警告。

$ pwd
/Users/x/Documents/Projects/XmlAuthoring/xml-authoring-project
$ composer validate
./composer.json is valid for simple usage with composer but has
strict errors that make it unable to be published as a package:
See https://getcomposer.org.cn/doc/04-schema.md for details on the schema
The property repositories-local is not defined and the definition does not allow additional properties

所以,虽然可能看起来有点痛苦,但它是无害的。因此,我们忽略它。一旦项目更加稳定,我们将将其删除。