Built for PS Generator
This CLI allow you to generate a Built For PS with different parameters: PrestaShop version, Billing i sandbox or not, Billing environment, Product ID (which allow to use different pricing model)
Requirements
First of all you need to install composer, please refer to the Linux / Unix / MacOS instruction or Windows instructions.
Installation
npm i -g @prestashopcorp/builtfor-generator-vanilla
or
yarn global add @prestashopcorp/builtfor-generator-vanilla
Usage
Classic
Launch in a terminal this command
builtforGen -id <productId> [...other options]
Options for classic usage
Generate Built for PS for PrestaShop
Options:
-id, --productId <productId> Technical id of the Built for PS. This id will be used to generate the Built for PS with the proper value. Ths value should match the product family item configured
in Chargebee, otherwise you must create it.
--psVersion <version> Description of the Built for PS (choices: "1.7", "8", "9", default: "9")
-s --sandbox Use this flag to generate a Built for PS in sandbox mode
-e, --environment <environment> Specify an environment when you don't want to use the production (choices: "prestabulle1", "prestabulle2", "prestabulle3", "prestabulle4", "prestabulle5",
"prestabulle6", "preprod")
-t, --template <template> Specify a template when you want to handling display of yours plans (choices: "standard", "handle",
default: "standard")
-wd, --workingDir <path> Directory where the Built for PS will be created. You can specify a relative or an absolute path. (default: "tmp")
-d, --description <description> Description of the Built for PS (default: "Built for PS in Vanilla JS for PrestaShop")
-name, --displayName <name> Display name of the Built for PS
-c, --context <context> This option allow you to inject some information within the context. Please give a stringified json: '{"foo": "bar"}' (default: {})
--customCancellation Use this flag to activate custom cancellation modal
-l, --module-lib-billing-version <version> This option allow you set the version of module-lib-billing. If you want to set it to a branch, you should add `dev` in front of it
(i.g. `dev-feat/my-feature` (default: "^4.0.0")
-h, --help display help for command
Focus on --context
You need to use this when the Built For PS documentation about billing, mention to add info within the context from your Javascript (in configure.tpl).
In this case please refer to the documentation to known which JSON structure should be used.
Example:
{
"product": {
"components": [
{
"id": "builtfor_example_stairstep",
"unitDescription": "Users"
}
]
}
}
Registered configuration
This script provide some registered configuration to save time. In this case the module generated is compatible with PS version 1.7, and all config are in sandbox.
builtforRegistered -c <config>
Options for registered configuration
Generate Built for PS for PrestaShop with registered whole configuration
Options:
-c, --config <config> Select your registered configuration (choices: "flat_bulle1", "flat_bulle2", "flat_bulle3", "flat_bulle4", "flat_bulle5", "flat_bulle6", "flat_preprod", "flat", "flat_handle_bulle1",
"flat_handle_bulle2", "flat_handle_bulle3", "flat_handle_bulle4", "flat_handle_bulle5", "flat_handle_bulle6", "flat_handle_preprod", "flat_handle", "stairstep_bulle1", "stairstep_bulle2",
"stairstep_bulle3", "stairstep_bulle4", "stairstep_bulle5", "stairstep_bulle6", "stairstep_preprod", "stairstep")
-h, --help display help for command
Examples
The product id is the key that makes this module either flat fee or stairstep
PS 9, Live, Production
Generate a flat fee module
builtforGen -id builtfor_example -d "PS 9 | Built for PS with a flat fee pricing"
Generate a flat fee module with the offer already selected
builtforGen \
-id builtfor_example \
-s \
-e prestabulle2 \
-d "PS 9 | Built for PS with a flat fee pricing in sandbox for prestabulle2. Selection automatic of the plan." \
-c '{"offerSelection": {"offerPricingId": "builtfor_example-ultimate-EUR-Monthly"}}'
Generate a stairstep module
builtforGen \
-id builtfor_example_stairstep \
-d "PS 9 | Built for PS with a stairstep pricing" \
-c '{"product": {"components": [{"id": "builtfor_example_stairstep", "unitDescription": "Users" }]}}'
Generate a stairstep module with preselected step
builtforGen \
-id builtfor_example_stairstep \
-s \
-e prestabulle2 \
-d "PS 9 | Built for PS with a stairstep pricing in sandbox for prestabulle2" \
-c '{"product": {"components": [{"id": "builtfor_example_stairstep", "unitDescription": "Users" }]}, "offerSelection": {"offerPricingId": "builtfor_example_stairstep", "offerQuantity": 255}}'
Generate a stairstep module with a frequency switcher
builtforGen \
-id builtfor_example_stairstep \
-name 'Builtfor Stairstep Example' \
-e prestabulle2 \
--template frequency \
-c '{"offerSelection": {"offerPricingId": "builtfor_stairstep-EUR-Monthly","offerQuantity": 1 }}'
PS 1.7, Sandbox, Prestabulle 2
Generate a flat fee module for PS 1.7
$ builtforGen -id builtfor_example -s -e prestabulle2 -d "PS 1.7 | Built for PS with a flat fee pricing in sandbox for prestabulle2" --psVersion "1.7" -l 3.3.0
$ builtforRegistered -c flat_bulle2
Generate a flat fee with handle plan module for PS1.7
builtforGen -id builtfor_example -s -e prestabulle2 -d "PS 1.7 | Built for PS with a flat fee pricing in sandbox for prestabulle2" --psVersion "1.7" -t "handle" -l 3.3.0
builtforRegistered -c flat_handle_bulle2
Generate a stairstep module for PS1.7
builtforGen \
-id builtfor_example_stairstep \
-s \
-e prestabulle2 \
-d "PS 1.7 | Built for PS with a stairstep pricing in sandbox for prestabulle2" \
--psVersion "1.7" \
-c '{"product": {"components": [{"id": "builtfor_example_stairstep", "unitDescription": "Users" }]}}' \
-l 3.3.0
Change PHP version
With Homebrew
$ brew install php@{version}
$ brew link --force --overwrite php@{version}
$ brew services start shivammathur/php/php@{version}
Contribute
Installation
yarn install
Launch
yarn start
yarn start:dev
yarn start_reg
yarn start_reg:dev
Build
yarn build