-
Notifications
You must be signed in to change notification settings - Fork 146
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
enhance: revamp transaction summary #1485
base: develop
Are you sure you want to change the base?
Changes from 7 commits
4f7f332
2b237da
6af33b4
d986e0e
9b903e2
35af3a2
788e070
34e33ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
'use strict'; | ||
module.exports = function(grunt) { | ||
var formBuilderAssets = require('./admin/form-builder/assets/js/form-builder-assets.js'); | ||
|
||
var pkg = grunt.file.readJSON('package.json'); | ||
|
||
grunt.initConfig({ | ||
|
@@ -16,14 +15,11 @@ module.exports = function(grunt) { | |
|
||
// Compile all .less files. | ||
less: { | ||
|
||
// one to one | ||
front: { | ||
files: { | ||
'<%= dirs.css %>/frontend-forms.css': '<%= dirs.less %>/frontend-forms.less' | ||
} | ||
}, | ||
|
||
admin: { | ||
files: { | ||
'<%= dirs.css %>/wpuf-form-builder.css': ['admin/form-builder/assets/less/form-builder.less'], | ||
|
@@ -84,11 +80,14 @@ module.exports = function(grunt) { | |
}, | ||
|
||
watch: { | ||
options: { | ||
debounceDelay: 500, // Add debounce delay | ||
spawn: false // Recommended for better performance | ||
}, | ||
Comment on lines
+83
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caution: 'spawn: false' may cause issues if tasks modify watched files Setting |
||
less: { | ||
files: ['<%= dirs.less %>/*.less'], | ||
tasks: ['less:front', 'less:admin'] | ||
}, | ||
|
||
formBuilder: { | ||
files: [ | ||
'admin/form-builder/assets/less/*', | ||
|
@@ -101,126 +100,30 @@ module.exports = function(grunt) { | |
'concat:formBuilder', 'concat:templates', 'less:front' | ||
] | ||
}, | ||
|
||
vue: { | ||
files: [ | ||
'assets/js/subscriptions.js', | ||
'assets/css/admin/subscriptions.css', | ||
'assets/js/components/**/*.vue', | ||
'assets/js/stores/**/*.js', | ||
], | ||
tasks: [ | ||
'shell:npm_build' | ||
] | ||
} | ||
}, | ||
|
||
// Clean up build directory | ||
clean: { | ||
main: ['build/'] | ||
}, | ||
|
||
// Copy the plugin into the build directory | ||
copy: { | ||
main: { | ||
src: [ | ||
'**', | ||
'!node_modules/**', | ||
'!build/**', | ||
'!admin/form-builder/assets/**', | ||
'!assets/css/*.less', | ||
'!bin/**', | ||
'!.git/**', | ||
'!includes/pro/.git/**', | ||
'!Gruntfile.js', | ||
'!secret.json', | ||
'!package.json', | ||
'!debug.log', | ||
'!phpunit.xml', | ||
'!.gitignore', | ||
'!.gitmodules', | ||
'!npm-debug.log', | ||
'!plugin-deploy.sh', | ||
'!export.sh', | ||
'!config.codekit', | ||
'!**/nbproject/**', | ||
'!assets/less/**', | ||
'!assets/tailwind/**', | ||
'!tests/**', | ||
'!**/Gruntfile.js', | ||
'!**/package.json', | ||
'!**/readme.md', | ||
'!**/docs.md', | ||
'!**/*~', | ||
'!**/log.txt', | ||
'!**/package-lock.json', | ||
'!**/appsero.json', | ||
'!**/composer.json', | ||
'!**/composer.lock', | ||
'!**/phpcs-report.txt', | ||
'!**/phpcs.xml.dist' | ||
'assets/js/**/*.{js,vue}', | ||
'src/js/**/*.{js,vue}', | ||
'!assets/js/**/*.min.js', // Exclude minified files | ||
'!src/js/**/*.min.js' // Exclude minified files | ||
], | ||
dest: 'build/' | ||
} | ||
}, | ||
|
||
//Compress build directory into <name>.zip and <name>-<version>.zip | ||
compress: { | ||
main: { | ||
options: { | ||
mode: 'zip', | ||
archive: './build/wp-user-frontend-v'+pkg.version+'.zip' | ||
}, | ||
expand: true, | ||
cwd: 'build/', | ||
src: ['**/*'], | ||
dest: 'wp-user-frontend' | ||
} | ||
}, | ||
|
||
// jshint | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc', | ||
reporter: require('jshint-stylish') | ||
}, | ||
|
||
formBuilder: [ | ||
'admin/form-builder/assets/js/**/*.js', | ||
'!admin/form-builder/assets/js/jquery-siaf-start.js', | ||
'!admin/form-builder/assets/js/jquery-siaf-end.js', | ||
'assets/js/wpuf-form-builder-wpuf-forms.js', | ||
] | ||
}, | ||
|
||
// concat/join files | ||
concat: { | ||
formBuilder: { | ||
files: { | ||
'<%= dirs.js %>/wpuf-form-builder.js': 'admin/form-builder/assets/js/form-builder.js', | ||
'<%= dirs.js %>/wpuf-form-builder-mixins.js': formBuilderAssets.mixins, | ||
'<%= dirs.js %>/wpuf-form-builder-components.js': formBuilderAssets.components, | ||
}, | ||
}, | ||
|
||
templates: { | ||
tasks: ['shell:npm_build'], | ||
options: { | ||
process: function(src, filepath) { | ||
var id = filepath.replace('/template.php', '').split('/').pop(); | ||
|
||
return '<script type="text/x-template" id="tmpl-wpuf-' + id + '">\n' + src + '</script>\n'; | ||
} | ||
}, | ||
files: { | ||
'<%= dirs.template %>/form-components.php': formBuilderAssets.componentTemplates, | ||
debounceDelay: 1000, // Longer delay for Vue files | ||
spawn: false, | ||
interval: 1000 // Add interval | ||
} | ||
} | ||
}, | ||
|
||
// is to run NPM commands through Grunt | ||
// Shell command for npm build | ||
shell: { | ||
npm_build: { | ||
command: 'npm run build', | ||
options: { | ||
stdout: true, | ||
stderr: true | ||
} | ||
} | ||
} | ||
}); | ||
|
@@ -239,13 +142,22 @@ module.exports = function(grunt) { | |
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' ); | ||
grunt.loadNpmTasks( 'grunt-shell' ); | ||
|
||
grunt.registerTask( 'default', [ 'less', 'concat', 'uglify', 'i18n' ] ); | ||
// Task optimization | ||
let changedFiles = Object.create(null); | ||
let onChange = grunt.util._.debounce(function() { | ||
grunt.config('shell.npm_build.src', Object.keys(changedFiles)); | ||
changedFiles = Object.create(null); | ||
}, 200); | ||
Comment on lines
+145
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential issue with 'shell.npm_build.src' configuration In the Consider modifying the shell command to accept the changed files if needed. For example: onChange = grunt.util._.debounce(function() {
- grunt.config('shell.npm_build.src', Object.keys(changedFiles));
+ let files = Object.keys(changedFiles).join(' ');
+ grunt.config('shell.npm_build.command', `npm run build -- ${files}`);
changedFiles = Object.create(null);
}, 200); Additionally, ensure that your
|
||
|
||
// file auto generation | ||
grunt.registerTask( 'i18n', [ 'makepot' ] ); | ||
grunt.registerTask( 'readme', [ 'wp_readme_to_markdown' ] ); | ||
grunt.event.on('watch', function(action, filepath) { | ||
changedFiles[filepath] = action; | ||
onChange(); | ||
}); | ||
Comment on lines
+145
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Issue with task optimization: 'shell.npm_build.src' is not utilized The optimization code attempts to set grunt.config('shell.npm_build.src', Object.keys(changedFiles)); However, the Consider modifying the task optimization logic. If the goal is to conditionally run the npm build only when certain files change, you might:
Example refactored code: let changedFiles = Object.create(null);
let onChange = grunt.util._.debounce(function() {
- grunt.config('shell.npm_build.src', Object.keys(changedFiles));
// If any Vue files have changed, run npm build
if (Object.keys(changedFiles).some(file => file.endsWith('.vue') || file.endsWith('.js'))) {
grunt.task.run('shell:npm_build');
}
changedFiles = Object.create(null);
}, 200); This ensures that |
||
|
||
// build stuff | ||
grunt.registerTask( 'release', [ 'less', 'concat', 'uglify', 'i18n', 'readme' ] ); | ||
grunt.registerTask( 'zip', [ 'clean', 'copy', 'compress' ] ); | ||
// Define tasks | ||
grunt.registerTask( 'default', ['less', 'concat', 'uglify', 'i18n'] ); | ||
grunt.registerTask( 'i18n', ['makepot'] ); | ||
grunt.registerTask( 'readme', ['wp_readme_to_markdown'] ); | ||
grunt.registerTask( 'release', ['less', 'concat', 'uglify', 'i18n', 'readme'] ); | ||
grunt.registerTask( 'zip', ['clean', 'copy', 'compress'] ); | ||
}; |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
'debounceDelay' is deprecated in 'grunt-contrib-watch' v^1.0.0
debounceDelay
option withawaitWriteFinish
for better compatibility and performance.🔗 Analysis chain
Ensure 'debounceDelay' is compatible with your Grunt version
The
debounceDelay
option might be deprecated in newer versions ofgrunt-contrib-watch
. Consider verifying ifdebounceDelay
is still supported or if you should useawaitWriteFinish
or adjust theinterval
option instead.You can check the Grunt documentation or run the following script to confirm if
debounceDelay
is supported:🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 210
Script:
Length of output: 98