Skip to content

Commit 3402e74

Browse files
authored
Merge pull request #38 from contentstack/Feat/CS-31377
Feat/cs 31377
2 parents a558450 + 235610c commit 3402e74

File tree

6 files changed

+167
-90
lines changed

6 files changed

+167
-90
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,60 @@
1-
name: Releases
2-
1+
name: Release
32
on:
43
push:
5-
branches: [main]
6-
4+
branches:
5+
- main
76
jobs:
87
build:
8+
name: Build and upload
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
12-
- uses: actions/setup-node@v1
11+
- name: Checkout
12+
uses: actions/[email protected]
1313
with:
14-
node-version: "16.x"
15-
- run: npm install
16-
17-
- name: get-npm-version
18-
id: package-version
19-
uses: martinbeentjes/npm-get-version-action@master
20-
- name: install npm packall
21-
run: npm install npm-pack-all
14+
fetch-depth: 0
15+
- name: Setup Node.js
16+
uses: actions/[email protected]
17+
with:
18+
node-version: '18.x'
19+
- name: Install dependencies
20+
run: npm install
21+
- name: Build
22+
run: npm run prepack
23+
- name: Upload dist
24+
uses: actions/[email protected]
25+
with:
26+
name: lib
27+
path: lib
2228

23-
- run: node node_modules/.bin/npm-pack-all
24-
- uses: Klemensas/action-autotag@stable
25-
id: update_tag
29+
release:
30+
name: Download dist and release
31+
runs-on: ubuntu-latest
32+
needs: build
33+
steps:
34+
- name: Checkout
35+
uses: actions/[email protected]
2636
with:
27-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
28-
tag_prefix: "v"
29-
- name: Create Release
30-
if: steps.update_tag.outputs.tagname
31-
uses: actions/create-release@v1
32-
id: create_release
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
37+
fetch-depth: 0
38+
- name: Setup Node.js
39+
uses: actions/[email protected]
40+
with:
41+
node-version: '18.x'
42+
- name: Install dependencies
43+
run: npm install
44+
- name: Download dist
45+
uses: actions/download-artifact@v3
3546
with:
36-
tag_name: ${{ steps.update_tag.outputs.tagname }}
37-
release_name: Release ${{ steps.update_tag.outputs.tagname }}
38-
draft: false # Default value, but nice to set explicitly
39-
prerelease: false # Default value, but nice to set explicitly
40-
- name: Upload Release Asset
41-
if: steps.update_tag.outputs.tagname
42-
id: upload-release-asset
43-
uses: actions/upload-release-asset@v1
47+
name: lib
48+
path: lib
49+
- name: Display dirs
50+
run: ls -R
51+
- name: Release
52+
id: release-plugin
53+
uses: JS-DevTools/[email protected]
54+
with:
55+
token: ${{ secrets.NPM_TOKEN }}
56+
- name: github-release
57+
id: github-release
4458
env:
4559
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
with:
47-
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
48-
asset_path: ./contentstack-cli-cm-regex-validate-${{ steps.package-version.outputs.current-version }}.tgz
49-
asset_name: contentstack-cli-cm-regex-validate-${{ steps.package-version.outputs.current-version }}.tgz
50-
asset_content_type: application/tgz
60+
run: gh release create v${{ steps.release-plugin.outputs.version }} --title "Release ${{ steps.release-plugin.outputs.version }}" --generate-notes

