Skip to content
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

Replace Grunt with wp-scripts #1541

Merged
merged 30 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a60da22
Add `wp-scripts` package and initial webpack config
delawski Aug 1, 2024
7cf3b36
Enqueue `admin.js` in a new way
delawski Aug 1, 2024
10b3ae2
Include alerts list stylesheet in build workflow
delawski Aug 1, 2024
68886ee
Add dev task for watching files and building right away
delawski Aug 1, 2024
853e35e
Abstract away scripts and styles enqueueing logic
delawski Aug 1, 2024
deb1f73
Enqueue admin-exclude in new way
delawski Aug 1, 2024
afb67c4
Enqueue global.js in new way and clean up other scripts
delawski Aug 1, 2024
25ca12e
Move assets enqueue logic to central `plugin` class
delawski Aug 1, 2024
ce802c0
Use new way of enqueueing for alerts and settings
delawski Aug 1, 2024
6f2ae87
Use new way of enqueueing for Yoast connector asset
delawski Aug 1, 2024
c645802
Use new way of enqueueing for alert type highlight assets
delawski Aug 1, 2024
ee62d36
Remove Grunt with its dependencies
delawski Aug 1, 2024
fdb0ed3
Use JS linter from wp-scripts
delawski Aug 2, 2024
0c3240e
Auto-format JS files, fix other lint issues manually
delawski Aug 2, 2024
3ba4faa
Use the same tooling for E2E tests linting
delawski Aug 2, 2024
af8a059
Run Playwright tests via wp-scripts
delawski Aug 2, 2024
9d3d628
Ensure test-related files are ignored
delawski Aug 2, 2024
46f4105
Make `select2` and `jquery.timeago` npm dependencies
delawski Aug 2, 2024
c2aea51
Make `datepicker` styles a SCSS partial
delawski Aug 2, 2024
5f4fdcd
Use entire horizontal space in alerts table
delawski Aug 2, 2024
5671225
Use SVGs instead of custom font; reorg assets
delawski Aug 2, 2024
8862878
Fix unit tests
delawski Aug 2, 2024
ee6ff4a
Fix lint issues
delawski Aug 2, 2024
0dcadfd
Update docs
delawski Aug 2, 2024
04a1a1e
Build assets before linting and testing
delawski Aug 2, 2024
5939594
Merge branch 'refs/heads/develop' into feature/1502-remove-grunt
delawski Aug 2, 2024
2fbee97
Merge branch 'refs/heads/develop' into feature/1502-remove-grunt
delawski Aug 5, 2024
9530765
Merge branch 'refs/heads/develop' into feature/1502-remove-grunt
delawski Aug 5, 2024
5e4acf1
Deprecate constant instead of removing it
delawski Aug 6, 2024
79b2879
Lint before building assets so that it fails early
delawski Aug 6, 2024
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
8 changes: 6 additions & 2 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
.distignore
.editorconfig
.eslintignore
.eslintrc.json
.eslintrc.playwright.json
.eslintrc.js
.gitignore
.nvmrc
.phpunit.result.cache
composer.lock
docker-compose.build.yml
docker-compose.yml
Expand All @@ -26,7 +26,11 @@ node_modules
tests

# Playwright generated files.
/artifacts/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

# JS and SCSS source files.
/src/
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/ui/lib/
**/*.min.js
/vendor/
/node_modules/
/build/
Expand Down
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
extends: [
'plugin:@wordpress/eslint-plugin/recommended-with-formatting',
],
env: {
browser: true,
es6: true,
},
rules: {
'@wordpress/no-global-event-listener': 'off',
'jsdoc/check-indentation': 'error',
'@wordpress/dependency-group': 'error',
'import/order': [ 'error', { groups: [ 'builtin', [ 'external', 'unknown' ], 'internal', 'parent', 'sibling', 'index' ] } ],
'jsdoc/require-param': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/check-param-names': 'off',
},
};
17 changes: 0 additions & 17 deletions .eslintrc.json

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc.playwright.json

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ jobs:
- name: Lint
run: npm run lint

- name: Build
run: npm run build

- name: Pull custom Docker images
run: docker compose pull wordpress

- name: Test
run: npm run test

- name: Build
run: npm run build
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ debug.log
package.lock
.phpunit.result.cache

# Compiled files
ui/js/*.min.js
ui/css/*.min.css
alerts/js/*.min.js

# Generated test data
/artifacts/
tests/data/tmp/*
/test-results/
/playwright-report/
Expand Down
68 changes: 0 additions & 68 deletions Gruntfile.js

This file was deleted.

35 changes: 11 additions & 24 deletions alerts/class-alert-type-highlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Alert_Type_Highlight extends Alert_Type {

/**
* Main JS file script handle.
*
* @deprecated 4.1.0 Constant is not used anymore and will be removed.
*/
const SCRIPT_HANDLE = 'wp-stream-alert-highlight-js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick
I think that just in case someone is dequeueing this for whatever reason that we should keep the constant or deprecate it?

Copy link
Contributor Author

@delawski delawski Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must have missed it – definitely can be removed now :)

I'm sorry, I got it all wrong. You've got a valid point. Since we're not planning to release a major version anytime soon, it'd be wise to deprecate this constant instead of removing it. I'll add it back with a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5e4acf1.


Expand Down Expand Up @@ -307,34 +309,19 @@ public function ajax_remove_highlight() {
* @param string $page WP admin page.
*/
public function enqueue_scripts( $page ) {
if ( 'toplevel_page_wp_stream' === $page ) {
$min = wp_stream_min_suffix();

wp_register_script(
self::SCRIPT_HANDLE,
$this->plugin->locations['url'] . 'alerts/js/alert-type-highlight.' . $min . 'js',
array(
'jquery',
),
$this->plugin->get_version(),
false
);
if ( 'toplevel_page_wp_stream' !== $page ) {
return;
}

$exports = array(
$this->plugin->enqueue_asset(
'alert-type-highlight',
array(),
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'removeAction' => self::REMOVE_ACTION,
'security' => wp_create_nonce( self::REMOVE_ACTION_NONCE ),
);

wp_scripts()->add_data(
self::SCRIPT_HANDLE,
'data',
sprintf( 'var _streamAlertTypeHighlightExports = %s;', wp_json_encode( $exports ) )
);

wp_add_inline_script( self::SCRIPT_HANDLE, 'streamAlertTypeHighlight.init();', 'after' );
wp_enqueue_script( self::SCRIPT_HANDLE );
}
)
);
}

/**
Expand Down
83 changes: 0 additions & 83 deletions alerts/js/alert-type-highlight.js

This file was deleted.

File renamed without changes
3 changes: 3 additions & 0 deletions assets/stream.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Loading