-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Update jquery.validate | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 1 * *' # Run on the first day of the month | ||
workflow_dispatch: # Allow manual runs | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
|
||
- name: Set RepoRoot | ||
run: echo "RepoRoot=$(pwd)" >> $GITHUB_ENV | ||
|
||
- name: Update dependencies | ||
working-directory: ${{ env.RepoRoot }}/src/Mvc/build | ||
run: | | ||
npm install --no-lockfile | ||
npm run build | ||
echo "JQUERY_VALIDATE_VERSION=$(npm ls jquery-validation --json | jq -r '.dependencies["jquery-validation"].version')" >> $GITHUB_ENV | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: Update jquery.validate to ${{ env.JQUERY_VALIDATE_VERSION }} | ||
title: Update jquery.validate to ${{ env.JQUERY_VALIDATE_VERSION }} | ||
body: | | ||
Update jquery.validate to the latest version. | ||
# The branch name is based on the date in the format YYYY-MM-DD | ||
branch: update-jquery-validate-$(date +'%Y-%m-%d') | ||
base: main | ||
paths: | | ||
**/jquery.validate.js | ||
**/jquery.validate.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
const repoRoot = process.env.RepoRoot; | ||
if (!repoRoot) { | ||
throw new Error('RepoRoot environment variable is not set') | ||
} | ||
|
||
// Search all the folders in the src directory for the files "jquery.validate.js" and "jquery.validate.min.js" but skip this | ||
// folder as well as the "node_modules" folder, the "bin" folder, and the "obj" folder. Recurse over subfolders. | ||
|
||
const srcDir = path.join(repoRoot, 'src'); | ||
const files = []; | ||
const search = (dir) => { | ||
const entries = fs.readdirSync(dir, { withFileTypes: true }); | ||
for (const entry of entries) { | ||
if (entry.isDirectory() && entry.name !== 'node_modules' && entry.name !== 'bin' && entry.name !== 'obj') { | ||
search(path.join(dir, entry.name)); | ||
} else if (entry.isFile() && (entry.name === 'jquery.validate.js' || entry.name === 'jquery.validate.min.js')) { | ||
files.push(path.join(dir, entry.name)); | ||
} | ||
} | ||
} | ||
|
||
search(srcDir); | ||
|
||
// Replace the files found with the versions from <<current-folder>>/node_modules/jquery-validation/dist. | ||
// Note that <<current-folder>>/node_modules/jquery-validation/dist/jquery.validate.js needs to override the | ||
// jquery.validate.js file found in the files array and the same for jquery.validate.min.js. | ||
const nodeModulesDir = path.join(import.meta.dirname, 'node_modules', 'jquery-validation', 'dist'); | ||
|
||
for (const file of files) { | ||
const source = path.join(nodeModulesDir, path.basename(file)); | ||
const target = file; | ||
fs.copyFileSync(source, target); | ||
console.log(`Copied ${path.basename(file)} to ${target}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "jquery-validation-dependency", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "node copy-files.mjs" | ||
}, | ||
"devDependencies": { | ||
"jquery-validation": "^1.20.1" | ||
} | ||
} |