Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 48 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
node-version: '18.x'
- name: Install dependencies
run: npm install
- name: Build
run: npm run prepack
- name: Upload dist
uses: actions/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,66 @@ 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)

<!-- toc -->

- [Usage](#usage)
- [Commands](#commands)
* [cli-cm-regex-validate](#cli-cm-regex-validate)
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->

# Usage

<!-- 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
...
```

<!-- usagestop -->

# Commands

<!-- commands -->

- [`csdx cm:stacks:validate-regex`](#csdx-cmstacksvalidate-regex)
* [`csdx cm:stacks:validate-regex`](#csdx-cmstacksvalidate-regex)

## `csdx cm:stacks:validate-regex`

This command is used to find all the invalid regexes present in the content types and global fields of your stack.

```
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 <value>] [-c] [-g] [-f <value>]

-g, --globalField To find invalid regexes within the global fields
FLAGS
-a, --alias=<value> Alias (name) assigned to the management token
-c, --contentType To find invalid regexes within the content types
-f, --filePath=<value> [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 <management_token_alias>

$ csdx cm:stacks:validate-regex -c

$ csdx cm:stacks:validate-regex -g

$ csdx cm:stacks:validate-regex -f <path/to/the/directory>

$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g

$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>
```

_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)_
<!-- commandsstop -->
61 changes: 61 additions & 0 deletions oclif.manifest.json
Original file line number Diff line number Diff line change
@@ -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 <management_token_alias>",
"$ csdx cm:stacks:validate-regex -c",
"$ csdx cm:stacks:validate-regex -g",
"$ csdx cm:stacks:validate-regex -f <path/to/the/directory>",
"$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g",
"$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>"
],
"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": {}
}
}
}
47 changes: 25 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions src/utils/generate-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
}