From 63317b1ee29a79c40c21cd0428c0adec20351226 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Tue, 18 May 2021 00:36:50 +0300 Subject: [PATCH 1/2] docs: add '.pubnub.yml' file Add `.pubnub.yml` file with change logs and distirbution options. build: Add '.pubnub.yml' validators Add GitH ub Actions for `.pubnub.yml` file validation. --- .github/workflows/validate-pubnub-yml.yml | 24 ++++ .github/workflows/validate-yml.js | 94 ++++++++++++ .pubnub.yml | 168 ++++++++++++++++++++++ 3 files changed, 286 insertions(+) create mode 100644 .github/workflows/validate-pubnub-yml.yml create mode 100644 .github/workflows/validate-yml.js create mode 100644 .pubnub.yml diff --git a/.github/workflows/validate-pubnub-yml.yml b/.github/workflows/validate-pubnub-yml.yml new file mode 100644 index 0000000..5394742 --- /dev/null +++ b/.github/workflows/validate-pubnub-yml.yml @@ -0,0 +1,24 @@ +name: validate-pubnub-yml + +# Controls when the action will run. Workflow runs when manually triggered using the UI +# or API. +on: [push] + +jobs: + build: + name: Validate PubNub yml + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '12.x' + - name: Install dependencies + run: | + npm install ajv@6.12.6 + npm install yaml@1.10.0 + npm install node-fetch@2.6.1 + npm install chalk@2.4.2 + - name: Validate + run: GITHUB_TOKEN=${{ secrets.GH_TOKEN }} node ./.github/workflows/validate-yml.js \ No newline at end of file diff --git a/.github/workflows/validate-yml.js b/.github/workflows/validate-yml.js new file mode 100644 index 0000000..7607296 --- /dev/null +++ b/.github/workflows/validate-yml.js @@ -0,0 +1,94 @@ +const YAML = require('yaml') +const Ajv = require('ajv'); +const fetch = require('node-fetch'); +const fs = require('fs'); +const chalk = require('chalk'); + +const ghToken = process.env.GITHUB_TOKEN; +const ghHeaders = {'User-Agent': 'sdk-bot', 'Authorization': 'token ' + ghToken,'Accept': 'application/vnd.github.v3.raw'}; + +const sdkReposJSONBranch = "develop"; +let sdkReposJSONPath = "http://api.github.com/repos/pubnub/documentation-resources/contents/website-common/tools/build/sdk-repos.json?ref=" + sdkReposJSONBranch; +startExecution(sdkReposJSONPath); + +async function startExecution(sdkReposJSONPath){ + var sdkRepos = await requestGetFromGithub(sdkReposJSONPath); + var sdkReposAndFeatureMappingArray = parseReposAndFeatureMapping(sdkRepos); + var schemaText = await requestGetFromGithub(sdkReposAndFeatureMappingArray[2]); + + schema = JSON.parse(schemaText); + var yaml = fs.readFileSync(".pubnub.yml", 'utf8'); + + if(yaml != null){ + yml = YAML.parse(yaml); + var ajv = new Ajv({schemaId: 'id', "verbose":true, "allErrors": true}); + const validate = ajv.compile(schema); + const valid = validate(yml); + if (validate.errors!= null) { + console.log(chalk.cyan("===================================")); + console.log(chalk.red(yml["version"] + " validation errors...")); + console.log(chalk.cyan("===================================")); + console.log(validate.errors); + console.log(chalk.cyan("===================================")); + var result = {code:1, repo: yml["version"], msg: "validation errors"}; + printResult(result); + process.exit(1); + } + else { + var result = {code: 0, repo: yml["version"], msg: "validation pass"}; + printResult(result); + } + } else { + var result = {code:1, repo: "yml null", msg: "validation errors"}; + printResult(result); + process.exit(1); + } +} + +function printResult(result){ + var str = result.repo + ", " + result.msg; + if(result.code === 0){ + console.log(chalk.green(str) + ", Code: " + result.code); + } else { + console.log(chalk.red(str) + ", Code: " + result.code); + } +} + +async function requestGetFromGithub(url){ + try { + const response = await fetch(url, { + headers: ghHeaders, + method: 'get', + }); + if(response.status == 200){ + const json = await response.text(); + return json; + } else { + console.error(chalk.red("res.status: " + response.status + "\n URL: " + url)); + return null; + } + + } catch (error) { + console.error(chalk.red("requestGetFromGithub: " + error + "\n URL: " + url)); + return null; + } +} + +function parseReposAndFeatureMapping(body){ + if(body != null){ + var sdkRepos = JSON.parse(body); + var locations = sdkRepos["locations"]; + if(locations!=null){ + var sdkURLs = locations["sdks"]; + var featureMappingURL = locations["featureMapping"]; + var pubnubYAMLSchemaURL = locations["pubnubYAMLSchema"]; + return [sdkURLs, featureMappingURL, pubnubYAMLSchemaURL]; + } else { + console.log(chalk.red("response locations null")); + return null; + } + } else { + console.log(chalk.red("response body null")); + return null; + } +} \ No newline at end of file diff --git a/.pubnub.yml b/.pubnub.yml new file mode 100644 index 0000000..442ae14 --- /dev/null +++ b/.pubnub.yml @@ -0,0 +1,168 @@ +--- +name: eon-map +scm: https://github.com/pubnub/eon-map +version: "1.2.2" +schema: 1 +files: + - ./eon-map.js +changelog: + - version: 1.2.2 + date: 2017-07-08 + changes: + - type: improvement + text: "Remove bad error checks." + - version: 1.2.1 + date: 2017-07-08 + changes: + - type: bug + text: "Fix require path for `mapbox.js`." + - type: improvement + text: "Add channels / groups verifications." + - type: improvement + text: "Add default map zoom and center location." + - version: 1.2.0 + date: 2017-07-07 + changes: + - type: improvement + text: "Move from Bower builds to Webpack" + - type: improvement + text: "Update keys used by demos." + - version: 1.1.4 + date: 2017-06-02 + changes: + - type: bug + text: "Fix mapbox dependency." + - version: 1.1.3 + date: 2017-06-02 + changes: + - type: improvement + text: "Update mapbox to v3" + - version: 1.1.1 + date: 2017-06-02 + changes: + - type: feature + text: "Add Leaflet Mutant plugin to display baselayers using mutation observers." + - version: 1.1.0 + date: 2017-06-02 + changes: + - type: feature + text: "Add Google maps support." +features: + channel-groups: + - CHANNEL-GROUPS-LIST-CHANNELS-IN-GROUP + storage: + - STORAGE-INCLUDE-TIMETOKEN + - STORAGE-COUNT + - STORAGE-FETCH-MESSAGES + subscribe: + - SUBSCRIBE-CHANNELS + - SUBSCRIBE-CHANNEL-GROUPS + - SUBSCRIBE-PUBSUB-V2 +sdks: + - full-name: EON Maps Framework + short-name: EON Maps + artifacts: + - artifact-type: framework + language: JavaScript + tier: 3 + tags: + - Web + source-repository: https://github.com/pubnub/eon-map + documentation: https://www.pubnub.com/developers/eon + distributions: + - distribution-type: source + distribution-repository: GitHub release + package-name: EON Maps Framework + location: https://github.com/pubnub/eon-map/releases/tag/1.2.2 + supported-platforms: + supported-browsers: + minimun-supported-version: + - Safari 10.0 + - Mozilla Firefox 51.0 + - Google Chrome 56.0 + - Opera 41.0 + - Microsoft Edge 38 + requires: + - name: google-maps + min-version: 3.2.1 + max-version: 3.3.0 + location: Shipped within framework + license: MIT + license-url: https://github.com/davidkudera/google-maps-loader/blob/master/LICENSE + is-required: Required + - name: leaflet + min-version: 1.0.3 + max-version: 1.7.1 + location: Shipped within framework + license: BSD-2-Clause + license-url: https://github.com/Leaflet/Leaflet/blob/master/LICENSE + is-required: Required + - name: leaflet.gridlayer.googlemutant + min-version: 0.6.2 + max-version: 0.6.4 + location: Shipped within framework + license: Beerware + license-url: https://gitlab.com/IvanSanchez/Leaflet.GridLayer.GoogleMutant/-/blob/master/LICENSE + is-required: Required + - name: mapbox.js + min-version: 3.1.1 + max-version: 3.3.1 + location: Shipped within framework + license: BSD-3-Clause + license-url: https://github.com/mapbox/mapbox.js/blob/publisher-production/LICENSE.md + is-required: Required + - name: pubnub + min-version: 4.0.13 + max-version: 4.32.0 + location: Shipped within framework + license: MIT + license-url: https://github.com/pubnub/javascript/blob/master/LICENSE + is-required: Required + - distribution-type: package + distribution-repository: NPM + package-name: EON Maps Framework + location: https://www.npmjs.com/package/eon-map + supported-platforms: + supported-browsers: + minimun-supported-version: + - Safari 10.0 + - Mozilla Firefox 51.0 + - Google Chrome 56.0 + - Opera 41.0 + - Microsoft Edge 38 + requires: + - name: google-maps + min-version: 3.2.1 + max-version: 3.3.0 + location: Shipped within framework + license: MIT + license-url: https://github.com/davidkudera/google-maps-loader/blob/master/LICENSE + is-required: Required + - name: leaflet + min-version: 1.0.3 + max-version: 1.7.1 + location: Shipped within framework + license: BSD-2-Clause + license-url: https://github.com/Leaflet/Leaflet/blob/master/LICENSE + is-required: Required + - name: leaflet.gridlayer.googlemutant + min-version: 0.6.2 + max-version: 0.6.4 + location: Shipped within framework + license: Beerware + license-url: https://gitlab.com/IvanSanchez/Leaflet.GridLayer.GoogleMutant/-/blob/master/LICENSE + is-required: Required + - name: mapbox.js + min-version: 3.1.1 + max-version: 3.3.1 + location: Shipped within framework + license: BSD-3-Clause + license-url: https://github.com/mapbox/mapbox.js/blob/publisher-production/LICENSE.md + is-required: Required + - name: pubnub + min-version: 4.0.13 + max-version: 4.32.0 + location: Shipped within framework + license: MIT + license-url: https://github.com/pubnub/javascript/blob/master/LICENSE + is-required: Required From acf6b770199b5d59736c81cbd31cff7ee8d4f4ba Mon Sep 17 00:00:00 2001 From: Rajat Kalsy Date: Tue, 7 Sep 2021 18:28:18 +0530 Subject: [PATCH 2/2] Update .pubnub.yml --- .pubnub.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pubnub.yml b/.pubnub.yml index 442ae14..cf9b2e5 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -61,10 +61,10 @@ features: sdks: - full-name: EON Maps Framework short-name: EON Maps + tier: 3 artifacts: - artifact-type: framework language: JavaScript - tier: 3 tags: - Web source-repository: https://github.com/pubnub/eon-map