Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update copy:files to glob “src” not “src/govuk” #2964

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tasks/gulp/copy-to-destination.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gulp.task('copy:files', () => {
*/
merge(
gulp.src([
`${slash(configPaths.src)}/govuk/**/*`,
`${slash(configPaths.src)}/**/*`,

// Exclude files we don't want to publish
'!**/.DS_Store',
Expand All @@ -45,19 +45,19 @@ gulp.task('copy:files', () => {
`!${slash(configPaths.src)}/govuk/README.md`,

// Exclude Sass files handled by PostCSS stream below
`!${slash(configPaths.src)}/govuk/**/*.scss`,
`!${slash(configPaths.src)}/**/*.scss`,

// Exclude source YAML handled by JSON streams below
`!${slash(configPaths.components)}/**/*.yaml`
]),

// Add CSS prefixes to Sass
gulp.src(`${slash(configPaths.src)}/govuk/**/*.scss`)
gulp.src(`${slash(configPaths.src)}/**/*.scss`)
.pipe(postcss([autoprefixer], { syntax: postcssScss })),

// Generate fixtures.json from ${componentName}.yaml
gulp.src(`${slash(configPaths.components)}/**/*.yaml`, {
base: slash(`${configPaths.src}/govuk`)
base: slash(configPaths.src)
})
.pipe(map((file, done) =>
generateFixtures(file)
Expand All @@ -71,7 +71,7 @@ gulp.task('copy:files', () => {

// Generate macro-options.json from ${componentName}.yaml
gulp.src(`${slash(configPaths.components)}/**/*.yaml`, {
base: slash(`${configPaths.src}/govuk`)
base: slash(configPaths.src)
})
.pipe(map((file, done) =>
generateMacroOptions(file)
Expand All @@ -82,7 +82,7 @@ gulp.task('copy:files', () => {
basename: 'macro-options',
extname: '.json'
}))
).pipe(gulp.dest(slash(join(destination, 'govuk'))))
).pipe(gulp.dest(slash(destination)))
)
})

Expand Down
28 changes: 3 additions & 25 deletions tasks/prototype-kit-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { copyFile, mkdir, writeFile } = require('fs/promises')
const { writeFile } = require('fs/promises')
const { EOL } = require('os')
const { dirname, join } = require('path')
const { join } = require('path')

const configPaths = require('../config/paths.js')
const { destination } = require('./task-arguments.js')

/**
Expand All @@ -13,33 +12,12 @@ const { destination } = require('./task-arguments.js')
async function updatePrototypeKitConfig () {
const { default: configFn } = await import('../src/govuk-prototype-kit/govuk-prototype-kit.config.mjs')

// Files to copy
const copyFiles = [
join('govuk-prototype-kit', 'init.js'),
join('govuk-prototype-kit', 'init.scss')
]

// Copy files to destination
const configTasks = copyFiles.map(async (file) => {
const fileSource = join(configPaths.src, file)
const fileTarget = join(destination, file)

// Create destination directory
await mkdir(dirname(fileTarget), { recursive: true })

// Copy file to destination
return copyFile(fileSource, fileTarget)
})

// JSON config file path + contents
const configPath = join(destination, 'govuk-prototype-kit.config.json')
const configJSON = JSON.stringify(await configFn(), null, 2) + EOL

// Write JSON config file
configTasks.push(writeFile(configPath, configJSON))

// Resolve on completion
return Promise.all(configTasks)
return writeFile(configPath, configJSON)
}

updatePrototypeKitConfig.displayName = 'update-prototype-kit-config'
Expand Down