@field123/hacksprint-2022-js-sdk-test-response-generation 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/README.md +43 -0
- package/dist/main.tf +164 -0
- package/dist/package.json +40 -0
- package/package.json +3 -2
package/dist/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# @field123/hacksprint-2022-js-sdk-test-response-generation
|
2
|
+
|
3
|
+
# Test Data Retrival Script
|
4
|
+
|
5
|
+
The script populates a store with test data, runs CURL calls to get data then tears down the data to create a clean slate.
|
6
|
+
|
7
|
+
Utilizes the [EPCC Terraform Provider](https://registry.terraform.io/providers/elasticpath/epcc/latest) to populate and tear down down data in a store.
|
8
|
+
|
9
|
+
## Setup
|
10
|
+
|
11
|
+
Create a `.env` file based on the `.env.example` file.
|
12
|
+
|
13
|
+
## Install
|
14
|
+
|
15
|
+
```sh
|
16
|
+
yarn add -D @field123/hacksprint-2022-js-sdk-test-response-generation
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```sh
|
22
|
+
npx hacksprint-2022-js-sdk-test-response-generation endpoints -s <source> -o <dest> -e <environment-file>
|
23
|
+
```
|
24
|
+
|
25
|
+
```sh
|
26
|
+
npx hacksprint-2022-js-sdk-test-response-generation endpoints -s ./postman-export/postman_collection.json -o ./output -e ./postman-export/postman_environment.json
|
27
|
+
```
|
28
|
+
|
29
|
+
```sh
|
30
|
+
npx hacksprint-2022-js-sdk-test-response-generation endpoints -s ./postman-export/postman_collection.json -o ./output -e ./postman-export/postman_environment.json -v
|
31
|
+
```
|
32
|
+
|
33
|
+
| Key | CLI opt | Default | Description |
|
34
|
+
| ---- | ----------------- | -------- | ------------------------------------------------------ |
|
35
|
+
| s | --source \<file\> | required | Source postman collection json file. |
|
36
|
+
| e | --env \<file\> | required | Source postman environment json file. |
|
37
|
+
| o | --output \<dir\> | \<dir\> | Output location for the generated endpoint json files. |
|
38
|
+
| v | --verbose | false | Logs details of terraform commands to console. |
|
39
|
+
| help | -h, --help | n/a | display help for command |
|
40
|
+
|
41
|
+
## Sources
|
42
|
+
|
43
|
+
`main.tf` comes from this repo: https://gitlab.elasticpath.com/commerce-cloud/playground/sample-catalogs-accelerator/-/blob/MT-11900/store-scope/variants/get-started-with-pcm-catalog/main.tf
|
package/dist/main.tf
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
terraform {
|
2
|
+
required_providers {
|
3
|
+
epcc = {
|
4
|
+
source = "elasticpath/epcc"
|
5
|
+
version = "0.0.2"
|
6
|
+
}
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
provider "epcc" {
|
11
|
+
}
|
12
|
+
|
13
|
+
resource "epcc_hierarchy" "major_appliances" {
|
14
|
+
name = "Major Appliances"
|
15
|
+
description = "Free standing appliances"
|
16
|
+
slug = "Major-Appliances-MA0"
|
17
|
+
}
|
18
|
+
|
19
|
+
resource "epcc_node" "ranges" {
|
20
|
+
hierarchy_id = epcc_hierarchy.major_appliances.id
|
21
|
+
name = "Ranges"
|
22
|
+
description = "All stoves and ovens"
|
23
|
+
slug = "Ranges-MA1"
|
24
|
+
}
|
25
|
+
|
26
|
+
resource "epcc_node" "electric_ranges" {
|
27
|
+
hierarchy_id = epcc_hierarchy.major_appliances.id
|
28
|
+
parent_id = epcc_node.ranges.id
|
29
|
+
name = "Electric Ranges"
|
30
|
+
description = "Electric stoves and ovens"
|
31
|
+
slug = "Electric-Ranges-MA2"
|
32
|
+
}
|
33
|
+
|
34
|
+
resource "epcc_node" "gas_ranges" {
|
35
|
+
hierarchy_id = epcc_hierarchy.major_appliances.id
|
36
|
+
parent_id = epcc_node.ranges.id
|
37
|
+
name = "Gas Ranges"
|
38
|
+
description = "Gas stoves and ovens"
|
39
|
+
slug = "Ranges-MA2"
|
40
|
+
}
|
41
|
+
|
42
|
+
resource "epcc_product" "be_electric_range" {
|
43
|
+
name = "BestEver Electric Range"
|
44
|
+
sku = "BE-Electric-Range-1a1a"
|
45
|
+
slug = "bestever-range-1a1a"
|
46
|
+
description = "This electric model offers an induction heating element and convection oven."
|
47
|
+
status = "live"
|
48
|
+
commodity_type = "physical"
|
49
|
+
upc_ean = "111122223333"
|
50
|
+
mpn = "BE-R-1111-aaaa-1a1a"
|
51
|
+
}
|
52
|
+
|
53
|
+
resource "epcc_node_product" "electric_ranges_be_electric_range" {
|
54
|
+
hierarchy_id = epcc_hierarchy.major_appliances.id
|
55
|
+
node_id = epcc_node.electric_ranges.id
|
56
|
+
product_id = epcc_product.be_electric_range.id
|
57
|
+
}
|
58
|
+
|
59
|
+
resource "epcc_product" "be_gas_range" {
|
60
|
+
name = "BestEver Gas Range"
|
61
|
+
sku = "BE-Gas-Range-2b2b"
|
62
|
+
slug = "bestever-range-2b2b"
|
63
|
+
description = "This gas model includes a convection oven."
|
64
|
+
status = "live"
|
65
|
+
commodity_type = "physical"
|
66
|
+
upc_ean = "222233334444"
|
67
|
+
mpn = "BE-R-2222-bbbb-2b2b"
|
68
|
+
}
|
69
|
+
|
70
|
+
resource "epcc_node_product" "gas_ranges_bestever_gas_range" {
|
71
|
+
hierarchy_id = epcc_hierarchy.major_appliances.id
|
72
|
+
node_id = epcc_node.gas_ranges.id
|
73
|
+
product_id = epcc_product.be_gas_range.id
|
74
|
+
}
|
75
|
+
|
76
|
+
resource "epcc_currency" "british_pound_sterling" {
|
77
|
+
code = "GBP"
|
78
|
+
exchange_rate = 1
|
79
|
+
format = "£{price}"
|
80
|
+
decimal_point = "."
|
81
|
+
thousand_separator = ","
|
82
|
+
decimal_places = 2
|
83
|
+
default = false
|
84
|
+
enabled = true
|
85
|
+
}
|
86
|
+
|
87
|
+
resource "epcc_pricebook" "preferred_pricing" {
|
88
|
+
name = "Preferred Pricing"
|
89
|
+
description = "Catalog with pricing suitable for high-volume customers."
|
90
|
+
}
|
91
|
+
|
92
|
+
resource "epcc_product_price" "be_electric_range_price" {
|
93
|
+
currency {
|
94
|
+
code = "USD"
|
95
|
+
amount = 300000
|
96
|
+
includes_tax = false
|
97
|
+
}
|
98
|
+
currency {
|
99
|
+
code = epcc_currency.british_pound_sterling.code
|
100
|
+
amount = 250000
|
101
|
+
includes_tax = false
|
102
|
+
}
|
103
|
+
pricebook_id = epcc_pricebook.preferred_pricing.id
|
104
|
+
sku = epcc_product.be_electric_range.sku
|
105
|
+
}
|
106
|
+
|
107
|
+
resource "epcc_product_price" "be_gas_range_price" {
|
108
|
+
currency {
|
109
|
+
code = "USD"
|
110
|
+
amount = 350000
|
111
|
+
includes_tax = false
|
112
|
+
}
|
113
|
+
currency {
|
114
|
+
code = epcc_currency.british_pound_sterling.code
|
115
|
+
amount = 300000
|
116
|
+
includes_tax = false
|
117
|
+
}
|
118
|
+
pricebook_id = epcc_pricebook.preferred_pricing.id
|
119
|
+
sku = epcc_product.be_gas_range.sku
|
120
|
+
}
|
121
|
+
|
122
|
+
resource "epcc_catalog" "ranges_catalog" {
|
123
|
+
name = "Ranges Catalog"
|
124
|
+
description = "Catalog of Ranges"
|
125
|
+
hierarchies = [epcc_hierarchy.major_appliances.id]
|
126
|
+
pricebook = epcc_pricebook.preferred_pricing.id
|
127
|
+
}
|
128
|
+
|
129
|
+
resource "epcc_customer" "billy_bob" {
|
130
|
+
name = "Billy Bob"
|
131
|
+
email = "billybob@example.com"
|
132
|
+
}
|
133
|
+
|
134
|
+
resource "epcc_catalog_rule" "preferred_customer_pricing" {
|
135
|
+
name = "Preferred Customer Pricing"
|
136
|
+
description = "Preferred customer pricing"
|
137
|
+
catalog = epcc_catalog.ranges_catalog.id
|
138
|
+
customers = [epcc_customer.billy_bob.id]
|
139
|
+
}
|
140
|
+
|
141
|
+
output "epcc_hierarchy_id" {
|
142
|
+
value = epcc_hierarchy.major_appliances.id
|
143
|
+
}
|
144
|
+
|
145
|
+
output "epcc_product_id" {
|
146
|
+
value = epcc_product.be_electric_range.id
|
147
|
+
}
|
148
|
+
|
149
|
+
output "epcc_customer_id" {
|
150
|
+
value = epcc_customer.billy_bob.id
|
151
|
+
}
|
152
|
+
|
153
|
+
output "epcc_customer_email" {
|
154
|
+
value = epcc_customer.billy_bob.email
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
output "epcc_catalog_id" {
|
159
|
+
value = epcc_catalog.ranges_catalog.id
|
160
|
+
}
|
161
|
+
|
162
|
+
output "epcc_currency_id" {
|
163
|
+
value = epcc_currency.british_pound_sterling.id
|
164
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "@field123/hacksprint-2022-js-sdk-test-response-generation",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"main": "dist/cli.js",
|
5
|
+
"repository": "https://gitlab.elasticpath.com/Michelle.Wan/hacksprint-2022-js-sdk-test-response-generation.git",
|
6
|
+
"author": "Elastic Path",
|
7
|
+
"scripts": {
|
8
|
+
"postinstall": "terraform init && terraform get",
|
9
|
+
"build": "tsup && yarn build:copy:terra",
|
10
|
+
"build:copy:terra": "cp package.json dist/ && cp README.md dist/ && cp main.tf dist/",
|
11
|
+
"semantic-release": "semantic-release"
|
12
|
+
},
|
13
|
+
"files": [
|
14
|
+
"dist/"
|
15
|
+
],
|
16
|
+
"devDependencies": {
|
17
|
+
"@semantic-release/git": "^10.0.1",
|
18
|
+
"@semantic-release/gitlab": "^9.1.0",
|
19
|
+
"@semantic-release/npm": "^9.0.1",
|
20
|
+
"@types/node": "^17.0.23",
|
21
|
+
"semantic-release": "^19.0.2",
|
22
|
+
"tsup": "^5.12.4",
|
23
|
+
"typescript": "^4.6.3"
|
24
|
+
},
|
25
|
+
"dependencies": {
|
26
|
+
"@field123/newman-reporter-ep-resp": "^0.0.5",
|
27
|
+
"@jahed/terraform": "1.1.7",
|
28
|
+
"@types/newman": "^5.3.0",
|
29
|
+
"axios": "^0.26.1",
|
30
|
+
"commander": "^9.1.0",
|
31
|
+
"dotenv": "^16.0.0",
|
32
|
+
"newman": "^5.3.2"
|
33
|
+
},
|
34
|
+
"publishConfig": {
|
35
|
+
"access": "public"
|
36
|
+
},
|
37
|
+
"bin": {
|
38
|
+
"hacksprint-2022-js-sdk-test-response-generation": "dist/cli.js"
|
39
|
+
}
|
40
|
+
}
|
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "@field123/hacksprint-2022-js-sdk-test-response-generation",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2",
|
4
4
|
"main": "dist/cli.js",
|
5
5
|
"repository": "https://gitlab.elasticpath.com/Michelle.Wan/hacksprint-2022-js-sdk-test-response-generation.git",
|
6
6
|
"author": "Elastic Path",
|
7
7
|
"scripts": {
|
8
8
|
"postinstall": "terraform init && terraform get",
|
9
|
-
"build": "tsup",
|
9
|
+
"build": "tsup && yarn build:copy:terra",
|
10
|
+
"build:copy:terra": "cp package.json dist/ && cp README.md dist/ && cp main.tf dist/",
|
10
11
|
"semantic-release": "semantic-release"
|
11
12
|
},
|
12
13
|
"files": [
|