diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index b1e6f62f6..6a978b3ea 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -419,6 +419,7 @@ return array( 'Combodo\\iTop\\Core\\Trigger\\Enum\\SubscriptionPolicy' => $baseDir . '/sources/Core/Trigger/Enum/SubscriptionPolicy.php', 'Combodo\\iTop\\Dependencies\\AbstractHook' => $baseDir . '/sources/Dependencies/AbstractHook.php', 'Combodo\\iTop\\Dependencies\\Composer\\iTopComposer' => $baseDir . '/sources/Dependencies/Composer/iTopComposer.php', + 'Combodo\\iTop\\Dependencies\\NPM\\iTopNPM' => $baseDir . '/sources/Dependencies/NPM/iTopNPM.php', 'Combodo\\iTop\\DesignDocument' => $baseDir . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\DesignElement' => $baseDir . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\Form\\Field\\AbstractSimpleField' => $baseDir . '/sources/Form/Field/AbstractSimpleField.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index 5422a3f3f..d4cd1ceca 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -794,6 +794,7 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f 'Combodo\\iTop\\Core\\Trigger\\Enum\\SubscriptionPolicy' => __DIR__ . '/../..' . '/sources/Core/Trigger/Enum/SubscriptionPolicy.php', 'Combodo\\iTop\\Dependencies\\AbstractHook' => __DIR__ . '/../..' . '/sources/Dependencies/AbstractHook.php', 'Combodo\\iTop\\Dependencies\\Composer\\iTopComposer' => __DIR__ . '/../..' . '/sources/Dependencies/Composer/iTopComposer.php', + 'Combodo\\iTop\\Dependencies\\NPM\\iTopNPM' => __DIR__ . '/../..' . '/sources/Dependencies/NPM/iTopNPM.php', 'Combodo\\iTop\\DesignDocument' => __DIR__ . '/../..' . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\DesignElement' => __DIR__ . '/../..' . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\Form\\Field\\AbstractSimpleField' => __DIR__ . '/../..' . '/sources/Form/Field/AbstractSimpleField.php', diff --git a/lib/composer/installed.php b/lib/composer/installed.php index 54fa11a53..36ca1d988 100644 --- a/lib/composer/installed.php +++ b/lib/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'combodo/itop', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '0c3e839381fb70ad7856576de4fc1da17278dfa2', + 'reference' => '26e588c1c3f3c4c30b0da3f14e0c4726d49d659e', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -22,7 +22,7 @@ 'combodo/itop' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '0c3e839381fb70ad7856576de4fc1da17278dfa2', + 'reference' => '26e588c1c3f3c4c30b0da3f14e0c4726d49d659e', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/package.json b/package.json index e74c4bc74..9f60a79c8 100644 --- a/package.json +++ b/package.json @@ -26,5 +26,9 @@ "showdown": "^2.0.0", "tippy.js": "^6.2.5", "toastify-js": "^1.12.0" + }, + "scripts": { + "postinstall": "php .make/dependencies/rmUnnecessaryFolders.php --manager npm", + "postupdate": "php .make/dependencies/rmUnnecessaryFolders.php --manager npm" } } diff --git a/sources/Dependencies/NPM/iTopNPM.php b/sources/Dependencies/NPM/iTopNPM.php new file mode 100644 index 000000000..1485a5b70 --- /dev/null +++ b/sources/Dependencies/NPM/iTopNPM.php @@ -0,0 +1,73 @@ + + * + */ + +namespace Combodo\iTop\Dependencies\NPM; + +use Combodo\iTop\Dependencies\AbstractHook; + +class iTopNPM extends AbstractHook +{ + /** + * @inheritDoc + */ + protected function GetDependenciesRootFolderAbsPath(): string + { + return $this->GetApprootPathWithSlashes() . "node_modules"; + } + + /** + * @inheritDoc + */ + public function ListAllowedQuestionnableFoldersAbsPaths(): array + { + $APPROOT_WITH_SLASHES = $this->GetDependenciesRootFolderAbsPath(); + return [ + // jQuery Sizzle used by jQuery + $APPROOT_WITH_SLASHES . '/jquery/external', + ]; + } + + /** + * @inheritDoc + */ + public function ListDeniedQuestionnableFolderAbsPaths(): array + { + $APPROOT_WITH_SLASHES = $this->GetDependenciesRootFolderAbsPath(); + return [ + $APPROOT_WITH_SLASHES . '/c3/htdocs', + $APPROOT_WITH_SLASHES . '/clipboard/demo', + $APPROOT_WITH_SLASHES . '/clipboard/test', + $APPROOT_WITH_SLASHES . '/delegate/demo', + $APPROOT_WITH_SLASHES . '/delegate/test', + $APPROOT_WITH_SLASHES . '/good-listener/demo', + $APPROOT_WITH_SLASHES . '/good-listener/test', + $APPROOT_WITH_SLASHES . '/jquery-migrate/test', + $APPROOT_WITH_SLASHES . '/jquery-ui/external', + $APPROOT_WITH_SLASHES . '/jquery-ui-dist/external', + $APPROOT_WITH_SLASHES . '/mousetrap/plugins/record/tests', + $APPROOT_WITH_SLASHES . '/mousetrap/tests', + $APPROOT_WITH_SLASHES . '/select/demo', + $APPROOT_WITH_SLASHES . '/select/test', + $APPROOT_WITH_SLASHES . '/selectize-plugin-a11y/examples', + $APPROOT_WITH_SLASHES . '/tiny-emitter/test', + ]; + } +} \ No newline at end of file diff --git a/tests/php-unit-tests/unitary-tests/sources/Dependencies/NPM/iTopNPMTest.php b/tests/php-unit-tests/unitary-tests/sources/Dependencies/NPM/iTopNPMTest.php new file mode 100644 index 000000000..a10aa38d9 --- /dev/null +++ b/tests/php-unit-tests/unitary-tests/sources/Dependencies/NPM/iTopNPMTest.php @@ -0,0 +1,59 @@ + + * + */ +class iTopNPMTest extends ItopTestCase +{ + + protected function setUp(): void + { + parent::setUp(); + clearstatcache(); + } + + /** + * This is NOT a unit test, this test the iTop instance running the test ... + */ + public function testAllFoldersCovered() + { + $oDependenciesHandler = new iTopNPM(); + $aAllowedAndDeniedDirs = array_merge( + $oDependenciesHandler->ListAllowedQuestionnableFoldersAbsPaths(), + $oDependenciesHandler->ListDeniedQuestionnableFolderAbsPaths() + ); + + $aExistingDirs = $oDependenciesHandler->ListAllQuestionnableFoldersAbsPaths(); + + $aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs); + $aExtra = array_diff($aAllowedAndDeniedDirs, $aExistingDirs); + + $this->assertEmpty( + $aMissing, + 'Test dirs exists in /node_modules !'."\n" + .' They must be declared either in the allowed or denied list in '.iTopNPM::class." (see N°2651).\n" + .' List of dirs:'."\n".var_export($aMissing, true) + ); + } +}