Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/**
|
|
* External dependencies
|
|
*/
|
|
const { sync: spawn } = require( 'cross-spawn' );
|
|
const { sync: resolveBin } = require( 'resolve-bin' );
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
const {
|
|
fromConfigRoot,
|
|
getArgsFromCLI,
|
|
hasArgInCLI,
|
|
hasFileArgInCLI,
|
|
hasProjectFile,
|
|
hasPackageProp,
|
|
} = require( '../utils' );
|
|
|
|
const args = getArgsFromCLI();
|
|
|
|
const defaultFilesArgs = hasFileArgInCLI() ? [] : [ '.' ];
|
|
|
|
// See: https://npmpackagejsonlint.org/docs/en/configuration
|
|
const hasLintConfig =
|
|
hasArgInCLI( '-c' ) ||
|
|
hasArgInCLI( '--configFile' ) ||
|
|
hasProjectFile( '.npmpackagejsonlintrc.js' ) ||
|
|
hasProjectFile( '.npmpackagejsonlintrc.json' ) ||
|
|
hasProjectFile( '.npmpackagejsonlintrc.yaml' ) ||
|
|
hasProjectFile( '.npmpackagejsonlintrc.yml' ) ||
|
|
hasProjectFile( 'npmpackagejsonlint.config.js' ) ||
|
|
hasProjectFile( '.npmpackagejsonlintrc' ) ||
|
|
hasPackageProp( 'npmpackagejsonlint' ) ||
|
|
// npm-package-json-lint v3.x used a different prop name.
|
|
hasPackageProp( 'npmPackageJsonLintConfig' );
|
|
|
|
const defaultConfigArgs = ! hasLintConfig
|
|
? [ '--configFile', fromConfigRoot( 'npmpackagejsonlint.json' ) ]
|
|
: [];
|
|
|
|
// See: https://github.com/tclindner/npm-package-json-lint/#cli-commands-and-configuration.
|
|
const hasIgnoredFiles =
|
|
hasArgInCLI( '--ignorePath' ) ||
|
|
hasProjectFile( '.npmpackagejsonlintignore' );
|
|
|
|
const defaultIgnoreArgs = ! hasIgnoredFiles
|
|
? [ '--ignorePath', fromConfigRoot( '.npmpackagejsonlintignore' ) ]
|
|
: [];
|
|
|
|
const result = spawn(
|
|
resolveBin( 'npm-package-json-lint', { executable: 'npmPkgJsonLint' } ),
|
|
[
|
|
...defaultConfigArgs,
|
|
...defaultIgnoreArgs,
|
|
...args,
|
|
...defaultFilesArgs,
|
|
],
|
|
{ stdio: 'inherit' }
|
|
);
|
|
|
|
process.exit( result.status );
|