Compare commits

..

13 Commits

Author SHA1 Message Date
1d3eb77235 v4.0.12
=====================================================================

--- Bug Fixes ----------------------------

- ensure proper return status from zsh/lib/utils/io print functions

- ensure user prompt is displayed when required if log-level is 0
2024-02-21 09:28:34 -07:00
406ee85d46 v4.0.11
=====================================================================

- ghaction fixed; quiet up the default logs again
2024-02-21 09:13:39 -07:00
7709c7e3db v4.0.10
=====================================================================

- actually let's just fetch tags in gh actions
2024-02-21 09:10:13 -07:00
8d3e6ae46f v4.0.9
=====================================================================

- include default-tag so scwrypts doesn't break in ghactions
2024-02-21 09:00:07 -07:00
fec8a7ec94 v4.0.8
=====================================================================

- more logs in virtual dependency update ghaction
2024-02-21 08:52:41 -07:00
534a2011a1 v4.0.7
=====================================================================

- unlock logs in virtual dependency update
2024-02-21 08:46:41 -07:00
e1b6c3e4f0 v4.0.6
=====================================================================

- bugfix in python scwrypts.scwrypts
2024-02-21 00:37:44 -07:00
1adb45d75e v4.0.5
=====================================================================

- one last python semver fix and then BOOM
2024-02-21 00:29:33 -07:00
62ab5404cf v4.0.4
=====================================================================

- ensure that full python semver is published to pypi
2024-02-21 00:22:49 -07:00
e43c07f75a v4.0.3
=====================================================================

- circleci: additional branch/tag trigger tweaks
2024-02-21 00:13:21 -07:00
fc5f80232e v4.0.2
=====================================================================

- circleci: more trigger fixes; add python build to python test
2024-02-21 00:05:40 -07:00
695eea2985 v4.0.1
=====================================================================

- circleci: trigger test workflows on tags too
2024-02-20 23:57:43 -07:00
a739d3b5a2 v4.0.0
=====================================================================

Big day! V4 is finally live. This INCLUDES some BREAKING CHANGES to ZSH
TYPE scwrypts! Please refer to the readme for upgrade details
                     (more specifically docs/upgrade/v3-to-v4.md)

Upgrade is SUPER EASY, so please take the time to do so.

--- New Features ----------------------------------------------------

- zsh type scwrypts have an upgraded runstring to improve context setup
  and simplicity to the scwrypt-writer

- scwrypts now publishes the package (scwrypts) to PyPi; this provides a
  simple way to invoke scwrypts from python-based environments as well
  as the entire scwrypts python library suite

  pip install scwrypts

- scwrypts now publishes the package (scwrypts) to npm; this provides a
  simple way to invoke scwrypts from nodesjs environments

  npm install scwrypts

--- Bug Fixes -------------------------------------------------------

- scwrypts runner prompts which use the zshbuiltin "read" now
  appropriately read input from tty, pipe, files, and user input

- virtualenv refresh now loads and prepares the scwrypts virtual
  environments correctly

--- Changes ---------------------------------------------------------

- created the (-v, --log-level) scwrypts arguments as improvements of
  and replacements to the --verbose and --no-log flags
     - (-n) is now an alias for (--log-level 0)
     - (--no-log) is the same as (-n) for compatibility, but will be removed in 4.2

- zsh/lib/utils/io print functions now *interact with log-level* various
  log levels will now only display the appropriate console prints for
  the specified log level

- zsh/lib/utils/io:INFO has been renamed to DEBUG to align with
  log-level output; please use DEBUG for debug messages and REMINDER for
  important user messages

- created zsh/lib/utils/io:FZF_USER_INPUT as a *drop-in replacement* for
  the confusing FZF_HEAD and FZF_TAIL commands. Update by literally
  changing any instances of FZF_HEAD or FZF_TAIL with FZF_USER_INPUT
     - FZF_HEAD and FZF_TAIL will be removed in 4.2

- zsh/lib/utils/io:READ (and other zshbuiltin/read-based prompts) now
  accept a --force-user-input flag in case important checks should
  require an admin's approval. This flag will ensure that piped input
  and the `scwrypts -y` flag are ignored for the single prompt.

- zsh/lib/utils/color has been updated to use color names which match
  the ANSI color names

