mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
feat: Config Persistence & API (#83)
* introduce a persistent config * add tests and refactor config creation * update config handling and add support for removing config * add support to skip suspicious pkgs marked as trusted * add support for config dir Env & unexport functions * small fixes * add assert for dir * fix tests * fix shell source line & trusted pkgs parsing * fix flag inconsistency * update config to read on each invocation and create if does not exist * fix flags value being overridden * remove redundant func call * modify trusted pkg check to be config bound * modify RemoveConfig to rm files & not dir. add tests for paths.go * add versions for package for e2e * modify tests to reset config * fix: Simplify config persistence * fix: Misc comments * fix: Misc fix * fix: Do not overwrite config file if exists * fix: Do not overwrite config file if exists * fix: Config cobra command should override and not replace * fix: Create dir before writing config template * fix: Create dir before writing config template * fix: Misc refactoring * test: Add test for is trusted package version * Update cmd/setup/setup.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com> * Update config/config.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com> * fix: Remove unused constant in config * fix: Resolve conflict with event logger * docs: Add doc for eventlogger.Logger interface * test: Add E2E for config file creation * fix: Code review fixes --------- Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com> Co-authored-by: Sahilb315 <bansalsahil315@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
Sahilb315
parent
698bd3dd13
commit
20c854e473
@@ -66,12 +66,23 @@ jobs:
|
||||
- name: Add pmg to PATH
|
||||
run: echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Setup PMG
|
||||
run: pmg setup install
|
||||
|
||||
- name: Test PMG - Config File is Created
|
||||
run: |
|
||||
test -f $HOME/.config/safedep/pmg/config.yml
|
||||
|
||||
- name: Test pmg.rc File is Created
|
||||
run: |
|
||||
test -f $HOME/.pmg.rc
|
||||
|
||||
- name: Test NPM - Single Package & Manifest
|
||||
run: |
|
||||
echo "Testing NPM single package installation..."
|
||||
mkdir npm-test && cd npm-test
|
||||
pmg npm init -y
|
||||
pmg npm install express
|
||||
pmg npm install express@5.2.1
|
||||
pmg npm install lodash@4.17.21
|
||||
|
||||
# Verification: npm added packages present and manifest updated
|
||||
@@ -95,7 +106,7 @@ jobs:
|
||||
echo "Testing PNPM single package installation..."
|
||||
mkdir pnpm-test && cd pnpm-test
|
||||
pmg pnpm init
|
||||
pmg pnpm add express
|
||||
pmg pnpm add express@5.2.1
|
||||
pmg pnpm add lodash@4.17.21
|
||||
|
||||
# Verification: pnpm packages installed and lockfile created
|
||||
@@ -118,7 +129,7 @@ jobs:
|
||||
echo "Testing Bun single package installation..."
|
||||
mkdir bun-test && cd bun-test
|
||||
pmg bun init -y
|
||||
pmg bun add express
|
||||
pmg bun add express@5.2.1
|
||||
pmg bun add lodash@4.17.21
|
||||
|
||||
# Verification: bun packages installed and lockfile created
|
||||
@@ -145,7 +156,7 @@ jobs:
|
||||
|
||||
mkdir yarn-test && cd yarn-test
|
||||
pmg yarn init -y
|
||||
pmg yarn add express
|
||||
pmg yarn add express@5.2.1
|
||||
pmg yarn add lodash@4.17.21
|
||||
|
||||
# Verification: yarn packages installed and lockfile created
|
||||
@@ -168,8 +179,8 @@ jobs:
|
||||
echo "Testing Pip single package installation..."
|
||||
mkdir pip-test && cd pip-test
|
||||
python -m venv venv && source venv/bin/activate
|
||||
pmg pip install requests
|
||||
pmg pip install numpy==1.24.0
|
||||
pmg pip install requests==2.32.4
|
||||
pmg pip install numpy==2.3.5
|
||||
pmg pip freeze > requirements.txt
|
||||
|
||||
# Verification: requirements.txt contains expected packages
|
||||
@@ -191,8 +202,8 @@ jobs:
|
||||
echo "Testing Pip3 single package installation..."
|
||||
mkdir pip3-test && cd pip3-test
|
||||
python -m venv venv && source venv/bin/activate
|
||||
pmg pip3 install requests
|
||||
pmg pip3 install numpy==1.24.0
|
||||
pmg pip3 install requests==2.32.4
|
||||
pmg pip3 install numpy==2.3.5
|
||||
pmg pip3 freeze > requirements.txt
|
||||
|
||||
# Verification: requirements.txt contains expected packages
|
||||
@@ -214,8 +225,8 @@ jobs:
|
||||
echo "Testing UV single package installation..."
|
||||
mkdir uv-test && cd uv-test
|
||||
pmg uv init --no-readme
|
||||
pmg uv add requests
|
||||
pmg uv add numpy
|
||||
pmg uv add requests==2.32.4
|
||||
pmg uv add numpy==2.3.5
|
||||
|
||||
# Verification: pyproject.toml lists expected dependencies
|
||||
test -f pyproject.toml
|
||||
@@ -247,8 +258,8 @@ jobs:
|
||||
echo "Testing Poetry single package installation..."
|
||||
mkdir poetry-test && cd poetry-test
|
||||
pmg poetry init --name poetry-test --no-interaction --quiet
|
||||
pmg poetry add requests
|
||||
pmg poetry add numpy
|
||||
pmg poetry add requests==2.32.4
|
||||
pmg poetry add numpy==2.3.5
|
||||
|
||||
# Verification: pyproject.toml dependencies updated
|
||||
test -f pyproject.toml
|
||||
|
||||
Reference in New Issue
Block a user