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

Setup to publish one package #680

Merged
merged 29 commits into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
afd1690
Rename packages folder to package
Apr 27, 2018
acb4967
Remove Lerna
Apr 27, 2018
62b7e4d
Update clean gulp task
May 3, 2018
6846b30
Update paths config.json
May 3, 2018
e00a49d
Update package.json tasks
May 3, 2018
c80de7d
Update asset version gulp task
May 3, 2018
28a108a
Update after-build-package task test
May 3, 2018
60dc7ed
Update file-helper.js
May 3, 2018
e313eb8
Update docs
May 3, 2018
6187ac2
Update gulpfile
May 3, 2018
85689cd
Move all folder into root
Apr 27, 2018
7e3946a
Update app*.scss files to import root govuk*.scss files
May 3, 2018
65c1f0b
Remove redundant govuk*.scss from app/ folder
May 3, 2018
5ced94c
Update import paths for partials in govuk*.scss files
May 3, 2018
248d988
Update app layout view to reference updated paths
May 3, 2018
1e8ef94
Update compile-assets gulp task
May 3, 2018
bae6b4b
Create a new package.json in package folder
Apr 27, 2018
0081099
Updated paths for imported JS
Apr 27, 2018
93b96ba
Remove all component package.json files
Apr 27, 2018
36b5cd4
No need to filter all package from the list of components
Apr 27, 2018
e26d56f
No longer need to expect package.json in each folder
Apr 27, 2018
18fffad
Expect root files from src/ in package/
Apr 27, 2018
e49d6be
Update build-after-dist test
May 1, 2018
2d17540
Update release scripts and remove redundant
May 2, 2018
d9d0beb
Update copy-to-destination gulp task
May 3, 2018
e96d90c
Update gitignore
May 3, 2018
64b6380
Import all in all-ie8.scss
May 3, 2018
16abddf
Document in CHANGELOG
May 4, 2018
13d18ff
Remove mention of packages from main readme
May 10, 2018
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ npm-debug.log
.DS_Store
preview/
tmp/
lerna-debug.log
axeReports/
public/
packages/**/package-lock.json
package/package-lock.json
examples/**/package-lock.json
*.zip
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ Note: We're not following semantic versioning yet, we are going to talk about th

Breaking changes:

