diff --git a/extensions/akismet/.editorconfig b/extensions/akismet/.editorconfig index 87694ddab..a61a3ab36 100644 --- a/extensions/akismet/.editorconfig +++ b/extensions/akismet/.editorconfig @@ -15,5 +15,5 @@ indent_size = 2 [*.{diff,md}] trim_trailing_whitespace = false -[*.php] +[*.{php,xml,json}] indent_size = 4 diff --git a/extensions/akismet/.gitattributes b/extensions/akismet/.gitattributes index 16ac2892f..ca0f40972 100644 --- a/extensions/akismet/.gitattributes +++ b/extensions/akismet/.gitattributes @@ -1,5 +1,18 @@ .gitattributes export-ignore .gitignore export-ignore +.gitmodules export-ignore +.github export-ignore +.travis export-ignore .travis.yml export-ignore +.editorconfig export-ignore +.styleci.yml export-ignore + +phpunit.xml export-ignore +tests export-ignore js/dist/* -diff +js/dist/* linguist-generated +js/dist-typings/* linguist-generated +js/yarn.lock -diff + +* text=auto eol=lf diff --git a/extensions/akismet/.github/workflows/backend.yml b/extensions/akismet/.github/workflows/backend.yml new file mode 100644 index 000000000..43ea32c86 --- /dev/null +++ b/extensions/akismet/.github/workflows/backend.yml @@ -0,0 +1,15 @@ +name: Akismet PHP + +on: [workflow_dispatch, push, pull_request] + +# The reusable workflow definitions will be moved to the `flarum/framework` repo soon. +# This will break your current script. +# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure. + +jobs: + run: + uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main + with: + enable_backend_testing: true + + backend_directory: . \ No newline at end of file diff --git a/extensions/akismet/.github/workflows/build.yml b/extensions/akismet/.github/workflows/build.yml deleted file mode 100644 index 9720b55cb..000000000 --- a/extensions/akismet/.github/workflows/build.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Build JavaScript assets - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - uses: flarum/action-build@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - diff --git a/extensions/akismet/.github/workflows/frontend.yml b/extensions/akismet/.github/workflows/frontend.yml new file mode 100644 index 000000000..324e3cc9b --- /dev/null +++ b/extensions/akismet/.github/workflows/frontend.yml @@ -0,0 +1,20 @@ +name: Akismet JS + +on: [workflow_dispatch, push, pull_request] + +# The reusable workflow definitions will be moved to the `flarum/framework` repo soon. +# This will break your current script. +# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure. + +jobs: + run: + uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main + with: + enable_bundlewatch: false + enable_prettier: true + enable_typescript: true + + frontend_directory: ./js + main_git_branch: main + secrets: + bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} \ No newline at end of file diff --git a/extensions/akismet/.gitignore b/extensions/akismet/.gitignore index 74b82bae7..4ebb168a0 100644 --- a/extensions/akismet/.gitignore +++ b/extensions/akismet/.gitignore @@ -1,8 +1,12 @@ -.idea /vendor +composer.lock composer.phar + .DS_Store Thumbs.db -node_modules -js/dist/* -composer.lock +tests/.phpunit.result.cache +/tests/integration/tmp +.vagrant +.idea/* +.vscode +js/coverage-ts diff --git a/extensions/akismet/composer.json b/extensions/akismet/composer.json index f32eaf63e..93e202d0c 100644 --- a/extensions/akismet/composer.json +++ b/extensions/akismet/composer.json @@ -41,6 +41,38 @@ "backgroundColor": "#5e8e14", "color": "#fff" } + }, + "flarum-cli": { + "modules": { + "js": true, + "jsCommon": false, + "gitConf": true, + "githubActions": true, + "prettier": true, + "typescript": true, + "bundlewatch": false, + "backendTesting": true, + "editorConfig": true, + "styleci": true + } } + }, + "scripts": { + "test": [ + "@test:unit", + "@test:integration" + ], + "test:unit": "phpunit -c tests/phpunit.unit.xml", + "test:integration": "phpunit -c tests/phpunit.integration.xml", + "test:setup": "@php tests/integration/setup.php" + }, + "scripts-descriptions": { + "test": "Runs all tests.", + "test:unit": "Runs all unit tests.", + "test:integration": "Runs all integration tests.", + "test:setup": "Sets up a database for use with integration tests. Execute this only once." + }, + "require-dev": { + "flarum/testing": "^1.0.0" } } diff --git a/extensions/akismet/js/.gitignore b/extensions/akismet/js/.gitignore new file mode 100644 index 000000000..adc90f312 --- /dev/null +++ b/extensions/akismet/js/.gitignore @@ -0,0 +1,9 @@ +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +node_modules diff --git a/extensions/akismet/js/package.json b/extensions/akismet/js/package.json index 820973b75..a657f5b2c 100644 --- a/extensions/akismet/js/package.json +++ b/extensions/akismet/js/package.json @@ -1,19 +1,29 @@ { - "private": true, - "name": "@flarum/akismet", - "prettier": "@flarum/prettier-config", - "dependencies": { - "flarum-webpack-config": "^1.0.0", - "webpack": "^4.46.0", - "webpack-cli": "^4.9.1" - }, - "scripts": { - "dev": "webpack --mode development --watch", - "build": "webpack --mode production" - }, - "devDependencies": { - "@flarum/prettier-config": "^1.0.0", - "flarum-tsconfig": "^1.0.2", - "prettier": "^2.5.1" - } + "private": true, + "name": "@flarum/akismet", + "prettier": "@flarum/prettier-config", + "dependencies": { + "flarum-webpack-config": "^1.0.0", + "webpack": "^4.46.0", + "webpack-cli": "^4.9.1" + }, + "scripts": { + "dev": "webpack --mode development --watch", + "build": "webpack --mode production", + "analyze": "cross-env ANALYZER=true yarn build", + "format": "prettier --write src", + "format-check": "prettier --check src", + "check-typings": "tsc --noEmit --emitDeclarationOnly false", + "check-typings-coverage": "typescript-coverage-report" + }, + "devDependencies": { + "@flarum/prettier-config": "^1.0.0", + "flarum-tsconfig": "^1.0.2", + "prettier": "^2.5.1", + "flarum-webpack-config": "^2.0.0", + "webpack": "^5.65.0", + "webpack-cli": "^4.9.1", + "typescript": "^4.5.4", + "typescript-coverage-report": "^0.6.1" + } } diff --git a/extensions/akismet/js/tsconfig.json b/extensions/akismet/js/tsconfig.json index ece4be0ee..ee0d5ef5a 100644 --- a/extensions/akismet/js/tsconfig.json +++ b/extensions/akismet/js/tsconfig.json @@ -1,7 +1,12 @@ { + // Use Flarum's tsconfig as a starting point "extends": "flarum-tsconfig", - "include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"], + // This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder + // and also tells your Typescript server to read core's global typings for + // access to `dayjs` and `$` in the global namespace. + "include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*", "@types/**/*"], "compilerOptions": { + // This will output typings to `dist-typings` "declarationDir": "./dist-typings", "baseUrl": ".", "paths": { diff --git a/extensions/akismet/js/webpack.config.js b/extensions/akismet/js/webpack.config.js index fcfa77c92..ef35ea006 100644 --- a/extensions/akismet/js/webpack.config.js +++ b/extensions/akismet/js/webpack.config.js @@ -1,3 +1 @@ -const config = require('flarum-webpack-config'); - -module.exports = config(); +module.exports = require('flarum-webpack-config')(); diff --git a/extensions/akismet/node_modules/.yarn-integrity b/extensions/akismet/node_modules/.yarn-integrity new file mode 100644 index 000000000..ecb00839f --- /dev/null +++ b/extensions/akismet/node_modules/.yarn-integrity @@ -0,0 +1,13 @@ +{ + "systemParams": "linux-x64-93", + "modulesFolders": [], + "flags": [], + "linkedModules": [ + "flarum-webpack-config", + "mem-fs" + ], + "topLevelPatterns": [], + "lockfileEntries": {}, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/extensions/akismet/tests/fixtures/.gitkeep b/extensions/akismet/tests/fixtures/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/extensions/akismet/tests/integration/setup.php b/extensions/akismet/tests/integration/setup.php new file mode 100644 index 000000000..67039c083 --- /dev/null +++ b/extensions/akismet/tests/integration/setup.php @@ -0,0 +1,16 @@ +run(); diff --git a/extensions/akismet/tests/phpunit.integration.xml b/extensions/akismet/tests/phpunit.integration.xml new file mode 100644 index 000000000..23afc237d --- /dev/null +++ b/extensions/akismet/tests/phpunit.integration.xml @@ -0,0 +1,24 @@ + + + + + ../src/ + + + + + ./integration + + + diff --git a/extensions/akismet/tests/phpunit.unit.xml b/extensions/akismet/tests/phpunit.unit.xml new file mode 100644 index 000000000..d3a4a3e3d --- /dev/null +++ b/extensions/akismet/tests/phpunit.unit.xml @@ -0,0 +1,27 @@ + + + + + ../src/ + + + + + ./unit + + + + + + diff --git a/extensions/akismet/tests/unit/.gitkeep b/extensions/akismet/tests/unit/.gitkeep new file mode 100644 index 000000000..e69de29bb