An open API service indexing awesome lists of open source software.

https://github.com/megamanics/replacor

Search & Replace CLI for Confluence Pages
https://github.com/megamanics/replacor

atlassian-confluence cli confluence nodejs rest-api

Last synced: 14 days ago
JSON representation

Search & Replace CLI for Confluence Pages

Awesome Lists containing this project

README

          

[![CodeQL](https://github.com/megamanics/replacor/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/megamanics/replacor/actions/workflows/codeql-analysis.yml)
[![ESLint analysis](https://github.com/megamanics/replacor/actions/workflows/eslint.yml/badge.svg)](https://github.com/megamanics/replacor/actions/workflows/eslint.yml)

[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/megamanics/replacor/badge)](https://api.securityscorecards.dev/projects/github.com/megamanics/replacor)

# Pre-Reqs for this

* [Install node.js](https://nodejs.org/en/)
* [API Token with scope read:content-details:confluence,write:content:confluence](https://id.atlassian.com/manage/api-tokens)

# Setup
```
gh repo clone megamanics/replacor
cd replacor
npm install
```

# Search CLI
```
./search.js -h
Usage: search.js [options]

CLI to search Confluence Pages

Options:
-V, --version output the version number
-q, --query CQL query to search for, eg: text~gitlab
-u, --user user eg: your_email@domain.com
-t, --token your_user_api_token with scope read:content-details:confluence,write:content:confluence
-d, --domain eg: https://.atlassian.net
-h, --help display help for command
```

example of an execution
```
./search.js -u $CONFLUENCE_USER -t $CONFLUENCE_TOKEN -d $CONFLUENCE_DOMAIN -q text~bitbucket.com
```

# Search & Replace CLI
```
./replace.js -h
Usage: replace.js [options]

CLI to replace strings in Confluence Pages

Options:
-V, --version output the version number
-q, --query CQL query used to search pages, eg: text~gitlab
-s, --search string to replace eg: gitlab
-r, --replace replacement string eg: gitlab -> github
-u, --user user eg: your_email@domain.com
-t, --token your_user_api_token with scope read:content-details:confluence,write:content:confluence
-d, --domain eg: https://.atlassian.net
-l, --loglevel loglevel, eg: debug, info, warn, error, fatal
-c, --convertbburl convert bitbucket url format to github url format
--dryrun dry run only
-h, --help display help for command
```

example of an execution
```
./replace.js -u $CONFLUENCE_USER -t $CONFLUENCE_TOKEN -d $CONFLUENCE_DOMAIN -q text~searchexpression -s -r --convertbburl --dryrun
```

### Advanced Search Strings

### To restrict search within a space
```
space = DEV and text~gitlab
```

# Reference
https://developer.atlassian.com/server/confluence/advanced-searching-using-cql
https://developer.atlassian.com/server/confluence/performing-text-searches-using-cql