- zsh/hello-world has been reduced to a minimal example; this is to
  emphasize ease-of-use with v4

- zsh/sanity-check is a scwrypts/run testing helper and detailed
  starting reference (helpful since hello-world is now minimal)

- various refactor, updates, and improvements to the scwrypts runner

- migrated all zsh scwrypts and plugins to use v4 runner syntax
     - zsh
     - plugins/kubectl
     - plugins/ci

- refactored py/lib into py/lib/scwrypts (PyPi)
2024-02-20 23:51:32 -07:00
10 changed files with 102 additions and 37 deletions

View File

@ -13,32 +13,40 @@ executors:
nodejs: nodejs:
docker: docker:
- image: node:18 - image: node:18
resource_class: small resource_class: medium
jobs: jobs:
python-test: python-test:
executor: python executor: python
working_directory: ./py/lib working_directory: ~/scwrypts/py/lib
steps: steps:
- run: | - checkout:
path: ~/scwrypts
- run:
name: pytest
command: |
: \ : \
&& pip install -e . \ && pip install . .[test] \
&& pytest \ && pytest \
; ;
- run: pip install build && python -m build
python-publish: python-publish:
executor: python executor: python
working_directory: ~/scwrypts/py/lib
steps: steps:
- checkout - checkout:
- python/dist path: ~/scwrypts
- run: pip install build && python -m build
- run: pip install twine && twine upload dist/* - run: pip install twine && twine upload dist/*
nodesjs-test: nodejs-test:
executor: nodejs executor: nodejs
working_directory: ./zx/lib working_directory: ~/scwrypts/zx/lib
steps: steps:
- checkout - checkout:
path: ~/scwrypts
- restore_cache: - restore_cache:
name: restore pnpm cache name: restore pnpm cache
@ -61,12 +69,14 @@ jobs:
- run: pnpm test - run: pnpm test
- run: pnpm lint - run: pnpm lint
- run: pnpm build
nodesjs-publish: nodejs-publish:
executor: nodejs executor: nodejs
working_directory: ./zx/lib working_directory: ~/scwrypts/zx/lib
steps: steps:
- checkout - checkout:
path: ~/scwrypts
- restore_cache: - restore_cache:
name: restore pnpm cache name: restore pnpm cache
@ -87,23 +97,62 @@ jobs:
paths: paths:
- .pnpm-store - .pnpm-store
- run: pnpm build - run:
- run: pnpm version $(git describe --tags) name: publish
command: |
: \
&& [ $CIRCLE_TAG ] \
&& pnpm build \
&& pnpm version $CIRCLE_TAG \
&& pnpm set //registry.npmjs.org/:_authToken=$NPM_TOKEN \
&& pnpm publish --no-git-checks \
;
workflows: workflows:
build: python-dev:
jobs: jobs:
- python-test - python-test:
filters:
branches:
ignore: /^main$/
python:
jobs:
- python-test:
filters:
tags:
only: /^v\d+\.\d+\.\d+.*$/
branches:
ignore: /^.*$/
- python-publish: - python-publish:
requires: [python-test] requires: [python-test]
context: [pypi-yage]
filters:
tags:
only: /^v\d+\.\d+\.\d+.*$/
branches:
ignore: /^.*$/
nodejs-dev:
jobs:
- nodejs-test:
filters: filters:
branches: branches:
only: main ignore: /^main$/
- nodejs-test nodejs:
jobs:
- nodejs-test:
filters:
tags:
only: /^v\d+\.\d+\.\d+.*$/
branches:
ignore: /^.*$/
- nodejs-publish: - nodejs-publish:
requires: [nodejs-test] requires: [nodejs-test]
context: [npm-wrynegade]
filters: filters:
tags:
only: /^v\d+\.\d+\.\d+.*$/
branches: branches:
only: main ignore: /^.*$/

View File

@ -29,6 +29,7 @@ runs:
repository: wrynegade/scwrypts repository: wrynegade/scwrypts
path: ./wrynegade/scwrypts path: ./wrynegade/scwrypts
ref: ${{ inputs.version }} ref: ${{ inputs.version }}
fetch-tags: true
- name: check dependencies - name: check dependencies
shell: bash shell: bash
@ -51,7 +52,7 @@ runs:
} > $HOME/.scwrypts.apt-get.log 2>&1 } > $HOME/.scwrypts.apt-get.log 2>&1
echo "updating virtual dependencies" echo "updating virtual dependencies"
$GITHUB_WORKSPACE/wrynegade/scwrypts/scwrypts -n \ $GITHUB_WORKSPACE/wrynegade/scwrypts/scwrypts \
--name scwrypts/virtualenv/update-all \ --name scwrypts/virtualenv/update-all \
--group scwrypts \ --group scwrypts \
--type zsh \ --type zsh \

3
py/lib/.gitignore vendored
View File

@ -1 +1,4 @@
dist/ dist/
__pycache__/
*.py[cod]
*.so

View File

@ -55,6 +55,5 @@ source = 'versioningit'
[tool.hatch.build.targets.wheel] [tool.hatch.build.targets.wheel]
packages = ['./'] packages = ['./']
[tool.versioningit] [tool.versioningit.vcs]
match = ['v*'] match = ['v[0-9]*.[0-9]*.[0-9]*']

View File

@ -41,7 +41,7 @@ def scwrypts(*args, patterns=None, name=None, group=None, _type=None, log_level=
depth = int(depth) + 1 depth = int(depth) + 1
return run( return run(
f'SUBSCWRYPT={depth} {executable} {pre_args} -- {" ".join(args)}', f'SUBSCWRYPT={depth} {executable} {" ".join(pre_args)} -- {" ".join(args)}',
shell=True, shell=True,
executable='/bin/zsh', executable='/bin/zsh',
check=False, check=False,

View File

@ -15,26 +15,31 @@ ERROR() { # command encountered an error
SUCCESS() { # command completed successfully SUCCESS() { # command completed successfully
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \ [[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \
&& PREFIX="SUCCESS ✔" COLOR=$__GREEN PRINT "$@" && PREFIX="SUCCESS ✔" COLOR=$__GREEN PRINT "$@"
return 0
} }
REMINDER() { # include sysadmin reminder or other important notice to users REMINDER() { # include sysadmin reminder or other important notice to users
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \ [[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \
&& PREFIX="REMINDER " COLOR=$__BRIGHT_MAGENTA PRINT "$@" && PREFIX="REMINDER " COLOR=$__BRIGHT_MAGENTA PRINT "$@"
return 0
} }
STATUS() { # general status updates (prefer this to generic 'echo') STATUS() { # general status updates (prefer this to generic 'echo')
[[ $SCWRYPTS_LOG_LEVEL -ge 2 ]] \ [[ $SCWRYPTS_LOG_LEVEL -ge 2 ]] \
&& PREFIX="STATUS " COLOR=$__BLUE PRINT "$@" && PREFIX="STATUS " COLOR=$__BLUE PRINT "$@"
return 0
} }
WARNING() { # warning-level messages; not errors WARNING() { # warning-level messages; not errors
[[ $SCWRYPTS_LOG_LEVEL -ge 3 ]] \ [[ $SCWRYPTS_LOG_LEVEL -ge 3 ]] \
&& PREFIX="WARNING " COLOR=$__YELLOW PRINT "$@" && PREFIX="WARNING " COLOR=$__YELLOW PRINT "$@"
return 0
} }
DEBUG() { # helpful during development or (sparingly) to help others' development DEBUG() { # helpful during development or (sparingly) to help others' development
[[ $SCWRYPTS_LOG_LEVEL -ge 4 ]] \ [[ $SCWRYPTS_LOG_LEVEL -ge 4 ]] \
&& PREFIX="DEBUG " COLOR=$__WHITE PRINT "$@" && PREFIX="DEBUG " COLOR=$__WHITE PRINT "$@"
return 0
} }
PROMPT() { # you probably want to use yN or INPUT from below PROMPT() { # you probably want to use yN or INPUT from below
@ -42,6 +47,7 @@ PROMPT() { # you probably want to use yN or INPUT from below
&& PREFIX="PROMPT " COLOR=$__CYAN PRINT "$@" \ && PREFIX="PROMPT " COLOR=$__CYAN PRINT "$@" \
&& PREFIX="USER ⌨" COLOR=$__BRIGHT_CYAN PRINT '' --no-line-end \ && PREFIX="USER ⌨" COLOR=$__BRIGHT_CYAN PRINT '' --no-line-end \
; ;
return 0
} }
FAIL() { SCWRYPTS_LOG_LEVEL=1 ERROR "${@:2}"; exit $1; } FAIL() { SCWRYPTS_LOG_LEVEL=1 ERROR "${@:2}"; exit $1; }
@ -211,15 +217,21 @@ READ_YN() { # yes/no read is suprisingly tricky
local yn local yn
PROMPT "${USERPROMPT[@]}" PROMPT "${USERPROMPT[@]}"
local PERFORM_FAKE_PROMPT=false
case $SKIP_USER_INPUT in case $SKIP_USER_INPUT in
true ) yn=y ;; true ) yn=y ;;
false ) false )
[[ $FORCE_USER_INPUT =~ true ]] && [[ $SCWRYPTS_LOG_LEVEL -lt 1 ]] \ [[ $SCWRYPTS_LOG_LEVEL -lt 1 ]] && {
[[ $FORCE_USER_INPUT =~ false ]] && [ ! -t 0 ] \
|| PERFORM_FAKE_PROMPT=true
}
[[ $PERFORM_FAKE_PROMPT =~ true ]] \
&& echo -n "${USERPROMPT[@]} : " >&2 && echo -n "${USERPROMPT[@]} : " >&2
READ ${READ_ARGS[@]} -s -k yn READ ${READ_ARGS[@]} -s -k yn
[[ $FORCE_USER_INPUT =~ true ]] && [[ $SCWRYPTS_LOG_LEVEL -lt 1 ]] \ [[ $PERFORM_FAKE_PROMPT =~ true ]] \
&& echo $yn >&2 && echo $yn >&2
;; ;;
esac esac

View File

@ -26,6 +26,7 @@
"prettier": "^3.2.5", "prettier": "^3.2.5",
"ts-jest": "^29.1.2", "ts-jest": "^29.1.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3",
"uuid": "^9.0.1" "uuid": "^9.0.1"
}, },
"eslintConfig": { "eslintConfig": {

3
zx/lib/pnpm-lock.yaml generated
View File

@ -43,6 +43,9 @@ devDependencies:
ts-node: ts-node:
specifier: ^10.9.2 specifier: ^10.9.2
version: 10.9.2(@types/node@20.11.19)(typescript@5.3.3) version: 10.9.2(@types/node@20.11.19)(typescript@5.3.3)
typescript:
specifier: ^5.3.3
version: 5.3.3
uuid: uuid:
specifier: ^9.0.1 specifier: ^9.0.1
version: 9.0.1 version: 9.0.1

View File

@ -64,11 +64,9 @@ afterEach(() => {
}); });
describe('exact lookup', () => { describe('exact lookup', () => {
let output;
beforeEach(async () => { beforeEach(async () => {
sample.spy.getScwryptsLookup.mockReturnValue(sample.lookup.exact); sample.spy.getScwryptsLookup.mockReturnValue(sample.lookup.exact);
await scwrypts(sample.options);
output = await scwrypts(sample.options);
}); });
test('gets the correct lookup', () => { test('gets the correct lookup', () => {
@ -98,7 +96,6 @@ describe('exact lookup', () => {
describe('patterns lookup', () => { describe('patterns lookup', () => {
beforeEach(async () => { beforeEach(async () => {
sample.spy.getScwryptsLookup.mockReturnValue(sample.lookup.patterns); sample.spy.getScwryptsLookup.mockReturnValue(sample.lookup.patterns);
await scwrypts(sample.options); await scwrypts(sample.options);
}); });

6
zx/package-lock.json generated
View File

@ -31,6 +31,7 @@
"prettier": "^3.2.5", "prettier": "^3.2.5",
"ts-jest": "^29.1.2", "ts-jest": "^29.1.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3",
"uuid": "^9.0.1" "uuid": "^9.0.1"
} }
}, },
@ -4997,7 +4998,6 @@
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true, "dev": true,
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@ -8596,6 +8596,7 @@
"prettier": "^3.2.5", "prettier": "^3.2.5",
"ts-jest": "^29.1.2", "ts-jest": "^29.1.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3",
"uuid": "^9.0.1" "uuid": "^9.0.1"
} }
}, },
@ -8884,8 +8885,7 @@
"version": "5.3.3", "version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true, "dev": true
"peer": true
}, },
"undici-types": { "undici-types": {
"version": "5.26.5", "version": "5.26.5",