From 11d0cbbd9915695fa391a711b83bb73deb5ccc06 Mon Sep 17 00:00:00 2001 From: Julian Scheuchenzuber Date: Thu, 14 Sep 2023 11:42:36 +0200 Subject: [PATCH] Initial commit --- .editorconfig | 20 +++++ .eslintrc.js | 1 + .gitattributes | 5 ++ .github/workflows/README.md | 9 ++ .github/workflows/ci.yml | 11 +++ .gitignore | 7 ++ .nvmrc | 1 + CONTRIBUTING.md | 15 ++++ LICENSE.md | 12 +++ README.md | 88 +++++++++++++++++++ _config.php | 4 + _config/config.yml | 1 + client/dist/js/bundle.js | 1 + client/dist/styles/bundle.css | 1 + client/src/boot/README.md | 7 ++ client/src/boot/index.js | 6 ++ client/src/boot/registerComponents.js | 9 ++ client/src/bundles/README.md | 7 ++ client/src/bundles/bundle.js | 5 ++ .../ExampleComponent/ExampleComponent.js | 7 ++ .../ExampleComponent/ExampleComponent.scss | 3 + .../tests/ExampleComponent-test.js | 12 +++ client/src/components/README.md | 7 ++ client/src/entwine/README.md | 8 ++ client/src/entwine/example-file.js | 8 ++ client/src/styles/README.md | 5 ++ client/src/styles/admin/pages/_pages.scss | 1 + client/src/styles/bundle.scss | 8 ++ composer.json | 31 +++++++ docs/en/README.md | 8 ++ package.json | 66 ++++++++++++++ phpcs.xml.dist | 13 +++ phpunit.xml.dist | 8 ++ src/readme.md | 5 ++ templates/README.md | 7 ++ tests/README.md | 5 ++ tests/endtoend/README.md | 5 ++ tests/php/README.md | 5 ++ webpack.config.js | 27 ++++++ 39 files changed, 449 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintrc.js create mode 100644 .gitattributes create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .nvmrc create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 _config.php create mode 100644 _config/config.yml create mode 100644 client/dist/js/bundle.js create mode 100644 client/dist/styles/bundle.css create mode 100644 client/src/boot/README.md create mode 100644 client/src/boot/index.js create mode 100644 client/src/boot/registerComponents.js create mode 100644 client/src/bundles/README.md create mode 100644 client/src/bundles/bundle.js create mode 100644 client/src/components/ExampleComponent/ExampleComponent.js create mode 100644 client/src/components/ExampleComponent/ExampleComponent.scss create mode 100644 client/src/components/ExampleComponent/tests/ExampleComponent-test.js create mode 100644 client/src/components/README.md create mode 100644 client/src/entwine/README.md create mode 100644 client/src/entwine/example-file.js create mode 100644 client/src/styles/README.md create mode 100644 client/src/styles/admin/pages/_pages.scss create mode 100644 client/src/styles/bundle.scss create mode 100644 composer.json create mode 100644 docs/en/README.md create mode 100644 package.json create mode 100644 phpcs.xml.dist create mode 100644 phpunit.xml.dist create mode 100644 src/readme.md create mode 100644 templates/README.md create mode 100644 tests/README.md create mode 100644 tests/endtoend/README.md create mode 100644 tests/php/README.md create mode 100644 webpack.config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..720cbaf --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# For more information about the properties used in this file, +# please see the EditorConfig documentation: +# https://editorconfig.org/ + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,js,json,css,scss}] +indent_size = 2 + +[composer.json] +indent_size = 4 diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..4b81cff --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@silverstripe/eslint-config/.eslintrc'); diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4718dc9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +/tests export-ignore +/client/src export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.github export-ignore diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..f02d8a9 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,9 @@ +# CI + +The `ci.yml` file uses [`silverstripe/gha-ci`](https://github.com/silverstripe/gha-ci/) which does its best to identify which types of tests need to be run for your project, against which version of `silverstripe/installer`, with which PHP versions. + +If you find it isn't quite getting it right, there are configuration options available for you to define exactly what jobs you want to be run. See the readme of the gha-ci repository for more information. + +It is recommended that you make this run on a cron, referred to in GitHub Actions as a "schedule". See [the GitHub Actions documentation](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule) for details. + +Make sure to remove this readme in your actual module! diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bf02210 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,11 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + ci: + name: CI + uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f51392 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +node_modules/ +/vendor/ +.DS_Store +composer.lock +*.js.map +*.css.map +yarn-error.log diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..3c03207 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b576a73 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +- Maintenance on this module is a shared effort of those who use it +- To contribute improvements to the code, ensure you raise a pull request and discuss with the module maintainers +- Please follow the Silverstripe CMS [code contribution guidelines](https://docs.silverstripe.org/en/contributing/code/) and [Module Standard](https://docs.silverstripe.org/en/developer_guides/extending/modules/#module-standard) +- Supply documentation that follows the [GitHub Flavored Markdown](https://help.github.com/articles/markdown-basics/) conventions +- When having discussions about this module in issues or pull request please adhere to the [Silverstripe CMS Community Code of Conduct](https://docs.silverstripe.org/en/project_governance/code_of_conduct/) + +## Contributor license agreement + +By supplying code to this module in patches, tickets and pull requests, you agree to assign copyright +of that code to MODULE_COPYRIGHT_HOLDER_HERE., on the condition that these code changes are released under the +same BSD license as the original module. We ask for this so that the ownership in the license is clear +and unambiguous. By releasing this code under a permissive license such as BSD, this copyright assignment +won't prevent you from using the code in any way you see fit. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..1886837 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,12 @@ +Copyright (c) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..13e0b8d --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# Silverstripe CMS supported module skeleton + +A useful skeleton to more easily create a [Silverstripe CMS Module](https://docs.silverstripe.org/en/developer_guides/extending/modules/) that conform to the +[Module Standard](https://docs.silverstripe.org/en/developer_guides/extending/modules/#module-standard). + +This README contains descriptions of the parts of this module base you should customise to meet you own module needs. +For example, the module name in the H1 above should be you own module name, and the description text you are reading now +is where you should provide a good short explanation of what your module does. + +Where possible we have included default text that can be included as is into your module and indicated in +other places where you need to customise it + +Below is a template of the sections of your `README.md` you should ideally include to met the Module Standard +and help others make use of your modules. + +## Steps to prepare this module for your own use + +Ensure you read the +['publishing a module'](https://docs.silverstripe.org/en/developer_guides/extending/how_tos/publish_a_module/) guide +and update your module's `composer.json` to designate your code as a Silversripe CMS module. + +- Clone this repository into a folder +- Add your name/organisation to `LICENSE.md` +- Update this README with information about your module. Ensure sections that aren't relevant are deleted and +placeholders are edited where relevant +- Review the README files in the various provided directories. You should ultimately delete these README files when you have added your code +- Update the module's `composer.json` with your requirements and package name +- Update (or remove) `package.json` with your requirements and package name. Run `yarn install` (or remove `yarn.lock`) to +ensure dependencies resolve correctly +- Clear the git history by running `rm -rf .git && git init` +- Add and push to a VCS repository +- Either [publish](https://getcomposer.org/doc/02-libraries.md#publishing-to-packagist) the module on packagist.org, or add a [custom repository](https://getcomposer.org/doc/02-libraries.md#publishing-to-a-vcs) to your main `composer.json` +- Require the module in your main `composer.json` +- If you need to build your css or js and are using components, injector, scss variables, etc from `silverstripe/admin`: + - Ensure that `silverstripe/admin` is installed with `composer install --prefer-source` instead of the default `--prefer-dist` (you can use `composer reinstall silverstripe/admin --prefer-source` if you already installed it) + - If you are relying on additional dependencies from `silverstripe/admin` instead of adding them as dependencies in your `package.json` file, you need to install third party dependencies in `silverstripe/admin` by running `yarn install` in the `vendor/silverstripe/admin/` directory. +- Start developing your module! + +## License + +See [License](LICENSE.md) + +This module template defaults to using the "BSD-3-Clause" license. The BSD-3 license is one of the most +permissive open-source license and is used by most Silverstripe CMS module. + +To publish your module under a different license: + +- update the [`license.md`](LICENSE.md) file +- update the `license' key in your [`composer.json`](composer.json). + +You can use [choosealicense.com](https://choosealicense.com) to help you pick a suitable license for your project. + +You do not need to keep this section in your README file - the `LICENSE.md` file is sufficient. + +## Installation + +Replace `silverstripe-module/skeleton` in the command below with the composer name of your module. + +```sh +composer require silverstripe-module/skeleton +``` + +**Note:** When you have completed your module, submit it to Packagist or add it as a VCS repository to your +project's composer.json, pointing to the private repository URL. + +## Documentation + +- [Documentation readme](docs/en/README.md) + +Add links into your `docs/` folder here unless your module only requires minimal documentation +in that case, add here and remove the docs folder. You might use this as a quick table of content if you +mhave multiple documentation pages. + +## Example configuration + +If your module makes use of the config API in Silverstripe CMS it's a good idea to provide an example config +here that will get the module working out of the box and expose the user to the possible configuration options. +Though note that in many cases simply linking to the documentation is enough. + +Provide a syntax-highlighted code examples where possible. + +```yaml +Page: + config_option: true + another_config: + - item1 + - item2 +``` diff --git a/_config.php b/_config.php new file mode 100644 index 0000000..4293057 --- /dev/null +++ b/_config.php @@ -0,0 +1,4 @@ +{(0,u.default)()}))},521:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=a(n(648)),u=a(n(64));function a(e){return e&&e.__esModule?e:{default:e}}t.default=()=>{o.default.component.registerMany({ExampleComponent:u.default})}},64:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o,u=(o=n(363))&&o.__esModule?o:{default:o};var a=()=>u.default.createElement("div",{className:"example-component"},"This is an example");t.default=a},708:function(e,t,n){var o=n(311);o(document).ready((()=>{}))},648:function(e){e.exports=Injector},363:function(e){e.exports=React},311:function(e){e.exports=jQuery}},t={};function n(o){var u=t[o];if(void 0!==u)return u.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,n),a.exports}n(708),n(274)}(); \ No newline at end of file diff --git a/client/dist/styles/bundle.css b/client/dist/styles/bundle.css new file mode 100644 index 0000000..8f2da17 --- /dev/null +++ b/client/dist/styles/bundle.css @@ -0,0 +1 @@ +.example-component{display:block} diff --git a/client/src/boot/README.md b/client/src/boot/README.md new file mode 100644 index 0000000..ffe0f6e --- /dev/null +++ b/client/src/boot/README.md @@ -0,0 +1,7 @@ +# JavaScript bundle entrypoint + +Put your initialisation scripts in here. + +See the [Silverstripe CMS javascript documentation](https://docs.silverstripe.org/en/developer_guides/customising_the_admin_interface/javascript_development/) + +Make sure to remove this readme in your actual module! diff --git a/client/src/boot/index.js b/client/src/boot/index.js new file mode 100644 index 0000000..7235c99 --- /dev/null +++ b/client/src/boot/index.js @@ -0,0 +1,6 @@ +/* global window */ +import registerComponents from 'boot/registerComponents'; + +window.document.addEventListener('DOMContentLoaded', () => { + registerComponents(); +}); diff --git a/client/src/boot/registerComponents.js b/client/src/boot/registerComponents.js new file mode 100644 index 0000000..0ac4e4d --- /dev/null +++ b/client/src/boot/registerComponents.js @@ -0,0 +1,9 @@ +import Injector from 'lib/Injector'; +import ExampleComponent from 'components/ExampleComponent/ExampleComponent'; + +export default () => { + Injector.component.registerMany({ + // List your React components here so Injector is aware of them + ExampleComponent + }); +}; diff --git a/client/src/bundles/README.md b/client/src/bundles/README.md new file mode 100644 index 0000000..68f9ea2 --- /dev/null +++ b/client/src/bundles/README.md @@ -0,0 +1,7 @@ +# JavaScript bundles + +Put your bundle.js file here, pointing to your boot files and legacy scripts. + +See the [Silverstripe CMS javascript documentation](https://docs.silverstripe.org/en/developer_guides/customising_the_admin_interface/javascript_development/) + +Make sure to remove this readme in your actual module! diff --git a/client/src/bundles/bundle.js b/client/src/bundles/bundle.js new file mode 100644 index 0000000..7802ae4 --- /dev/null +++ b/client/src/bundles/bundle.js @@ -0,0 +1,5 @@ +// Include any legacy Entwine wrappers +import 'entwine/example-file'; + +// Include boot entrypoint +import 'boot'; diff --git a/client/src/components/ExampleComponent/ExampleComponent.js b/client/src/components/ExampleComponent/ExampleComponent.js new file mode 100644 index 0000000..a9661ed --- /dev/null +++ b/client/src/components/ExampleComponent/ExampleComponent.js @@ -0,0 +1,7 @@ +import React from 'react'; + +const ExampleComponent = () => ( +
This is an example
+); + +export default ExampleComponent; diff --git a/client/src/components/ExampleComponent/ExampleComponent.scss b/client/src/components/ExampleComponent/ExampleComponent.scss new file mode 100644 index 0000000..f2a5156 --- /dev/null +++ b/client/src/components/ExampleComponent/ExampleComponent.scss @@ -0,0 +1,3 @@ +.example-component { + display: block; +} diff --git a/client/src/components/ExampleComponent/tests/ExampleComponent-test.js b/client/src/components/ExampleComponent/tests/ExampleComponent-test.js new file mode 100644 index 0000000..1e061db --- /dev/null +++ b/client/src/components/ExampleComponent/tests/ExampleComponent-test.js @@ -0,0 +1,12 @@ + +/* global jest, test, expect */ + +import React from 'react'; +import ExampleComponent from '../ExampleComponent'; +import { render } from '@testing-library/react'; + +test('ExampleComponent renders', async () => { + const { container } = render(); + const options = container.querySelectorAll('.example-component'); + expect(options).toHaveLength(1); +}); diff --git a/client/src/components/README.md b/client/src/components/README.md new file mode 100644 index 0000000..d1477c0 --- /dev/null +++ b/client/src/components/README.md @@ -0,0 +1,7 @@ +# React components + +Put any React components in here. + +See the [Silverstripe CMS react documentation](https://docs.silverstripe.org/en/developer_guides/customising_the_admin_interface/reactjs_redux_and_graphql/) + +Make sure to remove this readme in your actual module! diff --git a/client/src/entwine/README.md b/client/src/entwine/README.md new file mode 100644 index 0000000..9a6c530 --- /dev/null +++ b/client/src/entwine/README.md @@ -0,0 +1,8 @@ +# Entwine wrappers + +Put any Entwine wrappers in here to render React components in non-React controlled areas, or +to interact with parts of the Silverstripe CMS that are not React driven yet. + +See the [Silverstripe CMS enwtine documentation](https://docs.silverstripe.org/en/developer_guides/customising_the_admin_interface/jquery_entwine/) + +Make sure to remove this readme in your actual module! diff --git a/client/src/entwine/example-file.js b/client/src/entwine/example-file.js new file mode 100644 index 0000000..6668e6b --- /dev/null +++ b/client/src/entwine/example-file.js @@ -0,0 +1,8 @@ + +/* global jQuery */ + +(function ($) { + $(document).ready(() => { + // your code here. + }); +}(jQuery)); diff --git a/client/src/styles/README.md b/client/src/styles/README.md new file mode 100644 index 0000000..94d93cc --- /dev/null +++ b/client/src/styles/README.md @@ -0,0 +1,5 @@ +# SCSS bundles + +Put your SCSS bundle files here, importing variable sheets and each of the SCSS stylesheets. + +Make sure to remove this readme in your actual module! diff --git a/client/src/styles/admin/pages/_pages.scss b/client/src/styles/admin/pages/_pages.scss new file mode 100644 index 0000000..f65e978 --- /dev/null +++ b/client/src/styles/admin/pages/_pages.scss @@ -0,0 +1 @@ +// There would be some css changes relevant to something in the CMS pages admin diff --git a/client/src/styles/bundle.scss b/client/src/styles/bundle.scss new file mode 100644 index 0000000..5d59feb --- /dev/null +++ b/client/src/styles/bundle.scss @@ -0,0 +1,8 @@ +// Import core variables from silverstripe/admin +@import 'variables'; + +// Import your SCSS stylesheets using relative paths from "components" +@import '../components/ExampleComponent/ExampleComponent.scss'; + +// Import other legacy SCSS stylesheets that don't relate to react components +@import 'admin/pages/pages'; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..6abd10a --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "name": "silverstripe-module/skeleton", + "description": "A skeleton for Silverstripe CMS modules.", + "type": "silverstripe-vendormodule", + "keywords": [ + "silverstripe", + "CMS" + ], + "license": "BSD-3-Clause", + "require": { + "silverstripe/framework": "^5.0", + "silverstripe/admin": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.7" + }, + "autoload": { + "psr-4": { + "SilverStripeModule\\Skeleton\\": "src/", + "SilverStripeModule\\Skeleton\\Tests\\": "tests/php/" + } + }, + "extra": { + "expose": [ + "client/dist" + ] + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/docs/en/README.md b/docs/en/README.md new file mode 100644 index 0000000..0f14222 --- /dev/null +++ b/docs/en/README.md @@ -0,0 +1,8 @@ +# Documentation + +Add your documentation in the `docs/en/` folder as markdown. Note the "en/" part of the path refers to the language (English in this case) used in the documentation you provide. +If your documentation is vast, you can split it into many markdown files and sub folders. + +Look over the [guidance on documentation](https://docs.silverstripe.org/en/contributing/documentation/) + +Make sure to remove this readme in your actual module! diff --git a/package.json b/package.json new file mode 100644 index 0000000..d207927 --- /dev/null +++ b/package.json @@ -0,0 +1,66 @@ +{ + "name": "silverstripe-module-skeleton", + "engines": { + "node": ">=18.x" + }, + "scripts": { + "build": "yarn && yarn lint && yarn test && rm -rf client/dist/* && NODE_ENV=production webpack --mode production --bail --progress", + "dev": "NODE_ENV=development webpack --progress", + "watch": "NODE_ENV=development webpack --watch --progress", + "css": "WEBPACK_CHILD=css npm run build", + "test": "jest", + "coverage": "jest --coverage", + "lint": "yarn lint-js && yarn lint-sass", + "lint-js": "eslint client/src", + "lint-js-fix": "eslint client/src --fix", + "lint-sass": "sass-lint client/src" + }, + "dependencies": { + "core-js": "^3.26.0", + "react": "^18.2.0" + }, + "devDependencies": { + "@babel/runtime": "^7.20.0", + "@silverstripe/eslint-config": "^1.0.0", + "@silverstripe/webpack-config": "^2.0.0", + "@testing-library/react": "^14.0.0", + "eslint": "^8.0.0", + "eslint-plugin-react-hooks": "^4.3.0", + "jest-cli": "^29.2.2", + "jest-environment-jsdom": "^29.3.1", + "react-dom": "^18.0.0", + "webpack": "^5.74.0", + "webpack-cli": "^5.0.0" + }, + "browserslist": [ + "defaults" + ], + "jest": { + "testEnvironment": "jsdom", + "roots": [ + "client/src" + ], + "moduleDirectories": [ + "client/src", + "node_modules", + "../admin/client/src", + "../admin/node_modules", + "../silverstripe/admin/client/src", + "../silverstripe/admin/node_modules", + "../../silverstripe/admin/client/src", + "../../silverstripe/admin/node_modules" + ], + "testMatch": [ + "**/tests/**/*-test.js?(x)" + ], + "transform": { + ".*": "babel-jest" + } + }, + "babel": { + "presets": [ + "@babel/preset-env", + "@babel/preset-react" + ] + } +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..488aba4 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,13 @@ + + + CodeSniffer ruleset for Silverstripe coding conventions. + + src + tests + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..3801dc3 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + tests/php + + + diff --git a/src/readme.md b/src/readme.md new file mode 100644 index 0000000..1d016c4 --- /dev/null +++ b/src/readme.md @@ -0,0 +1,5 @@ +# Code + +Look over the [Developer Docs](https://docs.silverstripe.org) + +Make sure to remove this readme in your actual module! diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 0000000..f4aa8fc --- /dev/null +++ b/templates/README.md @@ -0,0 +1,7 @@ +# Templates + +Any templates your module uses should be put in here. + +See the [templates and views documentation](https://docs.silverstripe.org/en/developer_guides/templates/) + +Make sure to remove this readme in your actual module! diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..e0e6f88 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,5 @@ +# Tests + +Look over the [testing documentation](https://docs.silverstripe.org/en/developer_guides/testing/) + +Make sure to remove this readme in your actual module! diff --git a/tests/endtoend/README.md b/tests/endtoend/README.md new file mode 100644 index 0000000..8e25944 --- /dev/null +++ b/tests/endtoend/README.md @@ -0,0 +1,5 @@ +# End-to-end tests + +The supported modules use behat for end-to-end testing, but other options such as Cypress also work well. + +Make sure to remove this readme in your actual module! diff --git a/tests/php/README.md b/tests/php/README.md new file mode 100644 index 0000000..946fcba --- /dev/null +++ b/tests/php/README.md @@ -0,0 +1,5 @@ +# Unit and functional tests + +Look over the [unit testing](https://docs.silverstripe.org/en/developer_guides/testing/unit_testing/) and [functional testing](https://docs.silverstripe.org/en/developer_guides/testing/functional_testing/) documentation. + +Make sure to remove this readme in your actual module! diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..36f6a71 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,27 @@ +const Path = require('path'); +const { JavascriptWebpackConfig, CssWebpackConfig } = require('@silverstripe/webpack-config'); + +const PATHS = { + ROOT: Path.resolve(), + SRC: Path.resolve('client/src'), +}; + +const config = [ + // main JS bundle + new JavascriptWebpackConfig('js', PATHS) + .setEntry({ + bundle: `${PATHS.SRC}/bundles/bundle.js`, + }) + .getConfig(), + // sass to css + new CssWebpackConfig('css', PATHS) + .setEntry({ + bundle: `${PATHS.SRC}/styles/bundle.scss`, + }) + .getConfig(), +]; + +// Use WEBPACK_CHILD=js or WEBPACK_CHILD=css env var to run a single config +module.exports = (process.env.WEBPACK_CHILD) + ? config.find((entry) => entry.name === process.env.WEBPACK_CHILD) + : config;