Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostmanCli #33

Merged
merged 8 commits into from
Jan 15, 2024
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
6 changes: 6 additions & 0 deletions .cspell/softwares.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,9 @@ TRIVY
KICS
TRUFFLEHOG
GRYPE
octocat
prerequest
slurpfile
EJSON
ejson
clairefro
5 changes: 4 additions & 1 deletion .github/workflows/docsify-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ permissions:
contents: read
pages: write
id-token: write
# actions: read needed by actions/deploy-pages
actions: read

# Allow one concurrent deployment
concurrency:
Expand Down Expand Up @@ -50,9 +52,10 @@ jobs:
uses: actions/configure-pages@v2

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: 'pages'
if-no-files-found: error

# Deployment job
deploy:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- name: Set up Python
if: matrix.runPrecommitTests
# kics-scan ignore-line
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand Down Expand Up @@ -149,7 +149,6 @@ jobs:
USER_ID=1000 \
GROUP_ID=1000 \
vendor/bash-tools-framework/bin/test \
-vvv \
--vendor "${{matrix.vendor}}" \
--bash-version "${{matrix.bashTarVersion}}" \
--bash-base-image "${{matrix.bashImage}}" \
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/precommit-autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ permissions: read-all
jobs:
auto-update:
runs-on: ubuntu-22.04
permissions:
pull-requests: write
contents: write
steps:
# kics-scan ignore-line
- uses: actions/checkout@v4

- name: Set up Python
# kics-scan ignore-line
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand Down
5 changes: 4 additions & 1 deletion .jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"**/.idea/**",
"**/report/**",
"**/*.svg",
"**/testsData/**"
"**/testsData/**",
"conf/postmanCli/MongoDbData/MongoDBDataAPI.postman_collection.json",
"conf/postmanCli/GithubAPI/GitHubAPI-01-Basic_no_auth_postman_collection.json",
"conf/postmanCli/GithubAPI/GitHubAPI-02-Advanced_with_auth_postman_collection.json"
]
}
12 changes: 12 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ SPELL_LYCHEE_FILTER_REGEX_EXCLUDE: |
)

JSON_ESLINT_PLUGIN_JSONC_FILE_NAME: .eslintrc.js
JSON_PRETTIER_FILTER_REGEX_EXCLUDE: |
(?x)(
^src/Postman/Model/testsData/pushMode/GithubAPI/notValidJsonFile.json$|
^src/Postman/Collection/testsData/postmanCollections_invalidJsonFile.json$|
^src/Postman/Model/testsData/getCollectionInvalid.json$
)
JSON_ESLINT_PLUGIN_JSONC_FILTER_REGEX_EXCLUDE: |
(?x)(
^src/Postman/Model/testsData/pushMode/GithubAPI/notValidJsonFile.json$|
^src/Postman/Collection/testsData/postmanCollections_invalidJsonFile.json$|
^src/Postman/Model/testsData/getCollectionInvalid.json$
)
21 changes: 15 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
default_install_hook_types: [pre-commit, pre-push]
default_stages: [pre-commit, manual]
minimum_pre_commit_version: 3.5.0
repos:
- repo: local
hooks:
Expand All @@ -18,7 +20,8 @@ repos:
- id: end-of-file-fixer
exclude: |
(?x)(
.svg$
.svg$|
^src\/Postman\/Model\/testsData\/pullMode\/GithubAPI\/notWritableFile.json$
)
- id: trailing-whitespace
- id: check-executables-have-shebangs
Expand All @@ -34,13 +37,23 @@ repos:
(?x)^(
conf\/.vscode\/settings.json|
.vscode\/settings.json|
.vscode\/launch.json
.vscode\/launch.json|
src\/Postman\/Collection\/testsData\/postmanCollections_invalidJsonFile.json|
src\/Postman\/Model\/testsData\/pushMode\/GithubAPI\/notValidJsonFile.json|
src\/Postman\/Model\/testsData\/getCollectionInvalid.json|
src\/Postman\/Model\/testsData\/pullMode\/GithubAPI\/notWritableFile.json
)$

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
exclude: |
(?x)^(
src\/Postman\/Collection\/testsData\/postmanCollections_invalidJsonFile.json|
src\/Postman\/Model\/testsData\/getCollectionInvalid.json|
src\/Postman\/Model\/testsData\/pushMode\/GithubAPI\/notValidJsonFile.json
)$

- repo: https://github.com/fchastanet/jumanjihouse-pre-commit-hooks
rev: 3.0.2
Expand Down Expand Up @@ -97,10 +110,6 @@ repos:
- id: plantuml
- id: buildShFiles
- id: buildShFilesGithubAction
- id: runUnitTests
args: [-r, src, -j, '1']
# not manual as github will run UT with several versions of bash and arch
stages: [pre-commit]
- id: megalinterCheckVersion
- id: megalinterGithubAction

