Skip to content

Commit

Permalink
branch plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Shafeeq PP authored and Shafeeq PP committed Apr 4, 2023
1 parent 8234621 commit 61ed745
Show file tree
Hide file tree
Showing 30 changed files with 713 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/contentstack-branch/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Build files
/lib
/test
/types
55 changes: 55 additions & 0 deletions packages/contentstack-branch/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"env": {
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"extends": [
// "oclif",
"oclif-typescript",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "none"
}
],
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": [
"error",
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"semi": "off",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/no-redeclare": "off",
"eqeqeq": [
"error",
"smart"
],
"id-match": "error",
"no-eval": "error",
"no-var": "error",
"quotes": "off",
"indent": "off",
"camelcase": "off",
"comma-dangle": "off",
"arrow-parens": "off",
"operator-linebreak": "off",
"object-curly-spacing": "off",
"node/no-missing-import": "off",
"padding-line-between-statements": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"unicorn/no-abusive-eslint-disable": "off",
"unicorn/consistent-function-scoping": "off",
"@typescript-eslint/no-use-before-define": "off"
}
}
12 changes: 12 additions & 0 deletions packages/contentstack-branch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*-debug.log
*-error.log
/.nyc_output
/dist
/lib
/tmp
/yarn.lock
node_modules
.DS_Store
coverage
.talismanrc
.vscode
12 changes: 12 additions & 0 deletions packages/contentstack-branch/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"require": [
"test/helpers/init.js",
"ts-node/register",
"source-map-support/register"
],
"watch-extensions": [
"ts"
],
"recursive": true,
"timeout": 5000
}
5 changes: 5 additions & 0 deletions packages/contentstack-branch/.nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"inlcude": [
"lib/**/*.js"
]
}
7 changes: 7 additions & 0 deletions packages/contentstack-branch/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2
}
21 changes: 21 additions & 0 deletions packages/contentstack-branch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
160 changes: 160 additions & 0 deletions packages/contentstack-branch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# @contentstack/cli-cm-export

It is Contentstack’s CLI plugin to export content from the stack. To learn how to export and import content in Contentstack, refer to the [Migration guide](https://www.contentstack.com/docs/developers/cli/migration/).

[![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)

<!-- toc -->
* [@contentstack/cli-cm-export](#contentstackcli-cm-export)
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->

For switching to EU region update the hosts at config/default.js

```js
{
host:'https://eu-api.contentstack.com/v3',
cdn: 'https://eu-cdn.contentstack.com/v3',
...
}
```

For switching to AZURE-NA region update the hosts at config/default.js

```js
{
host:'https://azure-na-api.contentstack.com/v3',
cdn: 'https://azure-na-cdn.contentstack.com/v3',
...
}
```

# Usage

<!-- usage -->
```sh-session
$ npm install -g @contentstack/cli-cm-branches
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-branches/1.0.0 darwin-arm64 node-v18.11.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
...
```
<!-- usagestop -->

# Commands

<!-- commands -->
* [`csdx cm:branches [--base-branch <value>] [--stack-api-key <value>]`](#csdx-cmbranches---base-branch-value---stack-api-key-value)
* [`csdx cm:branches:config [--base-branch <value>] [--stack-api-key <value>]`](#csdx-cmbranchesconfig---base-branch-value---stack-api-key-value)
* [`csdx cm:branches:create [--base-branch <value>] [--stack-api-key <value>]`](#csdx-cmbranchescreate---base-branch-value---stack-api-key-value)
* [`csdx cm:branches:delete [--base-branch <value>] [--stack-api-key <value>]`](#csdx-cmbranchesdelete---base-branch-value---stack-api-key-value)
* [`csdx cm:branches:diff [--base-branch <value>] [--stack-api-key <value>]`](#csdx-cmbranchesdiff---base-branch-value---stack-api-key-value)
* [`csdx cm:branches:merge [--base-branch <value>] [--stack-api-key <value>]`](#csdx-cmbranchesmerge---base-branch-value---stack-api-key-value)

## `csdx cm:branches [--base-branch <value>] [--stack-api-key <value>]`

List the branches to select

```
USAGE
$ csdx cm:branches [--base-branch <value>] [--stack-api-key <value>]
DESCRIPTION
List the branches to select
EXAMPLES
$ csdx cm:branches --base-branch main --stack-api-key bltxxxxxxxx
```

_See code: [src/commands/cm/branches/index.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/index.ts)_

## `csdx cm:branches:config [--base-branch <value>] [--stack-api-key <value>]`

Set the branch

```
USAGE
$ csdx cm:branches:config [--base-branch <value>] [--stack-api-key <value>]
DESCRIPTION
Set the branch
EXAMPLES
$ csdx cm:branches:config --base-branch main --stack-api-key bltxxxxxxxx
```

_See code: [src/commands/cm/branches/config.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/config.ts)_

## `csdx cm:branches:create [--base-branch <value>] [--stack-api-key <value>]`

Create a new branch

```
USAGE
$ csdx cm:branches:create [--base-branch <value>] [--stack-api-key <value>]
DESCRIPTION
Create a new branch
EXAMPLES
$ csdx cm:branches:create --base-branch main --stack-api-key bltxxxxxxxx
```

_See code: [src/commands/cm/branches/create.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/create.ts)_

## `csdx cm:branches:delete [--base-branch <value>] [--stack-api-key <value>]`

Delete a branch

```
USAGE
$ csdx cm:branches:delete [--base-branch <value>] [--stack-api-key <value>]
DESCRIPTION
Delete a branch
EXAMPLES
$ csdx cm:branches:delete --base-branch main --stack-api-key bltxxxxxxxx
```

_See code: [src/commands/cm/branches/delete.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/delete.ts)_

## `csdx cm:branches:diff [--base-branch <value>] [--stack-api-key <value>]`

Check the difference between the branches

```
USAGE
$ csdx cm:branches:diff [--base-branch <value>] [--stack-api-key <value>]
DESCRIPTION
Check the difference between the branches
EXAMPLES
$ csdx cm:branches:diff --base-branch main --stack-api-key bltxxxxxxxx
```

_See code: [src/commands/cm/branches/diff.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/diff.ts)_

## `csdx cm:branches:merge [--base-branch <value>] [--stack-api-key <value>]`

Merge a branch

```
USAGE
$ csdx cm:branches:merge [--base-branch <value>] [--stack-api-key <value>]
DESCRIPTION
Merge a branch
EXAMPLES
$ csdx cm:branches:merge --base-branch main --stack-api-key bltxxxxxxxx
```

_See code: [src/commands/cm/branches/merge.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/merge.ts)_
<!-- commandsstop -->
17 changes: 17 additions & 0 deletions packages/contentstack-branch/bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node

const oclif = require('@oclif/core');

const path = require('path');
const project = path.join(__dirname, '..', 'tsconfig.json');

// In dev mode -> use ts-node and dev plugins
process.env.NODE_ENV = 'development';

require('ts-node').register({ project });

// In dev mode, always show stack traces
oclif.settings.debug = true;

// Start the CLI
oclif.run().then(oclif.flush).catch(oclif.Errors.handle);
3 changes: 3 additions & 0 deletions packages/contentstack-branch/bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\dev" %*
5 changes: 5 additions & 0 deletions packages/contentstack-branch/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

const oclif = require('@oclif/core');

oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'));
3 changes: 3 additions & 0 deletions packages/contentstack-branch/bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
1 change: 1 addition & 0 deletions packages/contentstack-branch/messages/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit 61ed745

Please sign in to comment.