Commit Graph

17036 Commits

Author SHA1 Message Date
Ingo Schommer
f9581438b5 Merge pull request #6016 from sminnee/travis-lint
NEW: Run JS/CSS linting in Travis.
2016-09-18 16:27:00 +12:00
Ingo Schommer
a0c0a4ae4f Updated docs with sass-lint references 2016-09-18 16:25:16 +12:00
Ingo Schommer
96892636c7 Removed CodeClimate badge 2016-09-18 16:25:08 +12:00
Ingo Schommer
8217109890 Added sass-lint to shrinkwrap file 2016-09-18 16:25:01 +12:00
Sam Minnee
b19475d748 NEW: Ignore npm-shrinkwrap for greenskeeper-provided PRs. 2016-09-18 14:52:00 +12:00
Sam Minnee
b61c5a56de FIX: sass-lint styleguide fixes 2016-09-18 14:50:27 +12:00
Sam Minnee
c2ebff5c19 NEW: Use sass-lint over scss-lint
SCSS linting now uses the node-based sass-lint tool, since we’re
shifting away from CodeClimate.

This has the benefit of not requiring a ruby gem on dev tools -
everything is provided as npm dev dependencies.

This was also necessary to run the linting inside travis.
2016-09-18 14:50:27 +12:00
Sam Minnee
f700d86557 NEW: Run JS/CSS linting in Travis.
The ‘npm run lint’ command will be used to run listing on Travis, which
can also be used on local dev environments. These can also be used with
editor plugins to highlight errors immediately.

The intention is that this can be used in place of codeclimate. The
benefits are that we use a single toolchain in both CI and local dev,
which is not entirely the case at the moment.

Note the sass-lint is provided by “sudo gem install scss_lint”. It’s
possible that we can move to a node-based sass-lint; I can’t recall
what the motivation for using the scss_lint gem was - I think it was
mainly that we had the AirBNB styleguide already implemented as a linter
config.
2016-09-18 14:49:08 +12:00
Daniel Hensby
6f28ac5365 Merge pull request #5986 from sminnee/simpler-test-run
Simpler test run
2016-09-17 08:10:46 +01:00
Sam Minnee
07396e4437 NEW: Move Travis behat test to run locally.
This shifts the behat test run to be triggered form composer activity
within the framework module directly,

 * silverstripe/serve is used to provide a webserver, based on the
   php -S command
 * se/selenium-server-standalone is used to install selenium rather than
   a download command

Because we’re using serve, the behat configuration can be locked down.

Further refinements could be made on this:

 * the behat-extension could be responsible for installing and
   starting/stopping selenium, making these tests more portable
 * xvfb initialisation could be provided with another bin tool in the
   begat-extension: vendor/bin/xvfb 1024x768
 * The bootstrap-file argument to serve could be provided as part of a
   composer.json setting. This would make it easier for developers to
   start a dev server simply by running vendor/bin/serve
 * the behat-extension could be responsible for installing and
   starting/stopping silverstripe/serve, removing the need for
   specifying base_url at all, and possibly utilising the same bootstrap
   file between serve and behat.
2016-09-17 15:40:37 +12:00
Sam Minnee
96126323d2 NEW: themedCSS() and themedJavascript() work with any file layout.
themedCSS() and themedJavascript() files have previously been hardcoded
to reside in the css/ or javascript/ folder directly beneath the theme
path.