Expand Down
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"name": "Bash-Debug (mysql2puml)",
"program": "bin/mysql2puml",
"args": ["src/_binaries/DbImport/testsData/dump.sql"]
},
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (postmanCli)",
"program": "bin/postmanCli",
"args": ["export", "--help"]
}
]
}
10 changes: 10 additions & 0 deletions Commands.tmpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- [4.1.3. Example 2: connect to mysql container with root user](#413-example-2-connect-to-mysql-container-with-root-user)
- [4.1.4. Example 3: connect to mysql server in order to execute a query](#414-example-3-connect-to-mysql-server-in-order-to-execute-a-query)
- [4.1.5. Example 4: pipe sql command to mysql container](#415-example-4-pipe-sql-command-to-mysql-container)
- [4.2. bin/postmanCli](#42-binpostmancli)
- [4.2.1. Help](#421-help)
- [5. Database tools](#5-database-tools)
- [5.1. bin/dbQueryAllDatabases](#51-bindbqueryalldatabases)
- [5.1.1. Help](#511-help)
Expand Down Expand Up @@ -194,6 +196,14 @@ project-mysql //bin/bash -c 'mysql -h127.0.0.1 -uroot -proot -P3306'
notice that as input is given to the command, tty option is not provided to
docker exec

### 4.2. bin/postmanCli

#### 4.2.1. Help

```text
@@@postmanCli_help@@@
```

## 5. Database tools

### 5.1. bin/dbQueryAllDatabases
Expand Down
92 changes: 92 additions & 0 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,96 @@ UI::theme() {
fi
}

bashToolsDefaultConfigTemplate="${bashToolsDefaultConfigTemplate:-$(
cat <<'EOF'
# shellcheck disable=SC2034

# Default settings
# you can override these settings by creating ${HOME}/.bash-tools/.env file
###
### LOG Level
### minimum level of the messages that will be logged into LOG_FILE
###
### 0: NO LOG
### 1: ERROR
### 2: WARNING
### 3: INFO
### 4: DEBUG
###
BASH_FRAMEWORK_LOG_LEVEL=${BASH_FRAMEWORK_LOG_LEVEL:-0}

###
### DISPLAY Level
### minimum level of the messages that will be displayed on screen
###
### 0: NO LOG
### 1: ERROR
### 2: WARNING
### 3: INFO
### 4: DEBUG
###
BASH_FRAMEWORK_DISPLAY_LEVEL=${BASH_FRAMEWORK_DISPLAY_LEVEL:-3}

###
### Log to file
###
### all log messages will be redirected to log file specified
### this same path will be used inside and outside of the container
###
BASH_FRAMEWORK_LOG_FILE=${BASH_FRAMEWORK_LOG_FILE:-${FRAMEWORK_ROOT_DIR}/logs/bash.log}

# absolute directory containing db import sql dumps
DB_IMPORT_DUMP_DIR=${DB_IMPORT_DUMP_DIR:-${HOME}/.bash-tools/dbImportDumps}

# garbage collect all files for which modification is greater than eg: 30 days (+30)
# each time an existing file is used by dbImport/dbImportTable
# the file modification time is set to now
DB_IMPORT_GARBAGE_COLLECT_DAYS=${DB_IMPORT_GARBAGE_COLLECT_DAYS:-+30}

# absolute directory containing dbScripts used by dbScriptAllDatabases
SCRIPTS_FOLDER=${SCRIPTS_FOLDER:-${HOME}/.bash-tools/conf/dbScripts}

# -----------------------------------------------------
# AWS Parameters
# -----------------------------------------------------
S3_BASE_URL=${S3_BASE_URL:-}

# -----------------------------------------------------
# Postman Parameters
# -----------------------------------------------------
POSTMAN_API_KEY=
EOF
)}"

# @description loads ~/.bash-tools/.env if available
# if not creates it from a default template
# else check if new options need to be added
BashTools::Conf::requireLoad() {
local envFile="${HOME}/.bash-tools/.env"
if [[ ! -f "${envFile}" ]]; then
mkdir -p "${HOME}/.bash-tools"
(
echo "#!/usr/bin/env bash"
echo "${bashToolsDefaultConfigTemplate}"
) >"${envFile}"
Log::displayInfo "Configuration file '${envFile}' created"
else
if ! grep -q '^POSTMAN_API_KEY=' "${envFile}"; then
(
echo '# -----------------------------------------------------'
echo '# Postman Parameters'
echo '# -----------------------------------------------------'
echo 'POSTMAN_API_KEY='
) >>"${envFile}"
fi
fi
# shellcheck source=/conf/.env
source "${envFile}" || {
Log::displayError "impossible to load '${envFile}'"
exit 1
}
}

# @description ensure COMMAND_BIN_DIR env var is set
# and PATH correctly prepared
# @noargs
Expand Down Expand Up @@ -904,6 +994,7 @@ FRAMEWORK_BIN_DIR="${FRAMEWORK_ROOT_DIR}/bin"
FRAMEWORK_VENDOR_DIR="${FRAMEWORK_ROOT_DIR}/vendor"
FRAMEWORK_VENDOR_BIN_DIR="${FRAMEWORK_ROOT_DIR}/vendor/bin"

# @require BashTools::Conf::requireLoad
if [[ -f "${HOME}/.bash-tools/.env" ]]; then
export BASH_FRAMEWORK_ENV_FILES=("${HOME}/.bash-tools/.env")
fi
Expand All @@ -912,6 +1003,7 @@ Env::requireLoad
UI::requireTheme
Linux::requireRealpathCommand
Log::requireLoad
BashTools::Conf::requireLoad
Compiler::Facade::requireCommandBinDir

# @require Compiler::Facade::requireCommandBinDir
Expand Down
Loading