-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Infrastructure] Update jquery validate periodically #56725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
475924a
Update jquery validate periodically
javiercn b374654
Update create pr action
javiercn e244aa7
Update trigger so that it can be tested
javiercn 59c278d
Fix branch name
javiercn 1373d71
update trigger so that it can be tested
javiercn 46ccc35
Set permissions
javiercn b9d7024
Remove the pull request trigger
javiercn 37c0490
Update .github/workflows/update-jquery-validate.yml
javiercn 5f6250f
Update .github/workflows/update-jquery-validate.yml
javiercn 5a5e9c5
Apply suggestions from code review
javiercn 64ab638
Fix syntax error
javiercn 018be62
Update Identity UI script tags
javiercn 065c421
Fix paths
javiercn afaa867
Fix workflow
javiercn b63b37c
Remove base
javiercn b2aac34
Pin jquery to 1.20.0 as 1.20.1 is not on cdnjs
javiercn e4c0252
Update jquery.validate to 1.20.0 (#56803)
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,49 @@ | ||
| name: Update jquery-validation | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 0 1 * *' # Run on the first day of the month | ||
| workflow_dispatch: # Allow manual runs | ||
|
|
||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update-jquery-validate: | ||
| 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 | ||
| uses: dotnet/actions-create-pull-request@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: Update jquery.validate to ${{ env.JQUERY_VALIDATE_VERSION }} | ||
| title: [Templates][Identity] Update jquery-validation to ${{ env.JQUERY_VALIDATE_VERSION }} | ||
| body: | | ||
| Updates the jquery-validation scripts to ${{ env.JQUERY_VALIDATE_VERSION }} | ||
| # The branch name is based on the date in the format YYYY-MM-DD | ||
| branch: update-jquery-validate-to-${{ env.JQUERY_VALIDATE_VERSION }} | ||
| base: main | ||
| paths: | | ||
| **/jquery.validate.js | ||
| **/jquery.validate.min.js | ||
This file contains hidden or 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. | ||
javiercn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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. | ||
javiercn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 hidden or 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" | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.