diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7db02c..7561662 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: "16.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 diff --git a/README.md b/README.md index 8cf485d..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,29 +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/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/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" diff --git a/package.json b/package.json index bf79a5c..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": { @@ -61,8 +61,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", diff --git a/src/utils/generate-output.ts b/src/utils/generate-output.ts index 43e40a8..2d037c2 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) + let messageAndPath = `${regexMessages.output.csvOutput} ${storagePath}` + cliux.print(table.toString()) + cliux.print(messageAndPath) + cliux.print(regexMessages.output.docsLink) } else { - console.log(regexMessages.output.noInvalidRegex) + cliux.print(regexMessages.output.noInvalidRegex) } }