Skip to content

Commit

Permalink
Move packages into npm workspaces structure
Browse files Browse the repository at this point in the history
Moves all packages into “packages” excluding `govuk-frontend` source and related directories (src, dist, package)

https://docs.npmjs.com/cli/v9/using-npm/workspaces#defining-workspaces
  • Loading branch information
colinrotherham committed Apr 6, 2023
1 parent e5f9f99 commit 07ddf40
Show file tree
Hide file tree
Showing 212 changed files with 540 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

# Review app is already built (or restored from cache) so
# start with `--ignore-scripts` to prevent "prestart" build
run: npm start --ignore-scripts --workspace app &
run: npm start --ignore-scripts --workspace packages/app &

- name: Send screenshots to Percy
run: npx percy exec --parallel -- npm run test:screenshots
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: npm start --workspace app
web: npm start --workspace packages/app
28 changes: 17 additions & 11 deletions docs/contributing/application-architecture.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
## Application architecture

- `app/`

[Express](https://github.com/expressjs/express) application to preview components; also referred to as the _review app_.

- `bin/`

Binary/executable files (i.e. bash scripts) mainly used in the [publishing process](/docs/releasing/publishing.md).
Expand All @@ -21,19 +17,29 @@
package published on npm.
Consume all of govuk-frontend through a single package.

- `shared/`
- `packages/`

- `app/`

[Express](https://github.com/expressjs/express) application to preview components; also referred to as the _review app_.

- `examples/`

Example GOV.UK Frontend integrations

- `shared/`

- `config/`
- `config/`

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

- `lib/`
- `lib/`

Application modules and helpers.
Application modules and helpers.

- `tasks/`
- `tasks/`

See [tasks](tasks.md) for more information about the tasks.
See [tasks](tasks.md) for more information about the tasks.

- `src/`

Expand Down
24 changes: 12 additions & 12 deletions docs/contributing/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To run the application without any tasks being triggered, see [Express app only]

npm scripts are defined in `package.json`. These trigger a number of Gulp tasks.

**`npm start` will trigger `npm run dev --workspace app` that will:**
**`npm start` will trigger `npm run dev --workspace packages/app` that will:**

- runs tasks from `npm run build:app`
- starts up Express, restarting when `.mjs`, `.json` or `.yaml` files change
Expand All @@ -20,14 +20,14 @@ npm scripts are defined in `package.json`. These trigger a number of Gulp tasks.
- run JavaScript tests on the review application
- run accessibility and HTML validation tests

**`npm run serve --workspace app` will do the following:**
**`npm run serve --workspace packages/app` will do the following:**

- start up Express, restarting when `.mjs`, `.json` or `.yaml` files change

**`npm run build:app` will trigger `npm run build --workspace app` that will:**
**`npm run build:app` will trigger `npm run build --workspace packages/app` that will:**

- clean the `./app/dist` folder
- output files into `./app/dist`
- clean the `./packages/app/dist` folder
- output files into `./packages/app/dist`
- copy fonts and images
- compile JavaScript and Sass, including documentation

Expand All @@ -53,33 +53,33 @@ npm scripts are defined in `package.json`. These trigger a number of Gulp tasks.

## Gulp tasks

Project Gulp tasks are defined in [`gulpfile.mjs`](../../gulpfile.mjs) and the [`tasks/`](../../shared/tasks) folder.
Project Gulp tasks are defined in [`gulpfile.mjs`](../../gulpfile.mjs) and the [`tasks/`](../../packages/shared/tasks) folder.

**`gulp --tasks`**

This task will:

- list out all available tasks

Review app Gulp tasks are defined in [`app/gulpfile.mjs`](../../app/gulpfile.mjs) and the [`app/tasks/`](../../app/tasks) folder.
Review app Gulp tasks are defined in [`packages/app/gulpfile.mjs`](../../packages/app/gulpfile.mjs) and the [`packages/app/tasks/`](../../packages/app/tasks) folder.

Gulp tasks from npm workspaces (such as the review app) can be run as shown:

**`npx --workspace app -- gulp styles`**
**`npx --workspace packages/app -- gulp styles`**

This task will:

- check Sass code quality via Stylelint (`npm run lint:scss`)
- compile Sass to CSS into `./app/dist/stylesheets`
- compile Sass documentation into `./app/dist/docs/sassdoc`
- compile Sass to CSS into `./packages/app/dist/stylesheets`
- compile Sass documentation into `./packages/app/dist/docs/sassdoc`

**`npx --workspace app -- gulp scripts`**
**`npx --workspace packages/app -- gulp scripts`**

This task will:

- check JavaScript code quality via ESLint (`npm run lint:js`) (using JavaScript Standard Style)
- compile JavaScript to Universal Module Definition (UMD) into `./app/dist/javascripts`
- compile JavaScript documentation into `./app/dist/docs/jsdoc`
- compile JavaScript documentation into `./packages/app/dist/docs/jsdoc`

## Express app only

Expand Down
2 changes: 1 addition & 1 deletion jest-dev-server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { ports } = require('govuk-frontend-config')
*/
module.exports = {
// Start with `--ignore-scripts` to prevent "prestart" build
command: 'npm start --ignore-scripts --workspace app',
command: 'npm start --ignore-scripts --workspace packages/app',
port: ports.app,

// Skip when already running
Expand Down
2 changes: 1 addition & 1 deletion jsdoc.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
opts: {
destination: './app/dist/docs/jsdoc',
destination: './packages/app/dist/docs/jsdoc',
recurse: true
},
plugins: [
Expand Down
Loading

0 comments on commit 07ddf40

Please sign in to comment.