From ec6f163e3b8e2f36095e83bd8ea8e14b2847c8e8 Mon Sep 17 00:00:00 2001 From: Talisson Ferreira Date: Thu, 5 Mar 2020 13:11:22 -0300 Subject: [PATCH 01/12] chore(pkg): add publish to market script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a112070..2d57146 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "serve": "echo 'Firebase runs with legacy Node.js 8; Use `npm run deploy` instead.'", "deploy": "NODE_ENV=production node ./firebase.js", "release": "standard-version", - "release:starter": "standard-version --prerelease starter" + "release:starter": "standard-version --prerelease starter", + "publish:market": "node ./publish-market.js" }, "repository": { "type": "git", From 6ea2155f7ffa59131e27ea6511b76b2ab955a116 Mon Sep 17 00:00:00 2001 From: Talisson Ferreira Date: Thu, 5 Mar 2020 13:11:56 -0300 Subject: [PATCH 02/12] feat: publish to market --- publish-market.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 publish-market.js diff --git a/publish-market.js b/publish-market.js new file mode 100644 index 0000000..518947a --- /dev/null +++ b/publish-market.js @@ -0,0 +1,49 @@ +'use strict' +const https = require('https') +const storeApp = require('./assets/application.json') +const { MARKET_TOKEN } = process.env + +if (!MARKET_TOKEN) { + console.error('Env MARKET_TOKEN is unset') + process.exit(1) +} + +const { title, slug } = storeApp + +const data = JSON.stringify({ + title, + slug, + category: 'all', + store_app: storeApp +}) + +const opt = { + hostname: 'market.e-com.plus', + port: 443, + path: '/v2/applications', + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + MARKET_TOKEN + } +} + +const req = https.request(opt, res => { + const { statusCode } = res + if (statusCode >= 201 && statusCode <= 204) { + console.log('Application updated') + } else { + console.error('API Request error') + } + res.on('data', d => { + process.stdout.write(d) + }) +}) + +req.on('error', error => { + console.error(error) + process.exit(1) +}) + +req.write(data) +req.end() From 0e847ab19ab2f67bd52098d2817c0a10c52d3162 Mon Sep 17 00:00:00 2001 From: Talisson Ferreira Date: Thu, 5 Mar 2020 13:16:54 -0300 Subject: [PATCH 03/12] ci(publish-market): add workflow to publish or update application on market --- .github/workflows/publish-market.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/publish-market.yml diff --git a/.github/workflows/publish-market.yml b/.github/workflows/publish-market.yml new file mode 100644 index 0000000..6ebf6e6 --- /dev/null +++ b/.github/workflows/publish-market.yml @@ -0,0 +1,26 @@ +name: Publish application in market + +on: + push: + paths: + - "./assets/applications.json" + +jobs: + pulish-market: + name: Publish application in market + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: "12.x" + registry-url: "https://registry.npmjs.org/" + + - name: Publish application in market + env: + MARKET_TOKEN: ${{ secrets.MARKET_TOKEN }} + run: "MARKET_TOKEN=$MARKET_TOKEN npm run publish:market" From 1bb4409b377ad984a1d1e4492a26d3d56b0058c9 Mon Sep 17 00:00:00 2001 From: Talisson Trindade Date: Thu, 5 Mar 2020 13:25:51 -0300 Subject: [PATCH 04/12] Update application.json --- assets/application.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/application.json b/assets/application.json index 3b54c11..1451834 100644 --- a/assets/application.json +++ b/assets/application.json @@ -1,7 +1,7 @@ { "app_id": 9000, "title": "My Awesome E-Com Plus App", - "slug": "my-awesome-ecom-plus-app", + "slug": "my-awesome-ecom-plus-app-V1", "type": "external", "state": "active", "authentication": true, @@ -28,4 +28,4 @@ }, "auth_callback_uri": "https://us-central1-ecom-app-boilerplate.cloudfunctions.net/app/ecom/auth-callback", "version": "1.0.0" -} \ No newline at end of file +} From 62d9237f1c3c2fba730ae09e28b63dbbb4ea3a2a Mon Sep 17 00:00:00 2001 From: Talisson Ferreira Date: Thu, 5 Mar 2020 13:27:46 -0300 Subject: [PATCH 05/12] fix: workflow paths --- .github/workflows/publish-market.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-market.yml b/.github/workflows/publish-market.yml index 6ebf6e6..e9d6a23 100644 --- a/.github/workflows/publish-market.yml +++ b/.github/workflows/publish-market.yml @@ -3,7 +3,7 @@ name: Publish application in market on: push: paths: - - "./assets/applications.json" + - "assets/applications.json" jobs: pulish-market: From 6849a4ed52a528fe89fa22f83c9f2d579841bb48 Mon Sep 17 00:00:00 2001 From: Talisson Trindade Date: Thu, 5 Mar 2020 13:29:25 -0300 Subject: [PATCH 06/12] Update application.json --- assets/application.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/application.json b/assets/application.json index 1451834..4c15562 100644 --- a/assets/application.json +++ b/assets/application.json @@ -1,7 +1,7 @@ { "app_id": 9000, "title": "My Awesome E-Com Plus App", - "slug": "my-awesome-ecom-plus-app-V1", + "slug": "my-awesome-ecom-plus-app-V2", "type": "external", "state": "active", "authentication": true, From 0507bd0ee2fb3c6c4f413f78f90c63b6b46e420e Mon Sep 17 00:00:00 2001 From: Talisson Ferreira Date: Thu, 5 Mar 2020 13:32:09 -0300 Subject: [PATCH 07/12] fix: workflow paths --- .github/workflows/publish-market.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-market.yml b/.github/workflows/publish-market.yml index e9d6a23..b503bf9 100644 --- a/.github/workflows/publish-market.yml +++ b/.github/workflows/publish-market.yml @@ -3,7 +3,7 @@ name: Publish application in market on: push: paths: - - "assets/applications.json" + - 'assets/application.json' jobs: pulish-market: From feca430245f448e58aeaafa76e10abc1993f3aa9 Mon Sep 17 00:00:00 2001 From: Talisson Trindade Date: Thu, 5 Mar 2020 13:33:15 -0300 Subject: [PATCH 08/12] Update application.json --- assets/application.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/application.json b/assets/application.json index 4c15562..1451834 100644 --- a/assets/application.json +++ b/assets/application.json @@ -1,7 +1,7 @@ { "app_id": 9000, "title": "My Awesome E-Com Plus App", - "slug": "my-awesome-ecom-plus-app-V2", + "slug": "my-awesome-ecom-plus-app-V1", "type": "external", "state": "active", "authentication": true, From 8da73d2a65efdec77be8bf01a887f667de5a4405 Mon Sep 17 00:00:00 2001 From: Talisson Ferreira Date: Thu, 5 Mar 2020 13:49:38 -0300 Subject: [PATCH 09/12] ci(publish-market): setted id if application has app_id --- publish-market.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/publish-market.js b/publish-market.js index 518947a..a2615f7 100644 --- a/publish-market.js +++ b/publish-market.js @@ -10,12 +10,18 @@ if (!MARKET_TOKEN) { const { title, slug } = storeApp -const data = JSON.stringify({ +let data = { title, slug, category: 'all', store_app: storeApp -}) +} + +if (storeApp.app_id) { + data.id = storeApp.app_id +} + +data = JSON.stringify(data) const opt = { hostname: 'market.e-com.plus', From e97830e7411bd3a8a7666576c361a1f89ecac8e6 Mon Sep 17 00:00:00 2001 From: Talisson Trindade Date: Thu, 5 Mar 2020 13:54:29 -0300 Subject: [PATCH 10/12] Update application.json --- assets/application.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/application.json b/assets/application.json index 1451834..7a9765c 100644 --- a/assets/application.json +++ b/assets/application.json @@ -1,7 +1,7 @@ { "app_id": 9000, "title": "My Awesome E-Com Plus App", - "slug": "my-awesome-ecom-plus-app-V1", + "slug": "my-awesome-ecom-plus-app-v3", "type": "external", "state": "active", "authentication": true, From 54bb880cb6fd5e8597a6faf456d3463208a7e1f7 Mon Sep 17 00:00:00 2001 From: Talisson Trindade Date: Thu, 5 Mar 2020 13:59:41 -0300 Subject: [PATCH 11/12] Update application.json --- assets/application.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/application.json b/assets/application.json index 7a9765c..6069d51 100644 --- a/assets/application.json +++ b/assets/application.json @@ -1,7 +1,7 @@ { "app_id": 9000, "title": "My Awesome E-Com Plus App", - "slug": "my-awesome-ecom-plus-app-v3", + "slug": "my-awesome-ecom-plus-app-v4", "type": "external", "state": "active", "authentication": true, From f9944733d7a4b2db5bef93177e76de01490c2294 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Thu, 5 Mar 2020 14:22:17 -0300 Subject: [PATCH 12/12] chore: revert to original application.json --- assets/application.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/application.json b/assets/application.json index 6069d51..5c5b9c6 100644 --- a/assets/application.json +++ b/assets/application.json @@ -1,7 +1,7 @@ { "app_id": 9000, "title": "My Awesome E-Com Plus App", - "slug": "my-awesome-ecom-plus-app-v4", + "slug": "my-awesome-ecom-plus-app", "type": "external", "state": "active", "authentication": true,