From bed88d5eebac920d9fc30354cb4a326e4a4c6f1a Mon Sep 17 00:00:00 2001 From: Alistair Laing Date: Tue, 18 Jun 2019 14:31:10 +0100 Subject: [PATCH] Ensure package contents is namespaced to use govuk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: package ├── assets ├── components ├── core ├── helpers ├── objects ├── overrides ├── settings ├── tools ├── utilities ├── vendor ├── README.md ├── all-ie8.scss ├── all.js ├── all.scss ├── common.js ├── govuk-prototype-kit.config.json ├── package.json └── template.njk After: package ├── govuk │ ├── assets │ ├── components │ ├── core │ ├── helpers │ ├── objects │ ├── overrides │ ├── settings │ ├── tools │ ├── utilities │ ├── vendor │ ├── all-ie8.scss │ ├── all.js │ ├── all.scss │ ├── common.js │ └── template.njk ├── README.md ├── govuk-prototype-kit.config.json └── package.json See proposal for more detail https://github.com/alphagov/govuk-design-system-architecture/blob/master/proposals/005-namespace-govuk-frontend-nunjucks-sass-using-a-nested-folder-structure.md --- tasks/gulp/__tests__/after-build-package.test.js | 10 ++++++---- tasks/gulp/compile-assets.js | 4 +++- tasks/gulp/copy-to-destination.js | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tasks/gulp/__tests__/after-build-package.test.js b/tasks/gulp/__tests__/after-build-package.test.js index 504f9a36608..fc03fc53f17 100644 --- a/tasks/gulp/__tests__/after-build-package.test.js +++ b/tasks/gulp/__tests__/after-build-package.test.js @@ -39,13 +39,15 @@ describe('package/', () => { '.DS_Store', '*.test.js', '*.yaml', - '*.snap' + '*.snap', + '*/govuk/README.md' ] const additionalFilesNotInSrc = [ 'package.json', 'govuk-prototype-kit.config.json', - '**/macro-options.json' + '**/macro-options.json', + 'README.md' ] return recursive(configPaths.src, filesToIgnore).then( @@ -92,7 +94,7 @@ describe('package/', () => { describe('all.scss', () => { it('should compile without throwing an exception', async () => { - const allScssFile = path.join(configPaths.package, 'all.scss') + const allScssFile = path.join(configPaths.package, 'govuk', 'all.scss') await renderSass({ file: allScssFile }) }) }) @@ -101,7 +103,7 @@ describe('package/', () => { const componentNames = lib.allComponents.slice() it.each(componentNames)(`'%s' should have macro-options.json that contains JSON`, (name) => { - const filePath = path.join(configPaths.package, 'components', name, 'macro-options.json') + const filePath = path.join(configPaths.package, 'govuk', 'components', name, 'macro-options.json') return readFile(filePath, 'utf8') .then((data) => { var parsedData = JSON.parse(data) diff --git a/tasks/gulp/compile-assets.js b/tasks/gulp/compile-assets.js index 80118e64537..a401088d97f 100644 --- a/tasks/gulp/compile-assets.js +++ b/tasks/gulp/compile-assets.js @@ -142,6 +142,8 @@ gulp.task('scss:compile', () => { gulp.task('js:compile', () => { // for dist/ folder we only want compiled 'all.js' file let srcFiles = isDist ? configPaths.src + 'all.js' : configPaths.src + '**/*.js' + let destination = isDist ? taskArguments.destination : taskArguments.destination + '/govuk/' + return gulp.src([ srcFiles, '!' + configPaths.src + '**/*.test.js' @@ -164,5 +166,5 @@ gulp.task('js:compile', () => { }) )) .pipe(eol()) - .pipe(gulp.dest(taskArguments.destination + '/')) + .pipe(gulp.dest(destination)) }) diff --git a/tasks/gulp/copy-to-destination.js b/tasks/gulp/copy-to-destination.js index 2db0db33299..ec05012eae1 100644 --- a/tasks/gulp/copy-to-destination.js +++ b/tasks/gulp/copy-to-destination.js @@ -60,5 +60,5 @@ gulp.task('copy-files', () => { path.extname = '.json' })) .pipe(yamlFiles.restore) - .pipe(gulp.dest(taskArguments.destination + '/')) + .pipe(gulp.dest(taskArguments.destination + '/govuk/')) })