@prestashopcorp/builtfor-generator-vanilla
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -33,3 +33,3 @@ "use strict"; | ||
.addOption(new commander_1.Option('-t, --template <template>', 'Specify a template when you want to handling display of yours plans ') | ||
.choices(['standard', 'handle']) | ||
.choices(['standard', 'handle', 'frequency']) | ||
.default('standard')) | ||
@@ -43,4 +43,3 @@ .addOption(new commander_1.Option('-wd, --workingDir <path>', 'Directory where the Built for PS will be created. You can specify a relative or an absolute path.').default('tmp')) | ||
.option('--customCancellation', 'Use this flag to activate custom cancellation modal') | ||
.addOption(new commander_1.Option('-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('^3.0.0')) | ||
.addOption(new commander_1.Option('-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(ArgsParserClassic.MODULE_LIB_BILLING_VERSION)) | ||
.parse(argv); | ||
@@ -47,0 +46,0 @@ super(program); |
@@ -148,3 +148,3 @@ "use strict"; | ||
customCancellation: false, | ||
moduleLibBillingVersion: '^3.0.0', | ||
moduleLibBillingVersion: ArgsParserConfig.MODULE_LIB_BILLING_VERSION, | ||
}; | ||
@@ -162,3 +162,3 @@ ArgsParserConfig.flatHandleConfig = { | ||
template: 'handle', | ||
moduleLibBillingVersion: '^3.0.0', | ||
moduleLibBillingVersion: ArgsParserConfig.MODULE_LIB_BILLING_VERSION, | ||
}; | ||
@@ -185,5 +185,5 @@ ArgsParserConfig.stairstepConfig = { | ||
customCancellation: false, | ||
moduleLibBillingVersion: '^3.0.0', | ||
moduleLibBillingVersion: ArgsParserConfig.MODULE_LIB_BILLING_VERSION, | ||
}; | ||
exports.ArgsParserConfig = ArgsParserConfig; | ||
//# sourceMappingURL=args-parser-config.js.map |
@@ -25,3 +25,4 @@ "use strict"; | ||
} | ||
ArgsParserRoot.MODULE_LIB_BILLING_VERSION = '^3.1.0'; | ||
exports.ArgsParserRoot = ArgsParserRoot; | ||
//# sourceMappingURL=args-parser.root.js.map |
@@ -76,3 +76,51 @@ "use strict"; | ||
{ | ||
$componentItems = $productComponents['body']['items']; | ||
$componentItemsTmp = $productComponents['body']['items']; | ||
// You need to retrieve plan information from your API or Class or Array like this | ||
// For plan id, please get in touch with your Solution Engineer at PrestaShop. | ||
$planInfos = [ | ||
[ | ||
"component_ids" => ["builtfor_free-EUR-Monthly", "builtfor_free-EUR-Yearly"], | ||
"name" => "Free", | ||
"features" => [ | ||
"Free Feature 1", | ||
"Free Feature 2", | ||
"Free Feature 3", | ||
"Free Feature 4" | ||
] | ||
], | ||
[ | ||
"component_ids" => ["builtfor_advanced-EUR-Monthly", "builtfor_advanced-EUR-Yearly"], | ||
"name" => "Advanced", | ||
"features" => [ | ||
"All features from Free, plus...", | ||
"Advanced Feature 1", | ||
"Advanced Feature 2", | ||
"Advanced Feature 3" | ||
] | ||
], | ||
[ | ||
"component_ids" => ["builtfor_ultimate-EUR-Monthly", "builtfor_ultimate-EUR-Yearly"], | ||
"name" => "Ultimate", | ||
"features" => [ | ||
"All features from Advanced, plus...", | ||
"Ultimate Feature 1", | ||
"Ultimate Feature 2" | ||
] | ||
] | ||
]; | ||
foreach($planInfos as $planInfo) { | ||
foreach($planInfo["component_ids"] as $component_id) { | ||
$componentItemIndex = array_search($component_id, array_column($componentItemsTmp, 'id')); | ||
if($componentItemIndex !== false) { | ||
$componentItemsTmp[$componentItemIndex]['details'] = [ | ||
"features" => $planInfo['features'], | ||
"name" => $planInfo['name'], | ||
]; | ||
// We store only components that are referenced in $planInfos | ||
array_push($componentItems, $componentItemsTmp[$componentItemIndex]); | ||
} | ||
} | ||
} | ||
} | ||
@@ -179,3 +227,3 @@ | ||
from: /<%TEMPLATE%>/g, | ||
to: this.options.template === 'standard' ? 'configure_standard' : 'configure_handle_plan_flat', | ||
to: this.selectTemplate(this.options.template), | ||
countMatches: true, | ||
@@ -206,2 +254,14 @@ }); | ||
} | ||
selectTemplate(template) { | ||
switch (template) { | ||
case 'standard': | ||
return 'configure_standard'; | ||
case 'handle': | ||
return 'configure_handle_plan_flat'; | ||
case 'frequency': | ||
return 'configure_frequency_selector'; | ||
default: | ||
throw new Error('Unrecognized template'); | ||
} | ||
} | ||
executeComposer() { | ||
@@ -208,0 +268,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@prestashopcorp/builtfor-generator-vanilla", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Built for PS generator with customization option", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -183,2 +183,14 @@ <div align="center"> | ||
\*\* Generate a stairstep module with a frequency switcher | ||
```bash | ||
builtforGen \ | ||
-id builtfor_example_stairstep \ | ||
-name 'Builtfor Stairstep Example' \ | ||
-e prestabulle2 \ | ||
--psVersion 1.7 \ | ||
--template frequency \ | ||
-c '{"offerSelection": {"offerPricingId": "builtfor_stairstep-EUR-Monthly","offerQuantity": 1 }}' | ||
``` | ||
#### PS 8, Live, Production | ||
@@ -185,0 +197,0 @@ |
@@ -45,3 +45,3 @@ import { Command, Option } from 'commander'; | ||
) | ||
.choices(['standard', 'handle']) | ||
.choices(['standard', 'handle', 'frequency']) | ||
.default('standard'), | ||
@@ -74,4 +74,3 @@ ) | ||
'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('^3.0.0') | ||
).default(ArgsParserClassic.MODULE_LIB_BILLING_VERSION), | ||
) | ||
@@ -78,0 +77,0 @@ .parse(argv); |
import { Command, Option } from 'commander'; | ||
import { ArgsParserRoot } from './args-parser.root'; | ||
import { ArgsParserOptions } from './args-parser-options'; | ||
import { Environment } from '@generator/generator-options'; | ||
@@ -51,3 +50,3 @@ type Preconfig = | ||
customCancellation: false, | ||
moduleLibBillingVersion: '^3.0.0', | ||
moduleLibBillingVersion: ArgsParserConfig.MODULE_LIB_BILLING_VERSION, | ||
}; | ||
@@ -66,3 +65,3 @@ | ||
template: 'handle', | ||
moduleLibBillingVersion: '^3.0.0', | ||
moduleLibBillingVersion: ArgsParserConfig.MODULE_LIB_BILLING_VERSION, | ||
}; | ||
@@ -90,3 +89,3 @@ | ||
customCancellation: false, | ||
moduleLibBillingVersion: '^3.0.0', | ||
moduleLibBillingVersion: ArgsParserConfig.MODULE_LIB_BILLING_VERSION, | ||
}; | ||
@@ -93,0 +92,0 @@ get options(): ArgsParserOptions { |
@@ -14,2 +14,3 @@ import { Command } from 'commander'; | ||
export abstract class ArgsParserRoot { | ||
protected static MODULE_LIB_BILLING_VERSION = '^3.1.0'; | ||
protected program: Command; | ||
@@ -16,0 +17,0 @@ get options(): ArgsParserOptions { |
@@ -6,3 +6,3 @@ import { JSONValue } from '@cli/args-parser.root'; | ||
export type PsVersion = '1.7' | '8'; | ||
export type Template = 'standard' | 'handle'; | ||
export type Template = 'standard' | 'handle' | 'frequency'; | ||
export type PsAccountVersion = "'5.0'" | "'6.0'"; | ||
@@ -9,0 +9,0 @@ export type Environment = |
@@ -9,2 +9,3 @@ import { existsSync } from 'fs'; | ||
RelativePath, | ||
Template, | ||
} from './generator-options'; | ||
@@ -94,3 +95,51 @@ import { rimrafSync } from 'rimraf'; | ||
{ | ||
$componentItems = $productComponents['body']['items']; | ||
$componentItemsTmp = $productComponents['body']['items']; | ||
// You need to retrieve plan information from your API or Class or Array like this | ||
// For plan id, please get in touch with your Solution Engineer at PrestaShop. | ||
$planInfos = [ | ||
[ | ||
"component_ids" => ["builtfor_free-EUR-Monthly", "builtfor_free-EUR-Yearly"], | ||
"name" => "Free", | ||
"features" => [ | ||
"Free Feature 1", | ||
"Free Feature 2", | ||
"Free Feature 3", | ||
"Free Feature 4" | ||
] | ||
], | ||
[ | ||
"component_ids" => ["builtfor_advanced-EUR-Monthly", "builtfor_advanced-EUR-Yearly"], | ||
"name" => "Advanced", | ||
"features" => [ | ||
"All features from Free, plus...", | ||
"Advanced Feature 1", | ||
"Advanced Feature 2", | ||
"Advanced Feature 3" | ||
] | ||
], | ||
[ | ||
"component_ids" => ["builtfor_ultimate-EUR-Monthly", "builtfor_ultimate-EUR-Yearly"], | ||
"name" => "Ultimate", | ||
"features" => [ | ||
"All features from Advanced, plus...", | ||
"Ultimate Feature 1", | ||
"Ultimate Feature 2" | ||
] | ||
] | ||
]; | ||
foreach($planInfos as $planInfo) { | ||
foreach($planInfo["component_ids"] as $component_id) { | ||
$componentItemIndex = array_search($component_id, array_column($componentItemsTmp, 'id')); | ||
if($componentItemIndex !== false) { | ||
$componentItemsTmp[$componentItemIndex]['details'] = [ | ||
"features" => $planInfo['features'], | ||
"name" => $planInfo['name'], | ||
]; | ||
// We store only components that are referenced in $planInfos | ||
array_push($componentItems, $componentItemsTmp[$componentItemIndex]); | ||
} | ||
} | ||
} | ||
} | ||
@@ -199,4 +248,3 @@ | ||
from: /<%TEMPLATE%>/g, | ||
to: | ||
this.options.template === 'standard' ? 'configure_standard' : 'configure_handle_plan_flat', | ||
to: this.selectTemplate(this.options.template), | ||
countMatches: true, | ||
@@ -233,2 +281,20 @@ }); | ||
private selectTemplate( | ||
template: Template, | ||
): 'configure_standard' | 'configure_handle_plan_flat' | 'configure_frequency_selector' { | ||
switch (template) { | ||
case 'standard': | ||
return 'configure_standard'; | ||
case 'handle': | ||
return 'configure_handle_plan_flat'; | ||
case 'frequency': | ||
return 'configure_frequency_selector'; | ||
default: | ||
throw new Error('Unrecognized template'); | ||
} | ||
} | ||
private async executeComposer(): Promise<void> { | ||
@@ -235,0 +301,0 @@ return new Promise((resolve, reject) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
116869
44
1411
245