Skip to content
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
5 changes: 3 additions & 2 deletions .github/clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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-")

Expand Down
113 changes: 113 additions & 0 deletions .github/workflows/validate-template-sync.yml
Original file line number Diff line number Diff line change
@@ -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<<EOF" >> $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!"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ wwwroot/*.js
node_modules
typings
dist
package-lock.json

# Ignore all tempfiles.
/tmp/*
Expand Down
2 changes: 1 addition & 1 deletion openapi/config-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
---
generatorName: typescript-axios
npmName: mx-platform-node
npmVersion: 1.12.0
npmVersion: 1.12.1
supportsES6: true
2 changes: 1 addition & 1 deletion openapi/config-v20111101.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
generatorName: typescript-axios
npmName: mx-platform-node-v20111101
npmVersion: 1.12.0
npmVersion: 1.12.1
supportsES6: true
2 changes: 1 addition & 1 deletion openapi/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
npmName: mx-platform-node
npmVersion: 1.12.0
npmVersion: 1.12.1
supportsES6: true
7 changes: 4 additions & 3 deletions openapi/templates/package.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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"
}
}