diff --git a/.github/workflows/prado.yml b/.github/workflows/prado.yml index 20050d700..545c332f0 100644 --- a/.github/workflows/prado.yml +++ b/.github/workflows/prado.yml @@ -93,6 +93,27 @@ jobs: run: | composer functionaltest + prado-js: + name: Prado JS (ESLint + Vitest) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + + - name: Install npm dependencies + run: npm install + + - name: Lint JavaScript (ESLint) + run: npm run lint + + - name: Run JavaScript unit tests (Vitest) + run: npm test + prado-macos: name: Prado (macOS) runs-on: macos-latest diff --git a/.gitignore b/.gitignore index 5b09f6a32..79ce49fda 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ atlassian-ide-plugin.xml .claude/ tests/FunctionalTests/results.dat tests/unit/Data/db/ +/node_modules +/package-lock.json # Composer stuff vendor/* @@ -24,3 +26,6 @@ vendor/* sauce_connect.log tests/unit/Data/SqlMap/sqlite/tests.db + +# Vitest cache artefacts +vitest.config.js.timestamp-* diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..209e3ef4b --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index b53e482b1..3eb622283 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,8 +1,10 @@ exclude('agents/') ->exclude('build/') ->exclude('docs/') + ->exclude('node_modules/') ->exclude('tests/') ->exclude('vendor/') ->in(__DIR__); diff --git a/composer.json b/composer.json index 97153fd87..49b5fe928 100644 --- a/composer.json +++ b/composer.json @@ -99,20 +99,31 @@ "devtools": [ "composer require --dev friendsofphp/php-cs-fixer", "composer require --dev phpstan/phpstan", - "composer require --dev phpunit/phpunit" + "composer require --dev phpunit/phpunit", + "npm install" ], "gendoc": "phpdoc --template=./vendor/pradosoft/prado-phpdoc-template", + "csfix": "php-cs-fixer fix", + "stan": "phpstan analyse --memory-limit=512M", "unittest": "phpunit --testsuite unit", - "functionaltest": [ - "Composer\\Config::disableProcessTimeout", - "phpunit --testsuite functional" - ], - "stantest": "vendor/bin/phpunit --testsuite phpstan", "fulltest": [ "php-cs-fixer fix", "phpstan analyse --memory-limit=512M", "phpunit --testsuite unit" - ] + ], + "jslint": "npm run lint", + "jsfix": "npm run lint:fix", + "jstest": "npm run test", + "jswatch": "npm run test:watch", + "jsfull": [ + "npm run lint:fix", + "npm run test" + ], + "functionaltest": [ + "Composer\\Config::disableProcessTimeout", + "phpunit --testsuite functional" + ], + "stantest": "vendor/bin/phpunit --testsuite phpstan" }, "bin" : [ "bin/prado-cli" diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..e4764f690 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,79 @@ +import js from '@eslint/js'; +import globals from 'globals'; + +export default [ + { + // Lint all PRADO client-side source scripts. + files: ['framework/Web/Javascripts/source/**/*.js'], + + languageOptions: { + // Current source targets ES5+ with some ES6 idioms. + ecmaVersion: 2015, + + // Scripts are concatenated / loaded as