CS-Cart SDK

CS-Cart開発者向けコマンドラインツール
https://github.com/cscart/sdk/

CS-Cart SDKはgithubで配布されているCS-Cart開発者向けのコマンドラインツールです。このドキュメントはgithubのREADMEを翻訳しています。

目的

CS-Cartに便利な開発ツールを提供したいと考えています。このSDKは、アドオンとテーマの開発に関連する複雑で日常的なタスクを処理することを目的としています。

インストール

システムにComposerをインストールする必要があります。
Composerをインストールしていない場合は、インストールガイドを確認してください。

$ composer global require "cscart/sdk:*"

Composerがインストールされたら、コンソールで次のコマンドを実行するだけです。

👍

パスを通しておくと便利です。
Xserverの場合
$ export COMPOSER_HOME=~/.composer
$ source ~/.bashrc
(これを.bashrcに書き込む)

Macの場合
$ export PATH=$HOME/.composer/vendor/bin:$PATH
$ source ~/.zprofile

コマンドの実行

$ cscart-sdk command:name

コマンド・リスト

addon:symlink

CS-Cartのインストールディレクトリにアドオンファイルのシンボリックリンクを作成し、アドオンファイルを開発して別のGitリポジトリに保存できるようにします。

$ cscart-sdk addon:symlink --help
Usage:
  addon:symlink [options] [--] <name> <addon-directory> <cart-directory>

Arguments:
  name                       Add-on ID (name)
  addon-directory            Path to directory with add-on files
  cart-directory             Path to CS-Cart installation directory

Options:
  -r, --relative             Created symlinks will have a relative path to the target file. By default the created symlinks have an absolute path to target.
      --templates-to-design  Whether to take the add-on templates from "var/themes_repository" path at the add-on directory and put them at "design/themes" path in the CS-Cart installation directory . When this option is not specified, the templates are being taken from "var/themes_repository" and also put into "var/themes_repository" directory.
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
 Creates symlinks for add-on files at the CS-Cart installation directory, allowing you to develop and store add-on files in a separate Git repository.

addon:export

ディレクトリの構造を維持しながら、すべてのアドオンファイルを別のディレクトリにコピーまたは移動します。

$ cscart-sdk addon:export --help
Usage:
  addon:export [options] [--] <name> <addon-directory> <cart-directory>

Arguments:
  name                         Add-on ID (name)
  addon-directory              Path to directory where files should be moved to
  cart-directory               Path to CS-Cart installation directory

Options:
  -d, --delete                 Files and directories will be moved instead of being copied.
      --templates-from-design  Whether to take the add-on templates from "design/themes" path at CS-Cart installation directory and put them at "var/themes_repository" path in the add-on files directory. When this option is not specified, the templates are being taken from "var/themes_repository" and also put into "var/themes_repository" directory.
  -h, --help                   Display this help message
  -q, --quiet                  Do not output any message
  -V, --version                Display this application version
      --ansi                   Force ANSI output
      --no-ansi                Disable ANSI output
  -n, --no-interaction         Do not ask any interactive question
  -v|vv|vvv, --verbose         Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
 Copies or moves all add-on files to the separate directory, preserving the structure of directories.

addon:sync

CS-Cartインストールディレクトリとすべてのアドオンファイルを保存する別のディレクトリの間でアドオンファイルを同期します。このコマンドを呼び出すと、addon:export コマンドとaddon:symlink コマンドを同時に呼び出すのと同じ効果があります。

$ cscart-sdk addon:sync --help
Usage:
  addon:sync [options] [--] <name> <addon-directory> <cart-directory>

Arguments:
  name                  Add-on ID (name)
  addon-directory       Path to directory where files should be moved to
  cart-directory        Path to CS-Cart installation directory

Options:
  -r, --relative        Created symlinks will have a relative path to the target file. By default the created symlinks have an absolute path to target.
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
 Synchronizes add-on files between CS-Cart installation directory and the separate directory storing all add-on files. Calling this command has the same effect as calling the "addon:export" and "addon:symlink" commands simultaneously.

addon:build_upgrade

アドオンバージョン間のアップグレードパッケージを作成します。

$ php bin/cscart-sdk addon:build_upgrade --help
Usage:
  addon:build_upgrade <old_addon_version_archive_path> <new_addon_version_archive_path> <result_dir_path>

Arguments:
  old_addon_version_archive_path  Old add-on version archive path
  new_addon_version_archive_path  New add-on version archive path
  result_dir_path                 Path to a directory where the built upgrade package will be placed

Options:
  -h, --help                      Display this help message
  -q, --quiet                     Do not output any message
  -V, --version                   Display this application version
      --ansi                      Force ANSI output
      --no-ansi                   Disable ANSI output
  -n, --no-interaction            Do not ask any interactive question
  -v|vv|vvv, --verbose            Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Creates upgrade package between add-on versions

ローカル開発環境の準備

フォークされたリポジトリのクローンを作成した後、cscart-sdkコマンドを実行してローカルでテストできるようにする必要があります。これを行うには、ローカルのパスからComposerパッケージをインストールする必要があります。

次の行を~/.composer/composer.jsonにあるグローバルのcomposer.jsonファイルに追記します。

{
    "minimum-stability": "dev",
    "repositories": [
        {
            "type": "path",
            "url": "/path/to/cloned/repository/directory"
        }
    ],
    "require": {
        "cscart/sdk": "*"
    }
}

リポジトリのフォークを複製した正しいディレクトリへのパスを指定することを忘れないでください。
その後、次のコマンドを実行します。

$ composer global require cscart/sdk

これを行う必要があるのは1度だけです。
コードを変更するたびにローカルパッケージを再インストールする必要はありません。フォークされたリポジトリを持つディレクトリは、グローバルにインストールされたComposerパッケージディレクトリにシンボリックリンクされます。

これで、グローバルで使用可能なcscart-sdkコマンドを実行して、変更をテストできます。

※このドキュメントはhttps://github.com/cscart/sdk/を翻訳したものです。