diff --git a/.gitignore b/.gitignore index c63f5b0..3ada55b 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,6 @@ vendor/ /css/ /templates/ /assets/ + +# Test-theme +/test/website/themes/mantra diff --git a/.gulp/Settings.ts b/.gulp/Settings.ts index 415b707..9a218f9 100644 --- a/.gulp/Settings.ts +++ b/.gulp/Settings.ts @@ -35,6 +35,16 @@ export class Settings */ private libraryPath = "javascript"; + /** + * The path to the test-directory. + */ + private testPath = "test"; + + /** + * The path to the test-website. + */ + private testWebsitePath = "website"; + /** * Initializes a new instance of the `Settings` class. * @@ -123,4 +133,32 @@ export class Settings { return this.RootPath(this.libraryPath, ...path); } + + /** + * Creates a path relative to the test-directory. + * + * @param path + * The path to join. + * + * @returns + * The joined path. + */ + public TestPath(...path: string[]) + { + return this.RootPath(this.testPath, ...path); + } + + /** + * Creates a path relative to the test-website. + * + * @param path + * The path to join. + * + * @returns + * The joined path. + */ + public TestWebsitePath(...path: string[]) + { + return this.TestPath(this.testWebsitePath, ...path); + } } \ No newline at end of file diff --git a/.gulp/TaskFunction.ts b/.gulp/TaskFunction.ts index d10e90d..f3f46b8 100644 --- a/.gulp/TaskFunction.ts +++ b/.gulp/TaskFunction.ts @@ -6,7 +6,7 @@ import { TaskFunction } from "gulp"; declare global { // tslint:disable-next-line: completed-docs - interface Function extends TaskFunction + interface Function extends Partial { } } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b5fccce..bd441a3 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ // List of extensions which should be recommended for users of this workspace. "recommendations": [ + "adrianhumphreys.silverstripe", "ms-vscode.vscode-typescript-tslint-plugin", "ms-vscode-remote.remote-containers" ], diff --git a/composer.json b/composer.json index 882ed08..b756985 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,9 @@ "extra": { "scripts-dev": { "post-install-cmd": [ - "npm install" + "npm install", + "@initialize", + "composer --working-dir=./test/website install" ] } } diff --git a/composer.lock b/composer.lock index e94ad04..c4714bb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "22068a23fc6b360469aeccc3a344ead6", + "content-hash": "848468c4f4ad00ed3629fa3cbf2bea5b", "packages": [], "packages-dev": [ { diff --git a/gulpfile.ts b/gulpfile.ts index 37a11e4..1f33f28 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -1,7 +1,8 @@ import browserify = require("browserify"); import log = require("fancy-log"); -import gulp = require("gulp"); +import FileSystem = require("fs-extra"); import { TaskFunction } from "gulp"; +import gulp = require("gulp"); import gulpIf = require("gulp-if"); import terser = require("gulp-terser"); import merge = require("merge-stream"); @@ -78,9 +79,28 @@ let settings = new Settings(options["target"]); /** * Initializes the project. */ -export function Initialize(done: () => void) +export async function Initialize() { - done(); + let directories = [ + "javascript", + "css", + "templates", + "assets" + ]; + + let themePath = settings.TestWebsitePath("themes", Path.basename(settings.RootPath())); + + for (let directory of directories) + { + await FileSystem.emptyDir(settings.RootPath(directory)); + } + + if (await FileSystem.pathExists(themePath)) + { + await FileSystem.remove(themePath); + } + + await require("create-symlink")(settings.RootPath(), themePath, { type: "junction" }); } Initialize.description = "Initializes the project."; @@ -132,7 +152,7 @@ export async function Build() log.info(watchStartMessage); } - Library(); + await Library(); } /** diff --git a/package-lock.json b/package-lock.json index c6d74dd..6a1cba9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,6 +66,15 @@ "integrity": "sha512-31Dt9JaGfHretvwVxCBrCFL5iC9MQ3zOXpu+8C4qzW0cxc5rJJVGxB5c/vZ+wmeTk/JjPz/D0gv8BZ+Ip6iCqQ==", "dev": true }, + "@types/fs-extra": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.0.0.tgz", + "integrity": "sha512-bCtL5v9zdbQW86yexOlXWTEGvLNqWxMFyi7gQA7Gcthbezr2cPSOb8SkESVKA937QD5cIwOFLDFt0MQoXOEr9Q==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/glob": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", @@ -1220,6 +1229,17 @@ "sha.js": "^2.4.8" } }, + "create-symlink": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/create-symlink/-/create-symlink-1.0.0.tgz", + "integrity": "sha1-QNOKcRdnMiNFdi+Q+NBs8nJiAdc=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "inspect-with-kind": "^1.0.0", + "is-plain-obj": "^1.1.0" + } + }, "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", @@ -1817,6 +1837,17 @@ "map-cache": "^0.2.2" } }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", @@ -2780,6 +2811,15 @@ "xtend": "^4.0.0" } }, + "inspect-with-kind": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/inspect-with-kind/-/inspect-with-kind-1.0.5.tgz", + "integrity": "sha512-MAQUJuIo7Xqk8EVNP+6d3CKq9c80hi4tjIbIAT6lmGW9W6WzlHiu9PS8uSuUYU+Do+j1baiFp3H25XEVxDIG2g==", + "dev": true, + "requires": { + "kind-of": "^6.0.2" + } + }, "interpret": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", @@ -2938,6 +2978,12 @@ } } }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -3038,6 +3084,15 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", @@ -3136,6 +3191,14 @@ "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "strip-bom": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "lodash.memoize": { @@ -3720,6 +3783,14 @@ "graceful-fs": "^4.1.2", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "pbkdf2": { @@ -3735,12 +3806,6 @@ "sha.js": "^2.4.8" } }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", @@ -4891,6 +4956,12 @@ "through2-filter": "^3.0.0" } }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", diff --git a/package.json b/package.json index bd78b2a..4c9e754 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "@types/bootstrap": "^4.3.1", "@types/browserify": "^12.0.36", "@types/fancy-log": "^1.3.1", + "@types/fs-extra": "^8.0.0", "@types/gulp": "^4.0.6", "@types/gulp-if": "0.0.33", "@types/gulp-terser": "^1.2.0", @@ -23,7 +24,9 @@ "@types/watchify": "^3.7.4", "bootstrap": "^4.3.1", "browserify": "^16.5.0", + "create-symlink": "^1.0.0", "fancy-log": "^1.3.3", + "fs-extra": "^8.1.0", "gulp": "^4.0.2", "gulp-if": "^3.0.0", "gulp-terser": "^1.2.0", diff --git a/test/website/app/_config/theme.yml b/test/website/app/_config/theme.yml index e1184e7..93d2496 100644 --- a/test/website/app/_config/theme.yml +++ b/test/website/app/_config/theme.yml @@ -3,6 +3,6 @@ Name: mytheme --- SilverStripe\View\SSViewer: themes: + - 'mantra' - '$public' - - 'simple' - '$default' diff --git a/test/website/composer.json b/test/website/composer.json index a69b88a..7bd7885 100644 --- a/test/website/composer.json +++ b/test/website/composer.json @@ -12,6 +12,11 @@ "phpunit/phpunit": "^5.7" }, "extra": { + "expose": [ + "themes/mantra/assets", + "themes/mantra/css", + "themes/mantra/javascript" + ], "resources-dir": "_resources", "project-files-installed": [ "app/.htaccess", diff --git a/test/website/composer.lock b/test/website/composer.lock index 75f7c42..8d1225d 100644 --- a/test/website/composer.lock +++ b/test/website/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7ff31cbd9aa5ee75c9624d2bb8c3bc5f", + "content-hash": "0ab3e4aaf71526993c3dbb3ea6179605", "packages": [ { "name": "bramus/ansi-php", @@ -2216,16 +2216,16 @@ }, { "name": "symfony/cache", - "version": "v3.4.31", + "version": "v3.4.32", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "6a9cc3ed7f61c6c2bc042d0594cdb807b6fea62c" + "reference": "5c7bd827617fcb9b13e04e423c31c0fb0bcf0160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/6a9cc3ed7f61c6c2bc042d0594cdb807b6fea62c", - "reference": "6a9cc3ed7f61c6c2bc042d0594cdb807b6fea62c", + "url": "https://api.github.com/repos/symfony/cache/zipball/5c7bd827617fcb9b13e04e423c31c0fb0bcf0160", + "reference": "5c7bd827617fcb9b13e04e423c31c0fb0bcf0160", "shasum": "" }, "require": { @@ -2282,20 +2282,20 @@ "caching", "psr6" ], - "time": "2019-08-26T07:52:58+00:00" + "time": "2019-09-29T21:19:44+00:00" }, { "name": "symfony/config", - "version": "v3.4.31", + "version": "v3.4.32", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "24a60c0d7ad98a0fa5d1f892e9286095a389404f" + "reference": "717ad66b5257e9752ae3c5722b5810bb4c40b236" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/24a60c0d7ad98a0fa5d1f892e9286095a389404f", - "reference": "24a60c0d7ad98a0fa5d1f892e9286095a389404f", + "url": "https://api.github.com/repos/symfony/config/zipball/717ad66b5257e9752ae3c5722b5810bb4c40b236", + "reference": "717ad66b5257e9752ae3c5722b5810bb4c40b236", "shasum": "" }, "require": { @@ -2346,11 +2346,11 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2019-08-26T07:52:57+00:00" + "time": "2019-09-19T15:32:51+00:00" }, { "name": "symfony/filesystem", - "version": "v4.3.4", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", @@ -2400,16 +2400,16 @@ }, { "name": "symfony/finder", - "version": "v3.4.31", + "version": "v3.4.32", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "1fcad80b440abcd1451767349906b6f9d3961d37" + "reference": "2b6a666d6ff7fb65d10b97d817c8e7930944afb9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/1fcad80b440abcd1451767349906b6f9d3961d37", - "reference": "1fcad80b440abcd1451767349906b6f9d3961d37", + "url": "https://api.github.com/repos/symfony/finder/zipball/2b6a666d6ff7fb65d10b97d817c8e7930944afb9", + "reference": "2b6a666d6ff7fb65d10b97d817c8e7930944afb9", "shasum": "" }, "require": { @@ -2445,7 +2445,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-08-14T09:39:58+00:00" + "time": "2019-09-01T21:32:23+00:00" }, { "name": "symfony/polyfill-apcu", @@ -2686,16 +2686,16 @@ }, { "name": "symfony/yaml", - "version": "v3.4.31", + "version": "v3.4.32", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "3dc414b7db30695bae671a1d86013d03f4ae9834" + "reference": "768f817446da74a776a31eea335540f9dcb53942" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/3dc414b7db30695bae671a1d86013d03f4ae9834", - "reference": "3dc414b7db30695bae671a1d86013d03f4ae9834", + "url": "https://api.github.com/repos/symfony/yaml/zipball/768f817446da74a776a31eea335540f9dcb53942", + "reference": "768f817446da74a776a31eea335540f9dcb53942", "shasum": "" }, "require": { @@ -2741,7 +2741,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2019-08-20T13:31:17+00:00" + "time": "2019-09-10T10:38:46+00:00" }, { "name": "webonyx/graphql-php",