Skip to content

Commit 8ed3adf

Browse files
committed
fix(config): replace POSIX shell commands with cross-platform python scripts in tasks
1 parent ab53901 commit 8ed3adf

1 file changed

Lines changed: 41 additions & 35 deletions

File tree

.unirtm.toml

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ run = 'unirtm exec -- gitleaks detect --source . --no-banner'
5050
[tasks."audit:zizmor"]
5151
description = 'Audit GitHub Actions workflows for security flaws'
5252
run = '''
53-
if [ "$UNIRTM_FIX" = "1" ]; then
54-
unirtm exec -- zizmor . --format plain --config .zizmor.yml --fix=all
55-
else
56-
unirtm exec -- zizmor . --format plain --config .zizmor.yml
57-
fi
53+
python -c "
54+
import os, sys
55+
cmd = 'unirtm exec -- zizmor . --format plain --config .zizmor.yml --fix=all' if os.environ.get('UNIRTM_FIX') == '1' else 'unirtm exec -- zizmor . --format plain --config .zizmor.yml'
56+
sys.exit(os.system(cmd))
57+
"
5858
'''
5959

6060
[tasks."audit:osv"]
@@ -64,39 +64,39 @@ run = 'unirtm exec -- osv-scanner scan . --config .osv-scanner.toml'
6464
[tasks."audit:npm"]
6565
description = 'Node.js dependency audit'
6666
run = '''
67-
if [ -f "package.json" ]; then
68-
if [ "$UNIRTM_FIX" = "1" ]; then
69-
unirtm exec -- npm audit fix --registry="https://registry.npmjs.org"
70-
else
71-
unirtm exec -- npm audit --registry="https://registry.npmjs.org"
72-
fi
73-
else
74-
echo "⏭️ Skipped (no package.json)"
75-
fi
67+
python -c "
68+
import os, sys
69+
if os.path.exists('package.json'):
70+
cmd = 'unirtm exec -- npm audit fix' if os.environ.get('UNIRTM_FIX') == '1' else 'unirtm exec -- npm audit'
71+
sys.exit(os.system(cmd + ' --registry=https://registry.npmjs.org'))
72+
else:
73+
print('⏭️ Skipped (no package.json)')
74+
"
7675
'''
7776

7877
[tasks."audit:pip"]
7978
description = 'Python dependency audit'
8079
run = '''
81-
if [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
82-
if [ "$UNIRTM_FIX" = "1" ]; then
83-
unirtm exec -- pip-audit --fix
84-
else
85-
unirtm exec -- pip-audit
86-
fi
87-
else
88-
echo "⏭️ Skipped (no python requirements)"
89-
fi
80+
python -c "
81+
import os, sys
82+
if os.path.exists('requirements.txt') or os.path.exists('pyproject.toml'):
83+
cmd = 'unirtm exec -- pip-audit --fix' if os.environ.get('UNIRTM_FIX') == '1' else 'unirtm exec -- pip-audit'
84+
sys.exit(os.system(cmd))
85+
else:
86+
print('⏭️ Skipped (no python requirements)')
87+
"
9088
'''
9189

9290
[tasks."audit:govulncheck"]
9391
description = 'Go dependency audit'
9492
run = '''
95-
if [ -f "go.mod" ]; then
96-
unirtm exec -- govulncheck ./...
97-
else
98-
echo "⏭️ Skipped (no go.mod)"
99-
fi
93+
python -c "
94+
import os, sys
95+
if os.path.exists('go.mod'):
96+
sys.exit(os.system('unirtm exec -- govulncheck ./...'))
97+
else:
98+
print('⏭️ Skipped (no go.mod)')
99+
"
100100
'''
101101

102102
[tasks."audit:trivy"]
@@ -109,17 +109,23 @@ unirtm exec -- trivy sbom sbom.json
109109
[tasks.lint]
110110
description = 'Fast lint: Check only modified files (staged & unstaged)'
111111
run = '''
112-
FILES=$(git ls-files -m -o --exclude-standard)
113-
if [ -z "$FILES" ]; then
114-
echo "✨ No changed files to lint."
115-
else
116-
unirtm exec -- pre-commit run --files $FILES || (echo "⚠️ First pass failed. Running second check..." && unirtm exec -- pre-commit run --files $FILES)
117-
fi
112+
python -c "
113+
import os, sys, subprocess
114+
files = subprocess.check_output(['git', 'ls-files', '-m', '-o', '--exclude-standard']).decode('utf-8').split()
115+
if not files:
116+
print('✨ No changed files to lint.')
117+
else:
118+
cmd = ['unirtm', 'exec', '--', 'pre-commit', 'run', '--files'] + files
119+
res = subprocess.run(cmd)
120+
if res.returncode != 0:
121+
print('⚠️ First pass failed. Running second check...')
122+
sys.exit(subprocess.run(cmd).returncode)
123+
"
118124
'''
119125

120126
[tasks.lint-all]
121127
description = 'Full lint: Check all project files (used in CI or verify)'
122-
run = 'unirtm exec -- pre-commit run --all-files > p1.log 2>&1 || (cat p1.log; echo "⚠️ First pass failed. Running second check..."; unirtm exec -- pre-commit run --all-files > p2.log 2>&1 || (cat p2.log; exit 1))'
128+
run = 'unirtm exec -- pre-commit run --all-files'
123129

124130
[tasks.test]
125131
description = 'Run Go unit tests for all packages recursively'

0 commit comments

Comments
 (0)