Skip to content

Commit

Permalink
Move source into package/src
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Apr 4, 2023
1 parent 5526cf3 commit bc83957
Show file tree
Hide file tree
Showing 434 changed files with 269 additions and 266 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
extends: 'standard',
ignorePatterns: [
'**/dist/**',
'**/release/**',
'**/vendor/**',

// Enable dotfile linting
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/diff-change-to-dist.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Diff changes to dist
name: Diff changes to release

on:
pull_request:
paths: ['dist/**']
paths: ['package/release/**']

permissions:
pull-requests: write
Expand Down Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Generate diff
id: diff
run: |
git diff -M05 origin/$GITHUB_BASE_REF -- dist \
> $GITHUB_WORKSPACE/dist.diff
git diff -M05 origin/$GITHUB_BASE_REF -- package/release \
> $GITHUB_WORKSPACE/release.diff
- name: Add comment to PR
uses: actions/github-script@v6
Expand All @@ -43,10 +43,10 @@ jobs:
script: |
const fs = require('fs').promises
const diff = await fs.readFile(
process.env.GITHUB_WORKSPACE + '/dist.diff', 'utf8'
process.env.GITHUB_WORKSPACE + '/release.diff', 'utf8'
)
const commentText = '## Changes to dist\n' +
const commentText = '## Changes to release\n' +
'```diff\n' +
diff +
'\n```'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/sass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
sass --version
- name: Run command
run: time sass src/govuk/all.scss > /dev/null
run: time sass package/src/govuk/all.scss > /dev/null

dart-sass-latest:
name: Dart Sass v1 (latest)
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
node-sass --version
- name: Run command
run: time node-sass src/govuk/all.scss > /dev/null
run: time node-sass package/src/govuk/all.scss > /dev/null

# Node Sass v8.x = LibSass v3 latest
lib-sass-latest:
Expand All @@ -110,7 +110,7 @@ jobs:
node-sass --version
- name: Run command
run: time node-sass src/govuk/all.scss > /dev/null
run: time node-sass package/src/govuk/all.scss > /dev/null

ruby-sass:
name: Ruby Sass v3.4.0 (deprecated)
Expand All @@ -131,7 +131,7 @@ jobs:
sass --version
- name: Run command
run: time sass src/govuk/all.scss > /dev/null
run: time sass package/src/govuk/all.scss > /dev/null

ruby-sass-latest:
name: Ruby Sass v3 (latest, deprecated)
Expand All @@ -152,4 +152,4 @@ jobs:
sass --version
- name: Run command
run: time sass src/govuk/all.scss > /dev/null
run: time sass package/src/govuk/all.scss > /dev/null
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:

- description: Verify distribution build
name: test-build-dist
run: npm run build:dist
run: npm run build:release

- description: JavaScript behaviour tests
name: test-behaviour
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage/

# Build output
dist/
release/

# Files to ignore
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage/

# Build output
dist/
release/

# 3rd party vendor code
vendor/
Expand Down
2 changes: 1 addition & 1 deletion app/nodemon.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"watch": ["./src", "../src/govuk/**/*.{json,yaml}"],
"watch": ["./src", "../package/src/govuk/**/*.{json,yaml}"],
"ignore": ["**/*.test.*"],
"ext": "mjs,json,yaml",
"quiet": true
Expand Down
2 changes: 1 addition & 1 deletion app/src/stylesheets/app-ie8.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import "../../../src/govuk/all-ie8";
@import "../../../package/src/govuk/all-ie8";
@import "partials/app";
@import "partials/banner";
2 changes: 1 addition & 1 deletion app/src/stylesheets/app.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$govuk-show-breakpoints: true;
$govuk-new-link-styles: true;

@import "../../../src/govuk/all";
@import "../../../package/src/govuk/all";
@import "partials/app";
@import "partials/code";
@import "partials/banner";
Expand Down
4 changes: 2 additions & 2 deletions app/src/stylesheets/full-page-examples/campaign-page.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../../../src/govuk/base";
@import "../../../../package/src/govuk/base";
$govuk-new-link-styles: true;
@import "../../../../src/govuk/core/all";
@import "../../../../package/src/govuk/core/all";

.app-header--campaign {
padding-bottom: govuk-spacing(2);
Expand Down
4 changes: 2 additions & 2 deletions app/src/stylesheets/full-page-examples/search.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../../../src/govuk/base";
@import "../../../../package/src/govuk/base";
$govuk-new-link-styles: true;
@import "../../../../src/govuk/core/all";
@import "../../../../package/src/govuk/core/all";

.app-document-list > li {
padding-top: govuk-spacing(4);
Expand Down
2 changes: 1 addition & 1 deletion bin/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi

npm run test
npm run build:package
npm run build:dist
npm run build:release

ALL_PACKAGE_VERSION=$(node -p "require('./package/package.json').version")
TAG="v$ALL_PACKAGE_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion bin/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ else
echo "🗒 Tag $TAG created and pushed to remote."

echo "🗒 Creating a release artifact..."
git archive -o ./release-$TAG.zip HEAD:dist
git archive -o ./release-$TAG.zip HEAD:release
echo "🗒 Artifact created. Now create a release on GitHub and attach this."
fi
10 changes: 5 additions & 5 deletions config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const rootPath = dirname(__dirname)
*/
module.exports = {
root: rootPath,
src: join(rootPath, 'src'),

// Build: Release distribution
dist: join(rootPath, 'dist'),
src: join(rootPath, 'package/src'),

// Build: Package for npm publish
package: join(rootPath, 'package'),
dist: join(rootPath, 'package/dist'),

// Build: Release distribution
release: join(rootPath, 'package/release'),

// Review application
app: join(rootPath, 'app')
Expand Down
10 changes: 1 addition & 9 deletions docs/contributing/application-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

Configuration files for the review app and [Jest](https://github.com/facebook/jest).

- `dist/` **contains auto-generated files**

Standalone builds of govuk-frontend. Provides a way to consume govuk-frontend without using npm.

- `docs/`

Documentation files.
Expand All @@ -24,15 +20,11 @@

Application modules and helpers.

- `package/` **contains auto-generated files**
- `package/`

package published on npm.
Consume all of govuk-frontend through a single package.

- `src/`

Source files. See README.md in the src directory for details.

- `tasks/`

Application modules and helpers. See [tasks](tasks.md) for more information about the tasks.
2 changes: 1 addition & 1 deletion docs/contributing/coding-standards/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Components

You can find components in `src/govuk/components`.
You can find components in `package/src/govuk/components`.

## Name your components

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/coding-standards/css.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,4 @@ The SassDoc comments are used to generate the [Sass API reference in the GOV.UK

For SassDoc comments, use 3 slashes (`///`) at the start of the line.

See [colour.scss](../../../src/govuk/helpers/_colour.scss) for an example of SassDoc syntax.
See [colour.scss](../../../package/src/govuk/helpers/_colour.scss) for an example of SassDoc syntax.
2 changes: 1 addition & 1 deletion docs/contributing/coding-standards/js.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Prefer named exports over default exports to avoid compatibility issues with tra

## Polyfilling

If you need to support older browsers, import the necessary [polyfills](/src/govuk/vendor/polyfills) and they will be added to the environment when the feature is not supported.
If you need to support older browsers, import the necessary [polyfills](../../../package/src/govuk/vendor/polyfills) and they will be added to the environment when the feature is not supported.

For example, if you want to polyfill `addEventListener` for IE8, import the Event polyfills.

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/coding-standards/nunjucks-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To provide a level of consistency for developers we have standardised option nam

The options (arguments) accepted by the component macro are specified in a `[component-name].yaml` file as `params`. Each option should have the following attributes: `name`, `type`, `required`, `description`.

An option can additionally contain `params` that denotes nested items in the option (see [breadcrumbs component](/src/govuk/components/breadcrumbs/breadcrumbs.yaml#L6)) and `isComponent: true` where the option is another component (see [checkboxes component](/src/govuk/components/checkboxes/checkboxes.yaml#L11)).
An option can additionally contain `params` that denotes nested items in the option (see [breadcrumbs component](../../../package/src/govuk/components/breadcrumbs/breadcrumbs.yaml#L6)) and `isComponent: true` where the option is another component (see [checkboxes component](../../../package/src/govuk/components/checkboxes/checkboxes.yaml#L10)).

Component macro options are shipped as `macro-options.json` in `package`.

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/managing-change.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ Keep the old name in the selector list, and mark it as deprecated.

In the above examples we've used `@include _warning(...)` instead of the native sass `@warn` at-rule. We use this instead of `@warn` because it gives users the option to suppress deprecation warnings by interacting with the `$govuk-suppressed-warnings` map.

You can read more about how `$govuk-suppressed-warnings` and `_warning` work by reading their respective sassdocs in `/src/govuk/settings/warnings.scss`.
You can read more about how `$govuk-suppressed-warnings` and `_warning` work by reading their respective sassdocs in `package/src/govuk/settings/warnings.scss`.

We make this option available for users because they can not always action deprecation warnings or upgrade their codebase beyond a specific version of GOV.UK Frontend. For example, a legacy codebase that does not have the resource to upgrade to the latest breaking change where a deprecated feature will be removed. This feature allows those users to continue to operate their codebase without having to repeatedly see non-actionable deprecation warnings in their testing.
12 changes: 6 additions & 6 deletions docs/contributing/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ npm scripts are defined in `package.json`. These trigger a number of Gulp tasks.

**`npm run build:package` will do the following:**

- clean the `./package` folder
- output files into `./package`
- clean the `./package/dist` folder
- output files into `./package/dist`
- copy Sass files, applying Autoprefixer via PostCSS
- copy Nunjucks component template/macro files, including JSON configs
- copy GOV.UK Prototype Kit config files
- compile JavaScript to ECMAScript Modules (ESM)
- compile JavaScript to Universal Module Definition (UMD)
- runs `npm run postbuild:package` (which will test the output is correct)

**`npm run build:dist` will do the following:**
**`npm run build:release` will do the following:**

- clean the `./dist` folder
- output files into `./dist`
- clean the `./package/release` folder
- output files into `./package/release`
- copy fonts and images
- compile JavaScript and Sass
- append version number from `package/package.json` to compiled JavaScript and CSS files
- runs `npm run postbuild:dist` (which will test the output is correct)
- runs `npm run postbuild:release` (which will test the output is correct)

## Gulp tasks

Expand Down
18 changes: 9 additions & 9 deletions docs/contributing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Check that:

You should add an example to the review app if the existing examples do not reflect the changes you've made.

1. Open `src/govuk/components/<COMPONENT>/<COMPONENT>.yaml`, where `<COMPONENT>` is the component you've changed.
1. Open `package/src/govuk/components/<COMPONENT>/<COMPONENT>.yaml`, where `<COMPONENT>` is the component you've changed.
2. Add or update examples in the `examples` list.

If you've created a new component, create a new `src/govuk/<COMPONENT>/<COMPONENT>.yaml` file instead, where `<COMPONENT>` is the name of the component you've created.
If you've created a new component, create a new `package/src/govuk/<COMPONENT>/<COMPONENT>.yaml` file instead, where `<COMPONENT>` is the name of the component you've created.

## 4. Test in supported browsers and assistive technology

Expand Down Expand Up @@ -84,27 +84,27 @@ You should write new tests if you’ve created a new component, or changed the w

If you're new to testing, see existing test files for examples of things to do. Do not let the tests keep you from submitting your contribution! If you're not sure which tests are needed or are having trouble updating them, submit your pull request anyway. We will help you create the tests and solve problems during code review.

Some test files use examples from each component’s `.yaml` file, for example `src/govuk/components/button/button.yaml`. When you add or update these tests, you can use the existing examples or add new ones.
Some test files use examples from each component’s `.yaml` file, for example `package/src/govuk/components/button/button.yaml`. When you add or update these tests, you can use the existing examples or add new ones.

Use `hidden: true` in a new example if you do not want to include the example in the review app. The example will still appear in our [test fixtures](http://frontend.design-system.service.gov.uk/testing-your-html/).

All tests should try and meet [our testing conventions](../releasing/testing-and-linting.md#conventions)

### If you created a component

Create the following files in the `src/govuk/components` folder:
Create the following files in the `package/src/govuk/components` folder:

- `<COMPONENT>/<COMPONENT>.test.js` - to test functionality if the component uses JavaScript
- `<COMPONENT>/<COMPONENT>.unit.test.mjs` - to unit test any JavaScript logic
- `<COMPONENT>/template.test.js` - to test the Nunjucks macro

Where `<COMPONENT>` is the name of the component you created.

You can use the existing files in the `src/govuk/components` folder as templates for your new files.
You can use the existing files in the `package/src/govuk/components` folder as templates for your new files.

### If you changed or added to a component

In the `src/govuk/components` folder, update or add tests to:
In the `package/src/govuk/components` folder, update or add tests to:

- `<COMPONENT>/<COMPONENT>.test.js` - if you updated functionality
- `<COMPONENT>/<COMPONENT>.unit.test.mjs` - if you updated JavaScript logic
Expand All @@ -116,7 +116,7 @@ Where `<COMPONENT>` is the name of the component you changed or added to.

Update or add tests in the `.test.js` file that matches the name of the `.scss` file you created or updated. Create the `.test.js` file if it does not exist.

For example, if you updated a mixin in `src/govuk/helpers/_colour.scss`, update or add tests in `src/govuk/helpers/_colour.test.js`.
For example, if you updated a mixin in `package/src/govuk/helpers/_colour.scss`, update or add tests in `package/src/govuk/helpers/_colour.test.js`.

## 7. Update the snapshot tests

Expand All @@ -125,8 +125,8 @@ If your component uses another component, one of the [Jest snapshot tests](https
If a snapshot test fails, follow these steps.

1. Check that the component's new markup is correct.
2. Run `npm test -- -u src/govuk/components/<COMPONENT>` to update the snapshot test with the new markup.
3. Commit the updated file in the `/src/govuk/components/<COMPONENT>/__snapshots__/` folder.
2. Run `npm test -- -u package/src/govuk/components/<COMPONENT>` to update the snapshot test with the new markup.
3. Commit the updated file in the `/package/src/govuk/components/<COMPONENT>/__snapshots__/` folder.
4. In the commit message, tell us you're updating the snapshot file and why.

Where `<COMPONENT>` is the name of the component you've changed.
Expand Down
10 changes: 5 additions & 5 deletions docs/releasing/testing-and-linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ See [Tasks](../contributing/tasks.md) for details of what `npm test` does.

You can run a subset of the test suite that only tests components by running:

`npx jest src/govuk/components/button`
`npx jest package/src/govuk/components/button`

Note: There's a watch mode that keeps a testing session open waiting for changes that can be used with:

`npx jest --watch src/govuk/components/button`
`npx jest --watch package/src/govuk/components/button`

### Running all linting checks locally

Expand Down Expand Up @@ -74,13 +74,13 @@ We use [Jest](https://jestjs.io/), an automated testing platform with an asserti

We write functional tests for every component to check the output of our Nunjucks code. These are found in `template.test.js` files in each component directory. These Nunjucks tests render the component examples defined in the component yaml files, and assert that the HTML tags, attributes and classes are as expected. For example: checking that when you pass in an `id` to the component using the Nunjucks macro, it outputs the component with an `id` attribute equal to that value.

If a component uses JavaScript, we also write functional tests in a `[component name].test.js` file, for example [checkboxes.test.js](../../src/govuk/components/checkboxes/checkboxes.test.js). These component tests check that interactions, such as a mouse click, have the expected result.
If a component uses JavaScript, we also write functional tests in a `[component name].test.js` file, for example [checkboxes.test.js](../../package/src/govuk/components/checkboxes/checkboxes.test.js). These component tests check that interactions, such as a mouse click, have the expected result.

You should also test component Javascript logic with unit tests, in a `[component name].unit.test.mjs` file. These tests are better suited for testing behind-the-scenes logic, or in cases where the final output of some logic is not a change to the component markup.

### Global tests

We write functional tests for checking our JavaScript exports and our global sass variables - see [all.test.js](../../src/govuk/all.test.js) for examples of global tests we run.
We write functional tests for checking our JavaScript exports and our global sass variables - see [all.test.js](../../package/src/govuk/all.test.mjs) for examples of global tests we run.

### Conventions

Expand All @@ -96,7 +96,7 @@ For components, the snapshots are stored in `[component-name directory]/_snapsho

If a snapshot test fails, review the difference in the console. If the change is the correct change to make, run:

`npm test -- -u src/govuk/components/button`
`npm test -- -u package/src/govuk/components/button`

This will update the snapshot file. Commit this file separately with a commit message that explains you're updating the snapshot file and an explanation of what caused the change.

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { browser } from './tasks/index.mjs'
* Build target tasks
*/
gulp.task('build:package', build.package)
gulp.task('build:dist', build.dist)
gulp.task('build:release', build.release)

/**
* Screenshots task
Expand Down
Loading

0 comments on commit bc83957

Please sign in to comment.