项目作者: robinvdvleuten

项目描述 :
📦 A CLI toolkit to create your Gigya screensets with React.
高级语言: JavaScript
项目地址: git://github.com/robinvdvleuten/gigya-toolkit.git
创建时间: 2017-11-09T18:33:17Z
项目社区:https://github.com/robinvdvleuten/gigya-toolkit

开源协议:MIT License

下载


gigya-toolkit

A CLI toolkit to create your Gigya screensets with React.

NPM version
Build Status

Installation

Install the package and its peer dependencies.

  1. $ npm install --save gigya-toolkit react react-dom

Usage

When you have defined a screen set (src/RegistrationLogin.js) like this;

  1. import React from 'react';
  2. const Login = () =>
  3. <div id="login-screen" className="gigya-screen" data-caption="Login">
  4. {/* Login Screen Markup */}
  5. </div>;
  6. const Registration = () =>
  7. <div id="registration-screen" className="gigya-screen" data-caption="Register">
  8. {/* Registration Screen Markup */}
  9. </div>;
  10. export default () => (
  11. <div id="react-screen-set" className="gigya-screen-set" style={{ display: 'none' }}>
  12. <Login ></Login>
  13. <Registration ></Registration>
  14. </div>
  15. );

You can create the correct HTML markup and synchronize them with Gigya like this;

  1. bin/gigya build --api-key=<GIGYA API KEY> --secret=<GIGYA SECRET> --region=<GIGYA DATACENTER> src

CLI Options

Compile and synchronize your screensets with the configured Gigya account.

  1. bin/gigya build [options] <source>
  2. Options:
  3. --cwd A directory to use instead of $PWD
  4. --prefix Prefix the identifier of the screenset
  5. --api-key Your Gigya API key [string]
  6. --secret Your Gigya secret [string]
  7. --region Your Gigya region [string]
  8. --babelrc Use the project\'s babelrc configuration [boolean]
  9. --config, -c Path to custom CLI config [string]
  10. --help, -h Show help [boolean]
  11. --version, -v Show version number [boolean]

Start a development server to develop your screensets locally.

  1. bin/gigya develop [options] <source>
  2. Options:
  3. --cwd A directory to use instead of $PWD
  4. --prefix Prefix the identifier of the screenset
  5. --api-key Your Gigya API key [string]
  6. --secret Your Gigya secret [string]
  7. --region Your Gigya region [string]
  8. --config, -c Path to custom CLI config [string]
  9. --babelrc Use the project\'s babelrc configuration [boolean]
  10. --help, -h Show help [boolean]
  11. --version, -v Show version number [boolean]
  12. --template Path to custom template file [string]
  13. --port Port to start a server on [default: 3000]
  14. --host Host to start a server on [default: "localhost"]

Default Options

You can use different ways to set a default options:

  • gigya object in your package.json
  • .gigyarc file in JSON or YML format
  • gigya.config.js file in JS format

See cosmiconfig for more details on what formats are supported.

Custom Configuration

To customize the compilation process, create a toolkit.config.js file which exports multiple hooks that will be invoked on each compilation step.

  1. /**
  2. * Function that mutates webpack configuration.
  3. * Supports asynchronous changes when promise is returned.
  4. *
  5. * @param {object} config - The webpack configuration.
  6. * @param {object} env - options passed to CLI.
  7. * @param {object} helpers - additional Webpack configuration helpers.
  8. **/
  9. exports.webpack = (config, env, helpers) => {
  10. /** you can change config here **/
  11. }
  12. /**
  13. * Function that renders the React component.
  14. * Supports asynchronous rendering when promise is returned.
  15. *
  16. * @param {object} config - The render configuration.
  17. * @param {object} env - options passed to CLI.
  18. **/
  19. exports.render = ({ Component, styles }, env) => {
  20. /** you can return a custom { markup, styles } object here **/
  21. }

License

MIT © Robin van der Vleuten