Skip to content

Commit b0070f8

Browse files
kadamwhiteclaude
andcommitted
chore: remaining review-pass fixes
- node-wpapi.php enqueued browser/wpapi.min.js, a path nothing has ever built; with the hook-name typo fixed that would have become a live 404 on every page load. Point it at the UMD bundle tsdown actually emits (dist/browser/wpapi.umd.js) and drop the SCRIPT_DEBUG branch — there is only one browser artifact now. - update-default-routes-json.js attached its download-failure handler as a trailing .catch, so an exception thrown by the downstream simplify-and-write callback was misreported as "Could not download endpoint JSON". The handler now sits alongside the callback so downstream errors surface with their real stack. - The superagent test directory held a single stub assertion but kept four config references alive (vitest include, eslint files, two npm scripts). Moved the test to tests/unit/superagent-stub.js and dropped the extra config surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 50906c1 commit b0070f8

6 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎build/scripts/update-default-routes-json.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ const getJSON = ( cbFn ) => {
124124
return process.exit( 1 );
125125
}
126126

127-
return response.json().then( cbFn );
127+
return response.json();
128128
} )
129-
.catch( ( err ) => {
129+
.then( cbFn, ( err ) => {
130+
// Rejection handler alongside cbFn (rather than a trailing .catch) so
131+
// errors thrown downstream in cbFn are not misreported as download failures.
130132
console.error( '\nSomething went wrong! Could not download endpoint JSON.' );
131133
console.error( err );
132134
process.exit( 1 );

‎eslint.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module.exports = tseslint.config(
114114
rules: styleRules,
115115
},
116116
{
117-
files: [ 'tests/**/*.js', 'fetch/tests/**/*.js', 'superagent/tests/**/*.js' ],
117+
files: [ 'tests/**/*.js', 'fetch/tests/**/*.js' ],
118118
languageOptions: {
119119
globals: testGlobals,
120120
},

‎node-wpapi.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
* @return void
1616
*/
1717
function enqueue_scripts() {
18-
$uri = plugin_dir_url( __FILE__ ) . 'browser/wpapi.min.js';
19-
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
20-
$uri = plugin_dir_url( __FILE__ ) . 'browser/wpapi.js';
21-
}
18+
$uri = plugin_dir_url( __FILE__ ) . 'dist/browser/wpapi.umd.js';
2219

2320
// Read the package.json to derive the version number.
2421
$package = read_json( plugin_dir_path( __FILE__ ) . '/package.json' );

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"format:check": "prettier --check .",
4848
"watch": "vitest",
4949
"test:all": "vitest run",
50-
"test:unit": "vitest run tests/unit fetch/tests/unit superagent/tests/unit",
50+
"test:unit": "vitest run tests/unit fetch/tests/unit",
5151
"test:integration": "vitest run tests/integration --no-file-parallelism",
52-
"test:ci": "npm run eslint && vitest run tests/unit fetch/tests/unit superagent/tests/unit --coverage",
52+
"test:ci": "npm run eslint && vitest run tests/unit fetch/tests/unit --coverage",
5353
"pretest": "npm run lint || true",
5454
"test": "vitest run --coverage"
5555
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe( 'wpapi/superagent', () => {
44

55
it( 'throws an error directing consumers to the fetch-based default export', () => {
6-
expect( () => require( '../../' ) ).toThrow( /wpapi\/superagent was removed in wpapi 2.0.0/ );
6+
expect( () => require( '../../superagent' ) ).toThrow( /wpapi\/superagent was removed in wpapi 2.0.0/ );
77
} );
88

99
} );

‎vitest.config.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module.exports = defineConfig( {
1313
include: [
1414
'tests/**/*.js',
1515
'fetch/tests/**/*.js',
16-
'superagent/tests/**/*.js',
1716
],
1817
exclude: [
1918
'**/node_modules/**',

0 commit comments

Comments
 (0)