From 592b77fcb977448c39feaa0d5ddc039fdc602bf1 Mon Sep 17 00:00:00 2001 From: Genevieve Nuebel Date: Tue, 25 Nov 2025 12:03:32 -0700 Subject: [PATCH] Fix dependency version issues, bump patch, fix clean and ignore files --- .github/clean.rb | 5 +- .github/workflows/validate-template-sync.yml | 113 +++++++++++++++++++ .gitignore | 1 + openapi/config-latest.yml | 2 +- openapi/config-v20111101.yml | 2 +- openapi/config.yml | 2 +- openapi/templates/package.mustache | 7 +- package.json | 9 +- 8 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/validate-template-sync.yml diff --git a/.github/clean.rb b/.github/clean.rb index 5f3f11d..dacc03d 100644 --- a/.github/clean.rb +++ b/.github/clean.rb @@ -6,12 +6,13 @@ ".openapi-generator-ignore", "LICENSE", "openapi", - "openapitools.json" + "openapitools.json", + "tmp" ].freeze ::Dir.each_child(::Dir.pwd) do |source| next if ALLOW_LIST.include?(source) - + # Preserve test-output directories for multi-version POC testing next if source.start_with?("test-output-") diff --git a/.github/workflows/validate-template-sync.yml b/.github/workflows/validate-template-sync.yml new file mode 100644 index 0000000..d4e4550 --- /dev/null +++ b/.github/workflows/validate-template-sync.yml @@ -0,0 +1,113 @@ +name: Validate Template Sync + +on: + pull_request: + paths: + - '**/package.json' + - 'openapi/templates/package.mustache' + push: + branches: [master] + workflow_dispatch: + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Find all package.json files + id: find_packages + run: | + # Find all package.json files in version directories and root + PACKAGES=$(find . -maxdepth 2 -name "package.json" \( -path "./*/package.json" -o -path "./package.json" \) ! -path "*/node_modules/*" || true) + echo "Found package.json files:" + echo "$PACKAGES" + echo "packages<> $GITHUB_OUTPUT + echo "$PACKAGES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Extract dependencies from template + id: template + run: | + AXIOS_VERSION=$(grep -A 1 '"dependencies"' openapi/templates/package.mustache | grep axios | sed 's/.*"axios": "\(.*\)".*/\1/') + TS_VERSION=$(grep '"typescript"' openapi/templates/package.mustache | sed 's/.*"typescript": "\(.*\)".*/\1/') + NODE_VERSION=$(grep '@types/node' openapi/templates/package.mustache | sed 's/.*"@types\/node": "\(.*\)".*/\1/') + + echo "axios=$AXIOS_VERSION" >> $GITHUB_OUTPUT + echo "typescript=$TS_VERSION" >> $GITHUB_OUTPUT + echo "node=$NODE_VERSION" >> $GITHUB_OUTPUT + + echo "📄 Template versions:" + echo " axios: $AXIOS_VERSION" + echo " typescript: $TS_VERSION" + echo " @types/node: $NODE_VERSION" + + - name: Validate all package.json files + run: | + TEMPLATE_AXIOS="${{ steps.template.outputs.axios }}" + TEMPLATE_TS="${{ steps.template.outputs.typescript }}" + TEMPLATE_NODE="${{ steps.template.outputs.node }}" + + MISMATCH=false + MISMATCH_DETAILS="" + + # Check each package.json file + while IFS= read -r package_file; do + [ -z "$package_file" ] && continue + + # Get directory name for clearer output + DIR=$(dirname "$package_file") + [ "$DIR" = "." ] && DIR="root" + + echo "" + echo "🔍 Checking $DIR/package.json..." + + # Extract versions from this package.json + PKG_AXIOS=$(jq -r '.dependencies.axios // empty' "$package_file") + PKG_TS=$(jq -r '.devDependencies.typescript // empty' "$package_file") + PKG_NODE=$(jq -r '.devDependencies["@types/node"] // empty' "$package_file") + + echo " axios: $PKG_AXIOS" + echo " typescript: $PKG_TS" + echo " @types/node: $PKG_NODE" + + # Compare versions + if [ -n "$PKG_AXIOS" ] && [ "$PKG_AXIOS" != "$TEMPLATE_AXIOS" ]; then + echo " ❌ MISMATCH: axios ($PKG_AXIOS vs template $TEMPLATE_AXIOS)" + MISMATCH=true + MISMATCH_DETAILS="${MISMATCH_DETAILS}\n - $DIR: axios $PKG_AXIOS (expected $TEMPLATE_AXIOS)" + fi + + if [ -n "$PKG_TS" ] && [ "$PKG_TS" != "$TEMPLATE_TS" ]; then + echo " ❌ MISMATCH: typescript ($PKG_TS vs template $TEMPLATE_TS)" + MISMATCH=true + MISMATCH_DETAILS="${MISMATCH_DETAILS}\n - $DIR: typescript $PKG_TS (expected $TEMPLATE_TS)" + fi + + if [ -n "$PKG_NODE" ] && [ "$PKG_NODE" != "$TEMPLATE_NODE" ]; then + echo " ❌ MISMATCH: @types/node ($PKG_NODE vs template $TEMPLATE_NODE)" + MISMATCH=true + MISMATCH_DETAILS="${MISMATCH_DETAILS}\n - $DIR: @types/node $PKG_NODE (expected $TEMPLATE_NODE)" + fi + + if [ "$MISMATCH" = false ]; then + echo " ✅ All versions match template" + fi + done <<< "${{ steps.find_packages.outputs.packages }}" + + if [ "$MISMATCH" = true ]; then + echo "" + echo "❌ ERROR: Template and generated files are out of sync!" + echo "" + echo "Mismatches found:" + echo -e "$MISMATCH_DETAILS" + echo "" + echo "📝 To fix:" + echo " 1. Update openapi/templates/package.mustache with the correct versions" + echo " 2. Regenerate all versions to sync package.json files" + echo " 3. Or manually update all package.json files to match the template" + exit 1 + fi + + echo "" + echo "✅ All package.json files match the template!" diff --git a/.gitignore b/.gitignore index 2a5ad35..bf10a49 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ wwwroot/*.js node_modules typings dist +package-lock.json # Ignore all tempfiles. /tmp/* diff --git a/openapi/config-latest.yml b/openapi/config-latest.yml index f47b7e3..9338ab5 100644 --- a/openapi/config-latest.yml +++ b/openapi/config-latest.yml @@ -3,5 +3,5 @@ --- generatorName: typescript-axios npmName: mx-platform-node -npmVersion: 1.12.0 +npmVersion: 1.12.1 supportsES6: true diff --git a/openapi/config-v20111101.yml b/openapi/config-v20111101.yml index f70d841..9479856 100644 --- a/openapi/config-v20111101.yml +++ b/openapi/config-v20111101.yml @@ -1,5 +1,5 @@ --- generatorName: typescript-axios npmName: mx-platform-node-v20111101 -npmVersion: 1.12.0 +npmVersion: 1.12.1 supportsES6: true diff --git a/openapi/config.yml b/openapi/config.yml index 369e6f4..64b895d 100644 --- a/openapi/config.yml +++ b/openapi/config.yml @@ -1,4 +1,4 @@ --- npmName: mx-platform-node -npmVersion: 1.12.0 +npmVersion: 1.12.1 supportsES6: true diff --git a/openapi/templates/package.mustache b/openapi/templates/package.mustache index 456831d..19dd5bf 100644 --- a/openapi/templates/package.mustache +++ b/openapi/templates/package.mustache @@ -16,12 +16,13 @@ "build": "tsc --outDir dist/", "prepare": "npm run build" }, + "_comment": "IMPORTANT: Keep these dependency versions in sync with security updates. If package.json is manually updated for security fixes, this template MUST also be updated to prevent automated generation from overwriting the fixes.", "dependencies": { - "axios": "^0.21.4" + "axios": "^1.6.8" }, "devDependencies": { - "@types/node": "^12.11.5", - "typescript": "^3.6.4" + "@types/node": "^20.12.7", + "typescript": "^5.4.5" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} "publishConfig": { diff --git a/package.json b/package.json index 7b9cde7..a7b501a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mx-platform-node", - "version": "1.12.0", + "version": "1.12.1", "description": "A Node library for the MX Platform API.", "author": "MX", "keywords": [ @@ -16,11 +16,12 @@ "build": "tsc --outDir dist/", "prepare": "npm run build" }, + "_comment": "IMPORTANT: Keep these dependency versions in sync with security updates. If package.json is manually updated for security fixes, this template MUST also be updated to prevent automated generation from overwriting the fixes.", "dependencies": { - "axios": "^0.21.4" + "axios": "^1.6.8" }, "devDependencies": { - "@types/node": "^12.11.5", - "typescript": "^3.6.4" + "@types/node": "^20.12.7", + "typescript": "^5.4.5" } }