README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,66 @@ Validate Fields with Regex Property of Content Type and Global Field in a Stack
88
[![License](https://img.shields.io/npm/l/cli-cm-regex-validate.svg)](https://github.com/contentstack/cli-cm-regex-validate/blob/master/package.json)
99

1010
<!-- toc -->
11-
12-
- [Usage](#usage)
13-
- [Commands](#commands)
11+
* [cli-cm-regex-validate](#cli-cm-regex-validate)
12+
* [Usage](#usage)
13+
* [Commands](#commands)
1414
<!-- tocstop -->
1515

1616
# Usage
1717

1818
<!-- usage -->
19-
2019
```sh-session
21-
$ npm install -g @contentstack/cli
22-
$ csdx plugins:install @contentstack/cli-cm-regex-validate
20+
$ npm install -g @contentstack/cli-cm-regex-validate
2321
$ csdx COMMAND
2422
running command...
25-
$ csdx (-v|--version|version)
26-
@contentstack/cli-cm-regex-validate/1.1.5 darwin-x64 node-v16.17.0
23+
$ csdx (--version)
24+
@contentstack/cli-cm-regex-validate/1.1.6 darwin-arm64 node-v18.15.0
2725
$ csdx --help [COMMAND]
2826
USAGE
2927
$ csdx COMMAND
3028
...
3129
```
32-
3330
<!-- usagestop -->
3431

3532
# Commands
3633

3734
<!-- commands -->
38-
39-
- [`csdx cm:stacks:validate-regex`](#csdx-cmstacksvalidate-regex)
35+
* [`csdx cm:stacks:validate-regex`](#csdx-cmstacksvalidate-regex)
4036

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

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

4541
```
4642
USAGE
47-
$ csdx cm:stacks:validate-regex
48-
49-
OPTIONS
50-
-a, --alias=alias Alias (name) assigned to the management token
51-
-c, --contentType To find invalid regexes within the content types
52-
53-
-f, --filePath=filePath [optional] The path or the location in your file system where the CSV output file should be
54-
stored.
43+
$ csdx cm:stacks:validate-regex [-h] [-a <value>] [-c] [-g] [-f <value>]
5544
56-
-g, --globalField To find invalid regexes within the global fields
45+
FLAGS
46+
-a, --alias=<value> Alias (name) assigned to the management token
47+
-c, --contentType To find invalid regexes within the content types
48+
-f, --filePath=<value> [optional] The path or the location in your file system where the CSV output file should be
49+
stored.
50+
-g, --globalField To find invalid regexes within the global fields
51+
-h, --help To show the flags that can be used with this CLI command
5752
58-
-h, --help To show the flags that can be used with this CLI command
53+
DESCRIPTION
54+
This command is used to find all the invalid regexes present in the content types and global fields of your stack.
5955
6056
EXAMPLES
6157
$ csdx cm:stacks:validate-regex
58+
6259
$ csdx cm:stacks:validate-regex -a <management_token_alias>
60+
6361
$ csdx cm:stacks:validate-regex -c
62+
6463
$ csdx cm:stacks:validate-regex -g
64+
6565
$ csdx cm:stacks:validate-regex -f <path/to/the/directory>
66+
6667
$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g
68+
6769
$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>
6870
```
6971

70-
_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)_
71-
72+
_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)_
7273
<!-- commandsstop -->

oclif.manifest.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"version": "1.1.4",
3+
"commands": {
4+
"cm:stacks:validate-regex": {
5+
"id": "cm:stacks:validate-regex",
6+
"description": "This command is used to find all the invalid regexes present in the content types and global fields of your stack.",
7+
"strict": true,
8+
"pluginName": "@contentstack/cli-cm-regex-validate",
9+
"pluginAlias": "@contentstack/cli-cm-regex-validate",
10+
"pluginType": "core",
11+
"aliases": [],
12+
"examples": [
13+
"$ csdx cm:stacks:validate-regex",
14+
"$ csdx cm:stacks:validate-regex -a <management_token_alias>",
15+
"$ csdx cm:stacks:validate-regex -c",
16+
"$ csdx cm:stacks:validate-regex -g",
17+
"$ csdx cm:stacks:validate-regex -f <path/to/the/directory>",
18+
"$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g",
19+
"$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>"
20+
],
21+
"flags": {
22+
"help": {
23+
"name": "help",
24+
"type": "boolean",
25+
"char": "h",
26+
"description": "To show the flags that can be used with this CLI command",
27+
"allowNo": false
28+
},
29+
"alias": {
30+
"name": "alias",
31+
"type": "option",
32+
"char": "a",
33+
"description": "Alias (name) assigned to the management token",
34+
"multiple": false
35+
},
36+
"contentType": {
37+
"name": "contentType",
38+
"type": "boolean",
39+
"char": "c",
40+
"description": "To find invalid regexes within the content types",
41+
"allowNo": false
42+
},
43+
"globalField": {
44+
"name": "globalField",
45+
"type": "boolean",
46+
"char": "g",
47+
"description": "To find invalid regexes within the global fields",
48+
"allowNo": false
49+
},
50+
"filePath": {
51+
"name": "filePath",
52+
"type": "option",
53+
"char": "f",
54+
"description": "[optional] The path or the location in your file system where the CSV output file should be stored.",
55+
"multiple": false
56+
}
57+
},
58+
"args": {}
59+
}
60+
}
61+
}

package-lock.json

Lines changed: 25 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-regex-validate",
33
"description": "Validate Fields with Regex Property of Content Type and Global Field in a Stack",
4-
"version": "1.1.5",
4+
"version": "1.1.6",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli-cm-regex-validate/issues",
77
"devDependencies": {
@@ -61,8 +61,8 @@
6161
"version": "oclif-dev readme && git add README.md"
6262
},
6363
"dependencies": {
64-
"@contentstack/cli-command": "^1.2.7",
65-
"@contentstack/cli-utilities": "^1.4.3",
64+
"@contentstack/cli-command": "^1.2.9",
65+
"@contentstack/cli-utilities": "^1.4.5",
6666
"@contentstack/management": "^1.8.0",
6767
"cli-table3": "^0.6.0",
6868
"cli-ux": "^6.0.9",

src/utils/generate-output.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as jsonexport from 'jsonexport'
22
import * as Table from 'cli-table3'
33
import * as path from 'path'
44
import * as fs from 'fs'
5+
import { cliux } from '@contentstack/cli-utilities'
56
const regexMessages = require('../../messages/index.json').validateRegex
67

78
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
2829
tableData.forEach((row: any) => {
2930
table.push(row)
3031
})
31-
console.log(table.toString())
32-
console.log(regexMessages.output.csvOutput, storagePath)
33-
console.log(regexMessages.output.docsLink)
32+
let messageAndPath = `${regexMessages.output.csvOutput} ${storagePath}`
33+
cliux.print(table.toString())
34+
cliux.print(messageAndPath)
35+
cliux.print(regexMessages.output.docsLink)
3436
} else {
35-
console.log(regexMessages.output.noInvalidRegex)
37+
cliux.print(regexMessages.output.noInvalidRegex)
3638
}
3739
}

0 commit comments

Comments
 (0)