- Restructure project to enable it to be published as a single package
([PR #680](https://github.com/alphagov/govuk-frontend/pull/680))
This is ground work to enable the project to be published as a single package by:
- removing components' package.json files
- moving "all" files into root
- renaming "packages" folder to "package"
- removing Lerna
- updating release scripts
- creating a new package.json
- updating documentation
- update any tests and build pipelines to support this

The single package will be published under a new name.
There are more changes to be done to folder structure to ensure
entry points are more understandable.

- Error messages have been moved out of the label and fieldset components and
are now called from every component that uses them - they are no longer nested
within the label or legend. They are associated with the input or with the
Expand Down Expand Up @@ -134,7 +150,6 @@ Breaking changes:

([PR #684](https://github.com/alphagov/govuk-frontend/pull/684))


- Remove -c -o -h layer prefixes
([PR #644](https://github.com/alphagov/govuk-frontend/pull/644))
In user research and in feedback from Private Beta partners we
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@ To install all components, run:
npm install --save @govuk-frontend/all
```

To install individual components (for example, a button), run:

```
npm install --save @govuk-frontend/button
```

You can find a list of all components in the [packages
directory](https://github.com/alphagov/govuk-frontend/tree/master/packages).
Each component has a README with installation and usage instructions.

After you have installed GOV.UK Frontend the `@govuk-frontend` package will
appear in your `node_modules` folder.

Expand Down
4 changes: 2 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ module.exports = (options) => {
// Filter out globals, all and icons package
const filteredComponents = components.filter(component => (
component !== 'globals' &&
component !== 'all' &&
component !== 'icons'
component !== 'icons' &&
!component.startsWith('all')
))

res.render('index', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// right corner of your site during development, add the breakpoints
// to this list, ordered by width, e.g. (mobile, tablet, desktop).
$mq-show-breakpoints: (desktop);
@import "../../../src/all/all-old-ie";
@import "../../../src/all-ie8";
@import "partials/app";
2 changes: 1 addition & 1 deletion app/assets/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// right corner of your site during development, add the breakpoints
// to this list, ordered by width, e.g. (mobile, tablet, desktop).
$mq-show-breakpoints: (mobile, tablet, desktop);
@import "../../../src/all/all";
@import "../../../src/all";
@import "partials/app";
1 change: 0 additions & 1 deletion app/assets/scss/govuk-frontend-old-ie.scss

This file was deleted.

1 change: 0 additions & 1 deletion app/assets/scss/govuk-frontend.scss

This file was deleted.

6 changes: 3 additions & 3 deletions app/views/layouts/_generic.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<title>GOV.UK Frontend</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--[if !IE 8]><!-->
<link rel="stylesheet" href="/public/css/app.css">
<link rel="stylesheet" href="/public/app.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/prism.min.js"></script>
<!--<![endif]-->
<!--[if lt IE 9]>
<script src="/vendor/html5-shiv/html5shiv.js"></script>
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" href="/public/css/app-old-ie.css">
<link rel="stylesheet" href="/public/app-ie8.css">
<![endif]-->
{% block styles %}
{% endblock %}
Expand All @@ -24,7 +24,7 @@
{% block body %}
{% block content %}{% endblock %}
{% endblock %}
<script src="/public/all/all.js"></script>
<script src="/public/all.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/3.5.15/iframeResizer.min.js"></script>
<!--[if lte IE 8]>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/3.5.15/ie8.polyfils.min.js"></script>
Expand Down
47 changes: 0 additions & 47 deletions bin/check-and-create-package-json.sh

This file was deleted.

13 changes: 0 additions & 13 deletions bin/npm-publish.sh

This file was deleted.

32 changes: 11 additions & 21 deletions bin/pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,21 @@ set -e

LATEST_PUBLISHED_TAG=$(git describe --abbrev=0 --tags)

npm run build:packages &&
lerna publish --skip-git --skip-npm &&
npm run build:package
npm run build:dist


ALL_PACKAGE_VERSION=$(node -p "require('./packages/all/package.json').version")
ALL_PACKAGE_VERSION=$(node -p "require('./package/package.json').version")
TAG="v$ALL_PACKAGE_VERSION"
ERROR_CODE=$?
CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)

if [ $ERROR_CODE != 0 ]; then
echo "⚠️ Error with lerna publish. Please try again."
exit $ERROR_CODE;
if [ "$LATEST_PUBLISHED_TAG" == "$TAG" ]; then
echo "⚠️ Git tag already exists."
exit 1;
else
# if you cancel lerna publish, it exists with 0 and it doesnt update package.json files so
# we exit because package.json file hasn't changed. Otherwise commit changes.
if [ "$LATEST_PUBLISHED_TAG" == "$TAG" ]; then
echo "⚠️ Nothing to commit. Rerun the step."
exit 1;
else
git add . &&
git commit -m "Release $TAG" &&
#set upstream so that we can push the branch up
git push --set-upstream origin $CURRENT_BRANCH_NAME &&
git push
echo "🗒 All done. Ready to create a pull request. Once approved, run npm run release"
fi
git add .
git commit -m "Release $TAG"
#set upstream so that we can push the branch up
git push --set-upstream origin $CURRENT_BRANCH_NAME
git push
echo "🗒 All done. Ready to create a pull request. Once approved, run npm run release"
fi
11 changes: 7 additions & 4 deletions bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ if ! [ "govuk-patterns-and-tools" == "$NPM_USER" ]; then
exit 1
fi

echo "📦 Publishing packages..."
echo "📦 Publishing package..."

# Try publishing
lerna exec -- $(PWD)/bin/npm-publish.sh
cd package
npm publish
echo "🗒 Package published!"
cd ..

# Extract tag version from all/package.json
ALL_PACKAGE_VERSION=$(node -p "require('./packages/all/package.json').version")
# Extract tag version from ./package/package.json
ALL_PACKAGE_VERSION=$(node -p "require('./package/package.json').version")
TAG="v$ALL_PACKAGE_VERSION"
LATEST_PUBLISHED_TAG=$(git describe --abbrev=0 --tags)

Expand Down
2 changes: 1 addition & 1 deletion config/paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"layouts": "app/views/layouts/",
"config": "config/",
"dist": "dist/",
"packages": "packages/",
"package": "package/",
"public": "public/",
"src": "src/",
"ports": {
Expand Down
4 changes: 0 additions & 4 deletions docs/coding-standards/css.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ System.

Modifying these styles should be safe and have no side effects.

This layer:
- is distributed as individual packages within the @govuk-frontend scope for
each component.

Any classes generated by this layer will use the prefix `govuk-`.

### 7. Overrides
Expand Down
2 changes: 1 addition & 1 deletion docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ issue fixed
- chore (updating gulp tasks etc; no production code change)

### scope:
thing being changed - e.g. component name, packages, gulp
thing being changed - e.g. component name, package, gulp
10 changes: 5 additions & 5 deletions docs/development-and-publish-tasks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NPM and Gulp tasks

This application used a number of a number of NPM scripts that run the application and trigger gulp tasks that build files, update packages, copy assets and watch for changes.
This application used a number of a number of NPM scripts that run the application and trigger gulp tasks that build files, update the package, copy assets and watch for changes.

## Express app only

Expand Down Expand Up @@ -31,14 +31,14 @@ There are a few npm scripts in `package.json` that trigger a number of gulp task
- compiles CSS & JS
- starts up Express

**`npm run build:packages` will do the following:**
**`npm run build:package` will do the following:**
- compile component nunjucks to HTML
- copy template, macro and component.njk files for each component
- copy Sass files, add vendor prefixes and replace path to be node_modules consumption compliant
- split icons out from globals/icons into a separate package (packages/icons)
- split icons out from globals/icons into a separate package (package/icons)
- create an "all" package for Sass
- generate README markdown files
- runs `npm run test:build:packages` (which will test the output is correct)
- runs `npm run test:build:package` (which will test the output is correct)

**`npm run build:dist` will do the following:**
- copy JS
Expand All @@ -47,7 +47,7 @@ There are a few npm scripts in `package.json` that trigger a number of gulp task
- compile component nujucks files to HTML
- generate README markdown files
- take version from 'all/package.json' and append it to compiled & minified JS and CSS files
- runs `npm run test:dist:packages` (which will test the output is correct)
- runs `npm run test:dist:package` (which will test the output is correct)

## Gulp tasks

Expand Down
Binary file removed docs/img/lerna-confirm-publish.png
Binary file not shown.
Binary file removed docs/img/lerna-select-version.png
Binary file not shown.
53 changes: 25 additions & 28 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,57 +78,54 @@ See [development and publishing tasks](development-and-publish-tasks.md) for mor

Application modules and helpers.

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

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

- `all/`
- `src/`

Consume all of govuk-frontend through a single package.
Source files.

- `globals/`

All packages depend on this package, it contains shared dependencies of all components (e.g. colours, font-face, media queries, typography and vars).

- `[component-name]/`

Individual packages - these depend on each other (dependencies are listed in package.json) and also the globals package.

- `CHANGELOG.md`
Generic scripts, style definitions and mixins.

Changes made to a package listed per version.
- `icons/`

- `LICENSE`
Image assets.

Package license.
- `[component-name]/`

- `README.md`
Component-specific source files.

- `CHANGELOG.md`

Package README showing the basic API and usage instructions.
Changes made to a package listed per release version.

- `package.json`
- `LICENSE`

npm definition for a package; states package dependencies.
Package license.

- `src/`
- `README.md`

Source files.
Package README showing the basic API and usage instructions.

- `all/`
- `package.json`

Import all scripts and styles.
npm definition for a package; states package dependencies.

- `globals/`
- `govuk-frontend.scss`

Generic scripts, style definitions and mixins.
Main Sass file that imports all partials

- `icons/`
- `govuk-frontend-ie8.scss`

Image assets.
Internet Explorer 8 specific Sass file that imports `govuk-frontend.scss`

- `[component-name]/`
- `govuk-frontend.js`

Component-specific source files.
Main Javascript file that imports all component specific .js files

- `tasks/`

Expand Down
Loading