Skip to content

Commit 67816f2

Browse files
Henrikof
Henri
authored andcommitted
Improve publishing experience (#998)
* Add publish scripts * Make prettier format package.json inside packages * Create script for getting the changes for the current lerna version * Add git tag command * Don't push changes and don't tag the version by lerna * Make versions exact * Remove beta release script and remove explicit version of alpha release scripts * Remove allow branch for now * Remove version hook for individual packages and replace it with global version hook * - Remove version hook for individual packages and replace it with global version hook - Add script for updating the git tag * Add empty changelogs for previous alphas * Revert lerna.json changes * Start on proper Changelog for alphas * Add script for updating changelog * Add missing changes for previous alpha versions * Remove readme * Remove readme * Add readme.md again
1 parent d1ebb75 commit 67816f2

File tree

43 files changed

+181
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+181
-33
lines changed

Diff for: .prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dist/
44
tmp/
55
*.html
66
# npm install does it's own formatting, which can conflict with prettier
7-
package*.json
7+
package.json
8+
!packages/**/package.json

Diff for: changelog.md

+77-10

Diff for: package.json

+17-3
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,35 @@
66
],
77
"scripts": {
88
"build": "lerna run build",
9+
910
"check:all": "yarn check:flow && yarn check:ts && yarn check:snapshots && yarn check:lint",
1011
"check:flow": "flow check --max-warnings=0",
1112
"check:ts": "tsc",
1213
"check:snapshots": "lerna run check-snapshot",
1314
"check:lint": "eslint scripts/ packages/ docs/ --ext js,md",
14-
"prepublish-packages": "yarn check:all && yarn format:ci && yarn test",
15-
"publish-packages": "lerna publish",
15+
1616
"format": "prettier \"*.{js,md,json}\" \"{docs,packages,scripts}/**/*.{js,md,json}\" --write",
1717
"format:ci": "yarn format -- --list-different",
18+
1819
"test": "karma start --single-run",
1920
"test:watch": "karma start",
2021
"posttest": "[ -z \"$TRAVIS\" ] || codecov",
2122
"codecov": "codecov",
2223
"bench": "cross-env BENCHMARK=true karma start --single-run",
23-
"pre-commit": "lint-staged && yarn check:all"
24+
25+
"pre-commit": "lint-staged && yarn check:all",
26+
27+
"---Release Scripts---": "",
28+
"version": "yarn build && yarn test && node ./scripts/update-changelog && node ./scripts/add-git-files",
29+
"prerelease": "yarn check:all && yarn format:ci",
30+
"release": "lerna publish --no-push --exact",
31+
"postrelease": "node ./scripts/create-git-tag && git push --tags",
32+
"release:patch": "yarn release patch --dist-tag latest",
33+
"release:minor": "yarn release minor --dist-tag latest",
34+
"release:major": "yarn release major --dist-tag latest",
35+
"release:alpha:patch": "yarn release --dist-tag next",
36+
"release:alpha:minor": "yarn release --dist-tag next",
37+
"release:alpha:major": "yarn release --dist-tag next"
2438
},
2539
"lint-staged": {
2640
"**/*.{js,md,json,ts}": [

Diff for: packages/jss-plugin-cache/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"scripts": {
3737
"build": "node ../../scripts/build.js",
38-
"postversion": "yarn build",
3938
"check-snapshot": "node ../../scripts/match-snapshot.js"
4039
},
4140
"dependencies": {

Diff for: packages/jss-plugin-camel-case/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
],
3535
"scripts": {
3636
"build": "node ../../scripts/build.js",
37-
"postversion": "yarn build",
3837
"check-snapshot": "node ../../scripts/match-snapshot.js"
3938
},
4039
"devDependencies": {

Diff for: packages/jss-plugin-compose/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"scripts": {
3737
"build": "node ../../scripts/build.js",
38-
"postversion": "yarn build",
3938
"check-snapshot": "node ../../scripts/match-snapshot.js"
4039
},
4140
"dependencies": {

Diff for: packages/jss-plugin-default-unit/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
],
3737
"scripts": {
3838
"build": "node ../../scripts/build.js",
39-
"postversion": "yarn build",
4039
"check-snapshot": "node ../../scripts/match-snapshot.js"
4140
},
4241
"devDependencies": {

Diff for: packages/jss-plugin-expand/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
],
3535
"scripts": {
3636
"build": "node ../../scripts/build.js",
37-
"postversion": "yarn build",
3837
"check-snapshot": "node ../../scripts/match-snapshot.js"
3938
},
4039
"devDependencies": {

Diff for: packages/jss-plugin-extend/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
],
3535
"scripts": {
3636
"build": "node ../../scripts/build.js",
37-
"postversion": "yarn build",
3837
"check-snapshot": "node ../../scripts/match-snapshot.js"
3938
},
4039
"devDependencies": {

Diff for: packages/jss-plugin-global/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"scripts": {
3737
"build": "node ../../scripts/build.js",
38-
"postversion": "yarn build",
3938
"check-snapshot": "node ../../scripts/match-snapshot.js"
4039
},
4140
"devDependencies": {

Diff for: packages/jss-plugin-isolate/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"scripts": {
3737
"build": "node ../../scripts/build.js",
38-
"postversion": "yarn build",
3938
"check-snapshot": "node ../../scripts/match-snapshot.js"
4039
},
4140
"dependencies": {

Diff for: packages/jss-plugin-nested/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"scripts": {
3737
"build": "node ../../scripts/build.js",
38-
"postversion": "yarn build",
3938
"check-snapshot": "node ../../scripts/match-snapshot.js"
4039
},
4140
"devDependencies": {

Diff for: packages/jss-plugin-props-sort/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"scripts": {
3737
"build": "node ../../scripts/build.js",
38-
"postversion": "yarn build",
3938
"check-snapshot": "node ../../scripts/match-snapshot.js"
4039
},
4140
"dependencies": {

Diff for: packages/jss-plugin-rule-value-function/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
],
4242
"scripts": {
4343
"build": "node ../../scripts/build.js",
44-
"postversion": "yarn build",
4544
"check-snapshot": "node ../../scripts/match-snapshot.js"
4645
},
4746
"dependencies": {

Diff for: packages/jss-plugin-rule-value-observable/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
],
4141
"scripts": {
4242
"build": "node ../../scripts/build.js",
43-
"postversion": "yarn build",
4443
"check-snapshot": "node ../../scripts/match-snapshot.js"
4544
},
4645
"dependencies": {

Diff for: packages/jss-plugin-template/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
],
3535
"scripts": {
3636
"build": "node ../../scripts/build.js",
37-
"postversion": "yarn build",
3837
"check-snapshot": "node ../../scripts/match-snapshot.js"
3938
},
4039
"dependencies": {

Diff for: packages/jss-plugin-vendor-prefixer/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
],
3434
"scripts": {
3535
"build": "node ../../scripts/build.js",
36-
"postversion": "yarn build",
3736
"check-snapshot": "node ../../scripts/match-snapshot.js"
3837
},
3938
"dependencies": {

Diff for: packages/jss-preset-default/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
],
3232
"scripts": {
3333
"build": "node ../../scripts/build.js",
34-
"postversion": "yarn build",
3534
"check-snapshot": "node ../../scripts/match-snapshot.js"
3635
},
3736
"dependencies": {

Diff for: packages/jss-starter-kit/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
],
3838
"scripts": {
3939
"build": "node ../../scripts/build.js",
40-
"postversion": "yarn build",
4140
"check-snapshot": "node ../../scripts/match-snapshot.js"
4241
},
4342
"dependencies": {

Diff for: packages/jss/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
],
3838
"scripts": {
3939
"build": "node ../../scripts/build.js",
40-
"postversion": "yarn build",
4140
"check-snapshot": "node ../../scripts/match-snapshot.js"
4241
},
4342
"dependencies": {

Diff for: packages/react-jss/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"scripts": {
3737
"build": "node ../../scripts/build.js",
38-
"postversion": "yarn build",
3938
"check-snapshot": "node ../../scripts/match-snapshot.js"
4039
},
4140
"peerDependencies": {

Diff for: scripts/add-git-files.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const shell = require('shelljs')
2+
3+
const {README_FILENAME, CHANGELOG_FILENAME} = require('./constants')
4+
5+
function addFiles(files) {
6+
const {code} = shell.exec(`git add ${files}`)
7+
8+
if (code !== 0) {
9+
shell.exit(code)
10+
}
11+
}
12+
13+
addFiles('packages/*/.size-snapshot.json')
14+
addFiles(`packages/*/${README_FILENAME}`)
15+
addFiles(CHANGELOG_FILENAME)

Diff for: scripts/constants.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const README_FILENAME = 'readme.md'
2+
const CHANGELOG_FILENAME = 'changelog.md'
3+
4+
module.exports = {
5+
README_FILENAME,
6+
CHANGELOG_FILENAME
7+
}

Diff for: scripts/create-git-tag.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const fs = require('fs')
2+
const shell = require('shelljs')
3+
4+
const lerna = require('../lerna')
5+
const {CHANGELOG_FILENAME} = require('./constants')
6+
7+
function getChangelog() {
8+
const content = fs.readFileSync(`../${CHANGELOG_FILENAME}`, 'utf-8')
9+
10+
const lines = content.split('\n')
11+
let hasStarted = false
12+
let hasFinished = false
13+
14+
return lines
15+
.filter(line => {
16+
if (hasFinished) {
17+
return false
18+
}
19+
20+
if (hasStarted) {
21+
hasFinished = line.startsWith('## ')
22+
23+
return !hasFinished
24+
}
25+
26+
hasStarted = line.startsWith(`## ${lerna.version}`)
27+
28+
return false
29+
})
30+
.join('\n')
31+
}
32+
33+
const changelog = getChangelog()
34+
const {code} = shell.exec(`git tag v${lerna.version} -f -a -m "${changelog}"`)
35+
36+
if (code !== 0) {
37+
shell.exit(code)
38+
}

Diff for: scripts/create-readme.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs')
22

33
const getPkg = require('./get-package-json')
4+
const {README_FILENAME} = require('./constants')
45

56
const pkg = getPkg()
67

@@ -37,7 +38,7 @@ yarn add ${pkg.name}
3738
`
3839

3940
function createReadme() {
40-
fs.writeFileSync('./README.md', readmeContent)
41+
fs.writeFileSync(README_FILENAME, readmeContent)
4142
}
4243

4344
module.exports = createReadme

0 commit comments

Comments
 (0)