nyt / sugarcli-nyt
SugarCli-NYT 是一个命令行工具,用于安装和管理 SugarCRM 安装,并为《纽约时报》提供定制。
Requires
- php: >=5.3.9
- ext-curl: *
- ext-reflection: *
- csanquer/colibri-csv: 1.1.*
- guzzle/guzzle: ~3.9
- inetprocess/libinventoryclient: ^1.0
- inetprocess/libsugarcrm: ^1.2
- inetprocess/neuralyzer: ~0.6
- jms/serializer: ~0.16
- padraic/phar-updater: ^1.0
- symfony/config: ^2.8
- symfony/console: ^2.8
- symfony/dependency-injection: ^2.8
- symfony/filesystem: ^2.8
- symfony/finder: ^2.8
- symfony/process: ^2.8
- symfony/stopwatch: ^2.8
- symfony/yaml: ^2.8
Requires (Dev)
- fabpot/php-cs-fixer: ^1.10
- phpunit/dbunit: ~1.3
- phpunit/phpunit: ~4
- dev-master
- v1.11.1
- v1.11.0
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.1
- v1.9.0
- v1.8.2-beta
- v1.8.1
- v1.8.0
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.0
- v1.6.0-beta
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- v0.1.0
- dev-dependabot/composer/padraic/humbug_get_contents-1.1.2
- dev-dependabot/composer/phpunit/phpunit-4.8.28
- dev-dependabot/composer/symfony/dependency-injection-2.8.50
- dev-feature/SCRM-ACTION/repairMetadata
This package is not auto-updated.
Last update: 2024-07-20 18:25:17 UTC
README
SugarCli 是一个命令行工具,用于安装和管理 SugarCRM 安装。
安装
从 http://apt.inetprocess.fr/pub/sugarcli.phar
获取 phar 归档文件。允许执行并运行它。
wget 'http://apt.inetprocess.fr/pub/sugarcli.phar'
chmod +x ./sugarcli.phar
./sugarcli.phar
或者克隆此 Git 仓库并使用 ./bin/sugarcli
。
构建
克隆 Git 仓库并运行 php -dphar.readonly=0 bin/compile
。它将在 Git 项目的顶部构建 sugarcli.phar
。
配置
您可以将一些配置选项保存到不同的位置。后者将覆盖前者:/etc/sugarclirc
$HOME/.sugarclirc
./.sugarclirc
命令行参数将覆盖这些配置。
示例
--- sugarcrm: path: path/to/sugar url: http://external.url
用法
./sugarcli.phar --help
:这将为您提供帮助和可用命令列表。
开发
运行测试
将文件 phpunit.xml.dist
复制到 phpunit.xml
并编辑环境变量。
使用 bin/phpunit
运行完整的测试套件或排除组以避免所需的外部资源 bin/phpunit --exclude-group inventory,sugarcrm-db
可用组:
- inventory
- sugarcrm-db
- sugarcrm-path
- sugarcrm-url
命令
清理语言文件
主要命令是 ./sugarcli.phar clean:langfiles
参数
--no-sort Do not sort the files contents. It will still remove duplicates. Useful for testing.
-t, --test Try to rewrite the files without modifying the contents. Imply --no-sort.
-p, --path=PATH Path to SugarCRM installation.
测试运行
./sugarcli.phar clean:langfiles --test path/to/sugar
这将解析 sugar 中的自定义语言文件。它应返回文件原样。
不排序清理。
./sugarcli.phar clean:langfiles --no-sort path/to/sugar
这将通过删除不必要的空格和删除变量定义中的重复项来清理 lang 文件。
清理并排序
./sugarcli.phar clean:langfiles path/to/sugar
这将清理和排序语言文件。所有定义的变量都将按名称排序。
安装 SugarCRM
主要命令是 ./sugarcli.phar install
子命令是
./sugarcli.phar install:config:get ./sugarcli.phar install:check ./sugarcli.phar install:run
配置您的安装
./sugarcli.phar install:config:get
将在当前目录中创建 config_si.php
。
这为安装程序提供默认设置。您需要完成一些必需参数,如数据库信息、用户名和密码。必需字段的形式为 <VALUE>
。
install:config:get
- 参数
-c, --config=CONFIG Write to this file instead of config_si.php. [default: "config_si.php"]
-f, --force Overwrite existing file
install:check
- 参数
-p, --path=PATH Path to SugarCRM installation.
运行安装程序
./sugarcli.phar install:run [-f|--force] [-s|--source[="..."]] [-c|--config[="..."]] 路径 URL
您需要指定安装路径和您的 Sugar 安装的公共 URL。
安装程序将提取一个名为 sugar.zip 的 SugarCRM 安装包,或使用 --source
选项指定的安装包。
它将使用 --config
选项用于安装。
install:run
- 参数
-f, --force Force installer to remove target directory if present. -s, --source=SOURCE Path to SugarCRM installation package. [default: "sugar.zip"] -c, --config=CONFIG PHP file to use as configuration for the installation. [default: "config_si.php"] -p, --path=PATH Path to SugarCRM installation.
示例
./sugarcli.phar install:config:get nano config_si.php ./sugarcli.phar install:run -v ~/www/sugar7 http://myserver.example.org/sugar7 --source ~/sugar_package/SugarPro-Full-7.2.2.1.zip
使用 -v
或 -vv
添加更多详细输出。
管理 fields_meta_data
和 relationships
表
有两个命令组可用于导出和同步 fields_meta_data 表(来自 studio 的自定义字段)和 relationships(默认和自定义关系)的内容。
第一个以 metadata
为前缀,第二个以 rels
为前缀。
默认情况下,元数据定义文件将是 <sugar_path>/../db/fields_meta_data.yaml
,关系将是 <sugar_path>/../db/relationships.yaml
。
您可以使用 --metadata-file
参数覆盖它,用于所有 metadata
子命令,以及使用 --file
参数覆盖所有 rels
子命令。
主要命令是 ./sugarcli.phar metadata
和 ./sugarcli.phar rels
子命令是
./sugarcli.phar metadata:loadfromfile ./sugarcli.phar metadata:dumptofile ./sugarcli.phar metadata:status ./sugarcli.phar rels:loadfromfile ./sugarcli.phar rels:dumptofile ./sugarcli.phar rels:status
以下说明是针对 metadata
的,但对 rels
也类似
将定义加载到数据库中
sugarcli {type}:loadfromfile
从元数据文件中加载字段,以更新数据库。
metadata:loadfromfile
参数
-s, --sql Print the sql queries that would have been executed. -f, --force Really execute the SQL queries to modify the database. -a, --add Add new fields from the file to the DB. -d, --del Delete fields not present in the metadata file from the DB. -u, --update Update the DB for modified fields in metadata file. -p, --path=PATH Path to SugarCRM installation. -m, --metadata-file=METADATA-FILE Path to the metadata file. (default: "<sugar_path>/../db/fields_meta_data.yaml")
rels:loadfromfile
参数
-s, --sql Print the sql queries that would have been executed. -f, --force Really execute the SQL queries to modify the database. -a, --add Add new fields from the file to the DB. -d, --del Delete fields not present in the relationships file from the DB. -u, --update Update the DB for modified fields in relationships file. -p, --path=PATH Path to SugarCRM installation. --file=FILE Path to the rels file. (default: "<sugar_path>/../db/relationships.yaml")
将定义写入文件
sugarcli {type}:dump
您可以将当前 DB fields_meta_data(或关系)的内容导出到定义文件中。
您还可以使用 --add
、--del
、--update
标志只添加、删除或更新字段(或关系)。
命令行后面的指定字段允许您仅对特定字段(或关系)进行操作。
metadata:dumptofile
参数
-a, --add Add new fields from the DB to the definition file. -d, --del Delete fields not present in the DB from the metadata file. -u, --update Update the metadata file for modified fields in the DB. -p, --path=PATH Path to SugarCRM installation. -m, --metadata-file=METADATA-FILE Path to the metadata file. (default: "<sugar_path>/../db/fields_meta_data.yaml")
rels:dumptofile
参数
-a, --add Add new relationships from the DB to the definition file. -d, --del Delete relationships not present in the DB -u, --update Update the relationships in the DB. -p, --path=PATH Path to SugarCRM installation. --file=FILE Path to the rels file. (default: "<sugar_path>/../db/relationships.yaml")
获取状态
sugarcli {type}:status -p path/to/sugar
这将显示定义文件和数据库之间不同的字段。
metadata:status
参数
-p, --path=PATH Path to SugarCRM installation.
-m, --metadata-file=METADATA-FILE Path to the metadata file. (default: "<sugar_path>/../db/fields_meta_data.yaml")
rels:status
参数
-p, --path=PATH Path to SugarCRM installation.
--file=FILE Path to the rels file. (default: "<sugar_path>/../db/relationships.yaml")
库存
主要命令是 ./sugarcli.phar inventory
子命令是
./sugarcli.phar inventory:facter ./sugarcli.phar inventory:agent
获取环境信息。
./sugarcli.phar inventory:facter --path <sugracrm_path> --format yml
将生成一个包含系统及其 sugarcrm 实例各种信息的 yaml 文件。
inventory:facter
参数
-F, --custom-fact=CUSTOM-FACT Add or override facts. Format: path.to.fact:value (multiple values allowed) -f, --format=FORMAT Specify the output format. (json|yml|xml). [default: "yml"] -p, --path=PATH Path to SugarCRM installation.
向库存服务器报告信息。
./sugarcli.phar inventory:agent --path <sugarcrm_path> --account-name '客户名称' <inventory_url> <username> <password>
这将发送所有收集到的信息到库存服务器。
inventory:agent
参数
-F, --custom-fact=CUSTOM-FACT Add or override facts. Format: path.to.fact:value (multiple values allowed) -p, --path=PATH Path to SugarCRM installation. -a, --account-name=ACCOUNT-NAME Name of the account.
用户管理
主要命令是 ./sugarcli.phar user
子命令是
./sugarcli.phar user:update ./sugarcli.phar user:create ./sugarcli.phar user:list
更新用户
./sugarcli.phar user:update --path <sugarcrm_path> --first-name=Admin --last-name='Test' myNewLogin
将更新用户 myNewLogin 并设置姓名。
user:update
参数
-c, --create Create the user instead of updating it. Optional if called with users:create. -f, --first-name=FIRST-NAME First name of the user. -l, --last-name=LAST-NAME Last name of the user. -P, --password=PASSWORD Password of the user [UNSAFE]. --ask-password Ask for user password. -a, --admin=ADMIN Make the user administrator. [yes/no] -A, --active=ACTIVE Make the user active. [yes/no] -p, --path=PATH Path to SugarCRM installation.
创建新用户
./sugarcli.phar user:create --path <sugarcrm_path> --password=mypasword --admin=yes myNewLogin
将创建一个新管理员用户,登录为 myNewLogin,密码为 mypasword。
user:create
参数
-c, --create Create the user instead of updating it. Optional if called with users:create. -f, --first-name=FIRST-NAME First name of the user. -l, --last-name=LAST-NAME Last name of the user. -P, --password=PASSWORD Password of the user [UNSAFE]. --ask-password Ask for user password. -a, --admin=ADMIN Make the user administrator. [yes/no] -A, --active=ACTIVE Make the user active. [yes/no] -p, --path=PATH Path to SugarCRM installation.
列出实例的用户。
./sugarcli.phar user:list --path <sugarcrm_path>
将提供用户列表。
您还可以限制结果到特定的用户名(--username
)并更改输出格式(--format
)为 json、yml 或 xml。
user:list
参数
-u, --username=USERNAME Login of the user. -f, --format=FORMAT Output format. (text|json|yml|xml) [default: "text"] -F, --fields=FIELDS List of comma separated field name. [default: "id,user_name,is_admin,status,first_name,last_name"] -l, --lang=LANG Lang for display. [default: "en_us"] -p, --path=PATH Path to SugarCRM installation.
系统
主要命令是 ./sugarcli.phar system
子命令有
./sugarcli.phar system:quickrepair
快速修复和重建
./sugarcli.phar system:quickrepair --path <sugarcrm_path>
将执行 SugarCRM 实例的基本快速修复和重建。
您还可以使用 --database
来检查 Vardefs 是否与数据库同步。
如果它们不同步,您可以通过添加 --force
来运行查询。
最后,如果您想获得 SugarCRM 的完整输出,请添加详细(--verbose
)选项。
system:quickrepair
参数
-d, --database Manage database changes. -f, --force Really execute the SQL queries (displayed by using -v). -p, --path=PATH Path to SugarCRM installation.
示例
命令 ./sugarcli.phar system:quickrepair --database
有这种类型的输出
Reparation:
- Repair Done.
Database Messages:
Database tables are synced with vardefs
逻辑钩子
主要命令是 ./sugarcli.phar hooks
子命令有
./sugarcli.phar hooks:list
列出模块的现有逻辑钩子
./sugarcli.phar hooks:list --path <sugarcrm_path> --module <module>
将生成指定模块的钩子列表。
该命令列出钩子,包括每个钩子的权重、描述、定义类的文件、调用的方法及其定义位置。
您还可以使用 --compact
来获得钩子的基本信息(权重/描述/方法)。
参数
-m, --module=MODULE Module's name.
--compact Activate compact mode
-p, --path=PATH Path to SugarCRM installation.
示例
命令 ./sugarcli.phar hooks:list --module Contacts --compact
给出这种类型的输出,对于一个没有钩子的模块
+-----------+-------------+--------+
| Hooks definition for Contacts |
+-----------+-------------+--------+
| Weight | Description | Method |
+-----------+-------------+--------+
| No Hooks for that module |
+-----------+-------------+--------+
Vardefs 提取器
为模块提取字段和关系
./sugarcli.phar extract:fields --path <sugarcrm_path> --module <module>
将提取一个模块中定义的所有字段及其参数(标签、下拉菜单内容、dbType等),并将数据写入包含数据的2个csv文件。
参数
-m, --module=MODULE Module's name.
--lang=LANG SugarCRM Language [default: "fr_FR"]
-p, --path=PATH Path to SugarCRM installation.
代码生成器
主要命令是 ./sugarcli.phar code
子命令有
./sugarcli.phar code:execute:file
在SugarCRM上下文中执行PHP文件
./sugracli.phar code:execute:file --path <sugarcrm_path> [--user-id='1'] <test.php>
将通过首先加载sugarcrm环境来执行文件 test.php
。因此,脚本可以直接使用sugar中的类和数据库。您还可以通过命令行设置user_id,以便使用除默认管理员以外的其他用户。