This short-cut still works, but you can also specify the theme-relative
path in its entirely, giving you more flexibility about your resource
layout.
2016-09-17 15:40:37 +12:00
Sam Minnee
61d7c3af28 FIX: Fix tests when running directly from framework. 2016-09-17 15:40:32 +12:00
Daniel Hensby
c8fdc7b180
Merge branch '3' 2016-09-16 14:31:10 +01:00
Daniel Hensby
cb2352548d
Merge branch '3.4' into 3 2016-09-16 14:22:31 +01:00
Daniel Hensby
71cc5d83e6
Revert "Merge remote-tracking branch '3Dgoo/patch-1' into 3.4"
This reverts commit e617042422, reversing
changes made to 995d07756d.
2016-09-16 14:21:16 +01:00
Daniel Hensby
f65168ef8d
Merge branch '3' 2016-09-16 13:43:23 +01:00
Daniel Hensby
beeed8155a
Merge branch '3.4' into 3 2016-09-16 11:56:01 +01:00
Daniel Hensby
e617042422
Merge remote-tracking branch '3Dgoo/patch-1' into 3.4 2016-09-16 11:50:24 +01:00
Dmitry Kudryavtsev
78276e5397 corrupt YML in italian translation (#5997) 2016-09-16 17:25:02 +12:00
Sam Minnee
9dd5ebee8c NEW: Don’t set up SilverStripe project for test run
The SilverStripe project structure complicates the travis test run, and
the goal of this branch is to prevent it from being necessary.

 - Unit tests can be run simply with PHPUnit.
 - Behat test can be run with the silverstripe/serve module

Note that initially this commit doesn’t cater to the behat tests.

As part of this, we allow dev packages to be installed when testing

These settings don’t affect projects that use framework, only when
framework’s composer install / require calls are used themselves.

Since SS4 is pre-stable, these are important. They can probably be
removed once SS4 stable (and stable versions of support packages) have
been released.
2016-09-16 16:16:44 +12:00
Sam Minnee
6b640f81f2 FIX: Don’t double-include composer autoloader
If another file is include main.php and has included composer already,
code might get weird. In particular, if the parent context includes a
different vendor/autoload.php than the one main.php expects.
2016-09-16 16:16:43 +12:00
Sam Minnee
93a0122c0f FIX: Don’t treat URLs as root relative when FRAMEWORK_DIR = “”
Code was assuming that FRAMEWORK_DIR would always have a value. If it
doesn’t (because you’re running a test instance of a naked framework)
This caused URLs to be treated as root relative, which creates some
duplicate-inclusion bugs.

The use of ltrim() works, but is a bit clumsy. A more flexible approach
to including front-end assets of given modules would be preferable;
ideally something that also let you keep your code outside of the
web root.
2016-09-16 16:16:39 +12:00
Sam Minnee
cebcf7fb8c NEW: More flexible theme resolution for framework and cms.
using ‘silverstripe/framework’ or ‘silverstripe/cms’ will resolve the
right path even if these folders are in the project root.

‘vendor/module:/sub/path’ theme references are also supported so that
the admin sub-theme can be accessed.
2016-09-16 14:36:08 +12:00
Sam Minnee
6b847d3614 NEW: Allow project root to be treated as a module.
If the _config folder exists as a top-level directory, treat the project
root as a module too. This is useful, e.g. when initialisation a
SilverStripe environment within a module.

This is only a first cut. Modules in the vendor directory are excluded.
Most likely, we will need to search the vendor folder for modules with
type = silverstripe-module in their composer.json.
2016-09-16 14:36:08 +12:00
Sam Minnee
ab7e5944d1 API: Derive BASE_PATH from composer autoloader
The location of composer’s vendor/autoload_real.php file is a good
indicator of the root of a project, and can be used to derive a
BASE_PATH

This gives us more flexibility about where the framework module is
installed relative to a project root. It also lets us use the framework
module as a project root, e.g. in test runs.

THIRDPARTY_PATH and ADMIN_PATH are calculated relative to this, and
the FRAMEWORK_DIR, THIRDPARTY_DIR, and ADMIN_DIR are relative to the
BASE_PATH.
2016-09-16 14:36:08 +12:00
Sam Minnée
a1c9de3c91 Merge pull request #5918 from sminnee/webpack
Replace browserify/gulp with Webpack
2016-09-16 14:31:17 +12:00
Ingo Schommer
3d7c60f8cb Updated dist files 2016-09-16 13:46:11 +12:00
Ingo Schommer
556667c4ea Removed unused "npm run sanity"
We're no longer copying JS sources around,
hence there's no need for this task.
2016-09-16 13:46:11 +12:00
Ingo Schommer
30174db459 FIx i18n JS regression about locale selection
When rewriting the i18n.js file from ES5 to ES6, the detectLocale()
call in the constructor was missed - meaning the lang files were loaded by the browser,
but never actually used.
2016-09-16 13:46:11 +12:00
Ingo Schommer
8f23fa99a5 API Moved CMS-specific JavaScript to admin/thirdparty
The 'admin' module will be split off from 'framework',
where 'framework' only provides (mostly) frontend-agnostic PHP classes.
For example, HTMLEditorField.php has a TinyMCEConfig.php driver,
but doesn't come with its own JS includes.
2016-09-16 13:46:10 +12:00
Ingo Schommer
7d67b24c25 API Removed legacy Jasmine JS Unit tests
They were used for TreeDropdownField JavaScript tests but were never run
on CI, hence have been a bit of a wasted effort.

We're using a different JS unit testing solution now (geared towards React),
and running Jasmine in parallel on Travis for a few test cases
doesn't warrant the setup effort involved.

The TreeDropdownField component will eventually move to a React solution
which can be developed in a test-driven fashion.
2016-09-16 13:46:10 +12:00
Ingo Schommer
686c167793 Removed TinyMCE NPM dep
We don't have an easy way to copy over those files automatically into the thirdparty/ dir,
where they are accessible on the webroot (not the case in node_modules).

To avoid confusion, we don't duplicate into node_modules for now.
See https://github.com/silverstripe/silverstripe-framework/pull/5918#issuecomment-244910280
2016-09-16 13:46:10 +12:00
Ingo Schommer
8eac22c628 Separate CSS bundling in Webpack
Multiple entry points can't result in a single bundle.css with a fixed filename, see
https://github.com/webpack/extract-text-webpack-plugin/issues/179

Until that's resolved, it's easier to keep the 'css' task separate in Webpack,
and have a single entry point for all CSS (bundle.scss).

Also partially reverting "Moved frontend assets into admin/ "module"",
which moved too many files: debug.css and install.css need to remain
as framework (not admin) deps. Split out into a separate `framework-css` Webpack
task in preparation for splitting off the module.
2016-09-16 13:46:09 +12:00
Ingo Schommer
8e5dd58c43 Removed unused dist files
Storing in fonts/, not font/fonts
2016-09-16 13:46:09 +12:00
Damian Mooyman
abaebbe1d7 FIX Manually fix issue in jquery-ui 1.9 2016-09-16 13:46:09 +12:00
Ingo Schommer
2316b0da9f API Remove i18n::js_i18n option
The JavaScript i18n functionality in SilverStripe is used in the CMS as well as form field implementations.
Form fields used to include their own JavaScript for usage outside of CMS. This now requires custom build tooling in a project.
Hence there's no need for an i18n shim (i18nx.js), since the CMS always uses i18n support.
2016-09-16 13:46:09 +12:00
Ingo Schommer
ee10dbb680 API Moved frontend assets into admin/ "module"
We've removed the ability to directly reference JS and CSS files
for form fields and other SilverStripe features in favour of a common bundle built by Webpack.

The logical next step is to make the framework module free of frontend dependencies,
which should simplify its operation, and avoid another time intensive "npm install" on a module.
2016-09-16 13:46:06 +12:00
Damian Mooyman
e5df794a04 Move incorrect lang file location 2016-09-16 13:44:15 +12:00
Ingo Schommer
6be25f3b52 Entry point for UploadField_select.js
Used in iframe, so can't be rolled into other code.
Moved in admin/ since that's easier for now with Webpack entry points,
and we'll move all JS/CSS into admin/ anyway soon.
2016-09-16 13:44:14 +12:00
Ingo Schommer
25f4741142 Removed ModelAdmin/SecurityAdmin Webpack entry points
There's not a lot of benefit in packaging these separately in terms of initial CMS load size,
so let's simplify the setup. They'll eventually become lazy loaded chunks in a React-based setup
2016-09-16 13:44:12 +12:00
Damian Mooyman
b87c668bf4 API support dblib (#5996) 2016-09-16 11:39:29 +12:00
Thomas Portelange
995d07756d cache currentUser query (#6007)
* cache currentUser query

Various modules can call a lot of time Member::currentUser(). We can avoid querying the database multiple times. Cache is implemented as a static array inside the method and store the data byID, in case the currentUserID changes within the same request (not very likely, but..)
2016-09-15 15:45:40 +01:00
Ingo Schommer
701c700d4c Fixed UploadField JS dependencies
When adding the deps straight into the file (recommended),
the onchange handler in file-upload isn't firing properly when a file is uploaded through
the <input type=file> button - it falls back to default behaviour, which submits the
containing form, failing because the upload is handled by a different URL.
2016-09-15 22:19:15 +12:00
Ingo Schommer
25b511f3d5 Build React in production mode by default
https://facebook.github.io/react/downloads.html says:
"By default, React will be in development mode. To use React in production mode, set the environment variable NODE_ENV to production (using envify or webpack's DefinePlugin). A minifier that performs dead-code elimination such as UglifyJS is recommended to completely remove the extra code present in development mode."
2016-09-15 22:19:15 +12:00
Ingo Schommer
9cb9a05ec0 API Removed duplicated thirdparty deps
These were originally copied from node_modules via an "npm run thirdparty" task,
in order to have them loadable with oldschool <script> tags.
Since webpack supports CommonJS-style loading, that's no longer required,
we can simply inline those scripts into the bundle.

We need to use imports-loader though, in order to ensure
that "define" is not available in some module scopes,
which triggers AMD behavior that's not compatible with Webpack's loaders.
See http://webpack.github.io/docs/shimming-modules.html

I've had to pin to the exact versions used in the 3.x CMS,
since jquery-upload has introduced an AMD wrapper sometime
between 6.0 and 6.9 (the latest version NPM automatically pulls in).
This AMD wrapper confuses Webpack, since it's trying to resolve the
dependencies contained in it. We could create shims for those instead,
but the easiest way was to simply revert to the versions already used
before the Webpack migration (since the newer versions in node_modules
were never actually copied into thirdparty, they weren't used before).
2016-09-15 22:19:12 +12:00
Ingo Schommer
0a380a94cd API Removed unused UMD builds of individual JS files
This has been made obsolete, since those files are all included in the main bundle (see bundle-lib.js).
They should not be referenced individually (e.g. through Requirements::block() or Requirements::javascript()).
2016-09-15 22:19:10 +12:00
Ingo Schommer
5f7b13ee49 API Removed unused images across CMS UI
Many of these are now inline via Webpack's url-loader plugin (https://github.com/webpack/url-loader),
and a tonne were legacy references (e.g. leftovers from ComplexTableField).

Some of these might still be used in other modules like userforms,
but we're removing support for "hotlinking" images in core - they're not an API.
2016-09-15 22:19:10 +12:00
Ingo Schommer
c9d964ff0d Fix HTMLEditorField image reference
Regression from moving images into client/src/ subfolder a while ago
2016-09-15 22:19:10 +12:00
Ingo Schommer
aea96f2f9a Enable UglifyJS mangling
We've disabled this previously because it was interfering with JS sourcemaps and breakpoints.
After some spot tests, this no longer seems to be the case with webpack generated sourcemaps.
2016-09-15 22:19:10 +12:00
Ingo Schommer
2bd4857260 Add new FormBuilderModal (required for asset-admin) 2016-09-15 22:19:09 +12:00