From 4bf760db45b9db01559dce1cb2b959dcf4e6f048 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Wed, 21 Jun 2023 12:26:04 +0530 Subject: [PATCH 1/9] fix: removed console.log statements --- README.md | 2 +- oclif.manifest.json | 61 ++++++++++++++++++++++++++++++++++++ src/utils/generate-output.ts | 10 +++--- 3 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 oclif.manifest.json diff --git a/README.md b/README.md index 9c9ca6a..b20cdd2 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-cm-regex-validate $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-regex-validate/1.1.4 darwin-arm64 node-v16.19.0 +@contentstack/cli-cm-regex-validate/1.1.4 darwin-arm64 node-v18.15.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/oclif.manifest.json b/oclif.manifest.json new file mode 100644 index 0000000..8f83713 --- /dev/null +++ b/oclif.manifest.json @@ -0,0 +1,61 @@ +{ + "version": "1.1.4", + "commands": { + "cm:stacks:validate-regex": { + "id": "cm:stacks:validate-regex", + "description": "This command is used to find all the invalid regexes present in the content types and global fields of your stack.", + "strict": true, + "pluginName": "@contentstack/cli-cm-regex-validate", + "pluginAlias": "@contentstack/cli-cm-regex-validate", + "pluginType": "core", + "aliases": [], + "examples": [ + "$ csdx cm:stacks:validate-regex", + "$ csdx cm:stacks:validate-regex -a ", + "$ csdx cm:stacks:validate-regex -c", + "$ csdx cm:stacks:validate-regex -g", + "$ csdx cm:stacks:validate-regex -f ", + "$ csdx cm:stacks:validate-regex -a -c -g", + "$ csdx cm:stacks:validate-regex -a -c -g -f " + ], + "flags": { + "help": { + "name": "help", + "type": "boolean", + "char": "h", + "description": "To show the flags that can be used with this CLI command", + "allowNo": false + }, + "alias": { + "name": "alias", + "type": "option", + "char": "a", + "description": "Alias (name) assigned to the management token", + "multiple": false + }, + "contentType": { + "name": "contentType", + "type": "boolean", + "char": "c", + "description": "To find invalid regexes within the content types", + "allowNo": false + }, + "globalField": { + "name": "globalField", + "type": "boolean", + "char": "g", + "description": "To find invalid regexes within the global fields", + "allowNo": false + }, + "filePath": { + "name": "filePath", + "type": "option", + "char": "f", + "description": "[optional] The path or the location in your file system where the CSV output file should be stored.", + "multiple": false + } + }, + "args": {} + } + } +} \ No newline at end of file diff --git a/src/utils/generate-output.ts b/src/utils/generate-output.ts index 43e40a8..dc6c571 100644 --- a/src/utils/generate-output.ts +++ b/src/utils/generate-output.ts @@ -2,6 +2,7 @@ import * as jsonexport from 'jsonexport' import * as Table from 'cli-table3' import * as path from 'path' import * as fs from 'fs' +import { cliux } from '@contentstack/cli-utilities' const regexMessages = require('../../messages/index.json').validateRegex export default async function generateOutput(flags: any, invalidRegex: any, tableData: any) { @@ -28,10 +29,11 @@ export default async function generateOutput(flags: any, invalidRegex: any, tabl tableData.forEach((row: any) => { table.push(row) }) - console.log(table.toString()) - console.log(regexMessages.output.csvOutput, storagePath) - console.log(regexMessages.output.docsLink) + cliux.print(table.toString()) + cliux.print(regexMessages.output.csvOutput) + cliux.print(storagePath) + cliux.print(regexMessages.output.docsLink) } else { - console.log(regexMessages.output.noInvalidRegex) + cliux.print(regexMessages.output.noInvalidRegex) } } From 95a68374ebef890d607be10e694d07bda281c6fe Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Wed, 21 Jun 2023 13:17:31 +0530 Subject: [PATCH 2/9] fix: updated versions --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 883ac16..fc3989b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-regex-validate", "description": "Validate Fields with Regex Property of Content Type and Global Field in a Stack", - "version": "1.1.4", + "version": "1.1.5", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli-cm-regex-validate/issues", "devDependencies": { @@ -62,8 +62,8 @@ "version": "oclif-dev readme && git add README.md" }, "dependencies": { - "@contentstack/cli-command": "^1.2.7", - "@contentstack/cli-utilities": "^1.4.3", + "@contentstack/cli-command": "^1.2.9", + "@contentstack/cli-utilities": "^1.4.5", "@contentstack/management": "^1.8.0", "cli-table3": "^0.6.0", "cli-ux": "^6.0.9", From 0a56cf1653319c3afa98a9a61eac8d10254a21f4 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 22 Jun 2023 13:08:08 +0530 Subject: [PATCH 3/9] fix: combined two display message into one variable --- src/utils/generate-output.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/generate-output.ts b/src/utils/generate-output.ts index dc6c571..2d037c2 100644 --- a/src/utils/generate-output.ts +++ b/src/utils/generate-output.ts @@ -29,9 +29,9 @@ export default async function generateOutput(flags: any, invalidRegex: any, tabl tableData.forEach((row: any) => { table.push(row) }) + let messageAndPath = `${regexMessages.output.csvOutput} ${storagePath}` cliux.print(table.toString()) - cliux.print(regexMessages.output.csvOutput) - cliux.print(storagePath) + cliux.print(messageAndPath) cliux.print(regexMessages.output.docsLink) } else { cliux.print(regexMessages.output.noInvalidRegex) From be4430410366f4efefa9f3eb61dbfb69d509066e Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 22 Jun 2023 13:20:00 +0530 Subject: [PATCH 4/9] fix: updated README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b20cdd2..dbc00d4 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-cm-regex-validate $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-regex-validate/1.1.4 darwin-arm64 node-v18.15.0 +@contentstack/cli-cm-regex-validate/1.1.5 darwin-arm64 node-v18.15.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND @@ -69,5 +69,5 @@ EXAMPLES $ csdx cm:stacks:validate-regex -a -c -g -f ``` -_See code: [src/commands/cm/stacks/validate-regex.ts](https://github.com/contentstack/cli-cm-regex-validate/blob/v1.1.4/src/commands/cm/stacks/validate-regex.ts)_ +_See code: [src/commands/cm/stacks/validate-regex.ts](https://github.com/contentstack/cli-cm-regex-validate/blob/v1.1.5/src/commands/cm/stacks/validate-regex.ts)_ From bc3e7159beee623022f4fae7483efcbca155bec0 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 22 Jun 2023 13:24:26 +0530 Subject: [PATCH 5/9] fix: updated package.json and README --- README.md | 46 ++++++++++++++++++++++++---------------------- package.json | 2 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 0d5c91e..282a154 100644 --- a/README.md +++ b/README.md @@ -8,35 +8,31 @@ Validate Fields with Regex Property of Content Type and Global Field in a Stack [![License](https://img.shields.io/npm/l/cli-cm-regex-validate.svg)](https://github.com/contentstack/cli-cm-regex-validate/blob/master/package.json) - -- [Usage](#usage) -- [Commands](#commands) +* [cli-cm-regex-validate](#cli-cm-regex-validate) +* [Usage](#usage) +* [Commands](#commands) # Usage - ```sh-session -$ npm install -g @contentstack/cli -$ csdx plugins:install @contentstack/cli-cm-regex-validate +$ npm install -g @contentstack/cli-cm-regex-validate $ csdx COMMAND running command... -$ csdx (-v|--version|version) -@contentstack/cli-cm-regex-validate/1.1.5 darwin-x64 node-v16.17.0 +$ csdx (--version) +@contentstack/cli-cm-regex-validate/1.1.6 darwin-arm64 node-v18.15.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND ... ``` - # Commands - -- [`csdx cm:stacks:validate-regex`](#csdx-cmstacksvalidate-regex) +* [`csdx cm:stacks:validate-regex`](#csdx-cmstacksvalidate-regex) ## `csdx cm:stacks:validate-regex` @@ -44,28 +40,34 @@ This command is used to find all the invalid regexes present in the content type ``` USAGE - $ csdx cm:stacks:validate-regex - -OPTIONS - -a, --alias=alias Alias (name) assigned to the management token - -c, --contentType To find invalid regexes within the content types - - -f, --filePath=filePath [optional] The path or the location in your file system where the CSV output file should be - stored. + $ csdx cm:stacks:validate-regex [-h] [-a ] [-c] [-g] [-f ] - -g, --globalField To find invalid regexes within the global fields +FLAGS + -a, --alias= Alias (name) assigned to the management token + -c, --contentType To find invalid regexes within the content types + -f, --filePath= [optional] The path or the location in your file system where the CSV output file should be + stored. + -g, --globalField To find invalid regexes within the global fields + -h, --help To show the flags that can be used with this CLI command - -h, --help To show the flags that can be used with this CLI command +DESCRIPTION + This command is used to find all the invalid regexes present in the content types and global fields of your stack. EXAMPLES $ csdx cm:stacks:validate-regex + $ csdx cm:stacks:validate-regex -a + $ csdx cm:stacks:validate-regex -c + $ csdx cm:stacks:validate-regex -g + $ csdx cm:stacks:validate-regex -f + $ csdx cm:stacks:validate-regex -a -c -g + $ csdx cm:stacks:validate-regex -a -c -g -f ``` -_See code: [src/commands/cm/stacks/validate-regex.ts](https://github.com/contentstack/cli-cm-regex-validate/blob/v1.1.5/src/commands/cm/stacks/validate-regex.ts)_ +_See code: [src/commands/cm/stacks/validate-regex.ts](https://github.com/contentstack/cli-cm-regex-validate/blob/v1.1.6/src/commands/cm/stacks/validate-regex.ts)_ diff --git a/package.json b/package.json index c633c80..0ccbccc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-regex-validate", "description": "Validate Fields with Regex Property of Content Type and Global Field in a Stack", - "version": "1.1.5", + "version": "1.1.6", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli-cm-regex-validate/issues", "devDependencies": { From 0c51faf93696bb22de19b277ad0f1aead11d4dd4 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 22 Jun 2023 13:25:56 +0530 Subject: [PATCH 6/9] fix: added npm audit fixes --- package-lock.json | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 94778be..6f0bcf8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@contentstack/cli-cm-regex-validate", - "version": "1.1.5", + "version": "1.1.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/cli-cm-regex-validate", - "version": "1.1.5", + "version": "1.1.6", "license": "MIT", "dependencies": { - "@contentstack/cli-command": "^1.2.7", - "@contentstack/cli-utilities": "^1.4.3", + "@contentstack/cli-command": "^1.2.9", + "@contentstack/cli-utilities": "^1.4.5", "@contentstack/management": "^1.8.0", "cli-table3": "^0.6.0", "cli-ux": "^6.0.9", @@ -650,11 +650,11 @@ } }, "node_modules/@contentstack/cli-command": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.2.8.tgz", - "integrity": "sha512-DYACPLKVK9+CsTynrCIGPaXoyb+Ruv+uRlE0/WFp6cnrmYRtajUnx9vi+UHZj6RYqMxnTnQcRFLZiX0e6JzdOw==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.2.9.tgz", + "integrity": "sha512-kmAIWUtEib6VnME2A2RN/ltLrVzaijgvczbMFQoFJZBvHkyZQ8yn+406EY1sq/DB8vGuHYRz+4RMIZ8G8y034g==", "dependencies": { - "@contentstack/cli-utilities": "^1.4.4", + "@contentstack/cli-utilities": "^1.4.5", "contentstack": "^3.10.1" }, "engines": { @@ -662,9 +662,9 @@ } }, "node_modules/@contentstack/cli-utilities": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.4.4.tgz", - "integrity": "sha512-WJCWwpe5XAB+dhz/nn2eeQCoy6YJen6bvT3/S4Xdb6EMlKv5fh9S6zHNwDri3bHtWrc5sF8iimwaAHyDdfSP6A==", + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.4.5.tgz", + "integrity": "sha512-rAOHX6ZKfBfdRA0VtIrs3a2QOZIq3yIlNSLY0cqksRDvqvnsUa0wwyKjew2pvDkP4tVXOrVm5S5rjwW7a74MIw==", "dependencies": { "@contentstack/management": "^1.8.0", "@oclif/core": "^2.8.2", @@ -3089,9 +3089,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1343.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1343.0.tgz", - "integrity": "sha512-p9+bgEeD2HxFMLAl5IyqvxfmFzuzSwyvoKfEaGL3+0Vndztv7TvCbHfKNH6olY9DjyLrq9f34fJ98owGD8sHnQ==", + "version": "2.1402.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1402.0.tgz", + "integrity": "sha512-ndyx3H+crHPIXJF+SO1dqzzBmQwMdoB9uCND/Ip4Ozfv5jse7X58LWpWucM9KBctQ8o37c8KvXjfTr14lE3ykA==", "dev": true, "dependencies": { "buffer": "4.9.2", @@ -3103,7 +3103,7 @@ "url": "0.10.3", "util": "^0.12.4", "uuid": "8.0.0", - "xml2js": "0.4.19" + "xml2js": "0.5.0" }, "engines": { "node": ">= 10.0.0" @@ -12599,19 +12599,22 @@ } }, "node_modules/xml2js": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", - "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", + "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", "dev": true, "dependencies": { "sax": ">=0.6.0", - "xmlbuilder": "~9.0.1" + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" } }, "node_modules/xmlbuilder": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", - "integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", "dev": true, "engines": { "node": ">=4.0" From 005c168bdda7828fd4af0fb044a3ced30e691dd1 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Mon, 3 Jul 2023 17:51:20 +0530 Subject: [PATCH 7/9] changed node-version to 18 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7db02c..67f53a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: "16.x" + node-version: "18.x" - run: npm install - name: get-npm-version From 39d3cef7ab4676570037df549aae8fc1dff9ad12 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Thu, 13 Jul 2023 15:39:07 +0530 Subject: [PATCH 8/9] Modfied the release workflow --- .github/workflows/release.yml | 86 +++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67f53a8..18a7b7f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,50 +1,60 @@ -name: Releases - +name: Release on: push: - branches: [main] - + branches: + - [main] jobs: build: + name: Build and upload runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - name: Checkout + uses: actions/checkout@v3.5.3 with: - node-version: "18.x" - - run: npm install - - - name: get-npm-version - id: package-version - uses: martinbeentjes/npm-get-version-action@master - - name: install npm packall - run: npm install npm-pack-all + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3.7.0 + with: + node-version: '18.x' + - name: Install dependencies + run: npm install + - name: Build + run: npm run prepack + - name: Upload dist + uses: actions/upload-artifact@v3.1.2 + with: + name: lib + path: lib - - run: node node_modules/.bin/npm-pack-all - - uses: Klemensas/action-autotag@stable - id: update_tag + release: + name: Download dist and release + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout + uses: actions/checkout@v3.5.3 with: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - tag_prefix: "v" - - name: Create Release - if: steps.update_tag.outputs.tagname - uses: actions/create-release@v1 - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3.7.0 + with: + node-version: '18.x' + - name: Install dependencies + run: npm install + - name: Download dist + uses: actions/download-artifact@v3 with: - tag_name: ${{ steps.update_tag.outputs.tagname }} - release_name: Release ${{ steps.update_tag.outputs.tagname }} - draft: false # Default value, but nice to set explicitly - prerelease: false # Default value, but nice to set explicitly - - name: Upload Release Asset - if: steps.update_tag.outputs.tagname - id: upload-release-asset - uses: actions/upload-release-asset@v1 + name: lib + path: lib + - name: Display dirs + run: ls -R + - name: Release + id: release-plugin + uses: JS-DevTools/npm-publish@v2.2.0 + with: + token: ${{ secrets.NPM_TOKEN }} + - name: github-release + id: github-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./contentstack-cli-cm-regex-validate-${{ steps.package-version.outputs.current-version }}.tgz - asset_name: contentstack-cli-cm-regex-validate-${{ steps.package-version.outputs.current-version }}.tgz - asset_content_type: application/tgz + run: gh release create v${{ steps.release-plugin.outputs.version }} --title "Release ${{ steps.release-plugin.outputs.version }}" --generate-notes \ No newline at end of file From 235610c2d377307f7888968869944ad5a6c73817 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Fri, 14 Jul 2023 17:20:34 +0530 Subject: [PATCH 9/9] resolved error in release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18a7b7f..7561662 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: push: branches: - - [main] + - main jobs: build: name: Build and upload