Skip to content

Commit 5d526bd

Browse files
authored
chore: Fix package build scripts for git-deps and npm-link symlinks (#746)
## Background This PR is copied from #481. It was contributed by @jasonkarns a couple of years ago. I just pulled his changes, merged master and resolved conflicts. ## Summary Main change: `prepublishOnly` is the wrong lifecycle script for building/compiling. prepublishOnly does not run during install for git-deps; nor does it run when a package is being symlinked via npm-link. The correct script is `prepare`. This PR: - ensures the build/bundle/compile script is accurately defined as `build` so as to be run properly by the top level `lerna run build` script. - ensures "clean" is run before building - ensures `clean` is defined and exposed such that `lerna run clean` works properly - ensures `build` is invoked during `prepare` lifecycle hook (packing, publishing, git-installing, npm-linking) - preserves `npm test` being run during `prepublishOnly` - adds package tarball pattern to gitignore so npm-pack can be run for inspection - removes unnecessary files from `package.json#files` array (license, changelog, readme, and package.json files are included automatically) - renames CHANGELOG.MD to be cased properly ## Test plan No code changes
1 parent 8eedd63 commit 5d526bd

File tree

10 files changed

+33
-37
lines changed

10 files changed

+33
-37
lines changed

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
.DS_STORE
1+
node_modules/
2+
/packages/*/optimizely-*.tgz
3+
24
npm-debug.log
3-
dist
4-
node_modules
55
lerna-debug.log
66

77
coverage/
8+
dist/
89

10+
# user-specific ignores ought to be defined in user's `core.excludesfile`
911
.idea/*
12+
.DS_STORE

packages/datafile-manager/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
"test": "__test__"
2121
},
2222
"files": [
23-
"lib",
24-
"LICENSE",
25-
"CHANGELOG",
26-
"README.md",
27-
"package.json"
23+
"lib"
2824
],
2925
"publishConfig": {
3026
"access": "public"
@@ -61,10 +57,13 @@
6157
}
6258
},
6359
"scripts": {
60+
"clean": "rm -rf lib",
6461
"lint": "tsc --noEmit && eslint --fix 'src/**/*.ts' '__test__/**/*.ts'",
6562
"test": "jest",
6663
"posttest": "npm run lint",
67-
"tsc": "rm -rf lib && tsc",
68-
"prepublishOnly": "npm run lint && npm test && npm run tsc"
64+
"prebuild": "npm run clean",
65+
"build": "tsc",
66+
"prepare": "npm run build",
67+
"prepublishOnly": "npm test"
6968
}
7069
}

packages/event-processor/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
"test": "test"
1414
},
1515
"files": [
16-
"lib",
17-
"LICENSE",
18-
"CHANGELOG",
19-
"README.md",
20-
"package.json"
16+
"lib"
2117
],
2218
"scripts": {
23-
"tsc": "rm -rf lib && tsc",
19+
"clean": "rm -rf lib",
20+
"prebuild": "npm run clean",
21+
"build": "tsc",
2422
"test": "jest",
25-
"prepublishOnly": "jest && npm run tsc"
23+
"prepare": "npm run build",
24+
"prepublishOnly": "npm test"
2625
},
2726
"repository": {
2827
"type": "git",
File renamed without changes.

packages/logging/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
"test": "test"
1313
},
1414
"files": [
15-
"lib",
16-
"LICENSE",
17-
"CHANGELOG",
18-
"README.md",
19-
"package.json"
15+
"lib"
2016
],
2117
"scripts": {
22-
"tsc": "rm -rf lib && tsc",
18+
"clean": "rm -rf lib",
19+
"prebuild": "npm run clean",
20+
"build": "tsc",
2321
"test": "jest",
24-
"prepublishOnly": "jest && npm run tsc"
22+
"prepare": "npm run build",
23+
"prepublishOnly": "npm test"
2524
},
2625
"repository": {
2726
"type": "git",

packages/optimizely-sdk/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"cover": "nyc report -r lcov",
2424
"precoveralls": "npm run cover",
2525
"coveralls": "< coverage/lcov.info coveralls",
26-
"prepublishOnly": "npm run build && npm test && npm run test-xbrowser && npm run test-umdbrowser"
26+
"prepare": "npm run build",
27+
"prepublishOnly": "npm test && npm run test-ci"
2728
},
2829
"repository": {
2930
"type": "git",
@@ -87,11 +88,7 @@
8788
},
8889
"files": [
8990
"dist/",
90-
"lib/",
91-
"LICENSE",
92-
"CHANGELOG",
93-
"README.md",
94-
"package.json"
91+
"lib/"
9592
],
9693
"nyc": {
9794
"temp-dir": "coverage/raw"
File renamed without changes.

packages/utils/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
"test": "test"
1313
},
1414
"files": [
15-
"lib",
16-
"LICENSE",
17-
"CHANGELOG",
18-
"README.md",
19-
"package.json"
15+
"lib"
2016
],
2117
"scripts": {
22-
"tsc": "rm -rf lib && tsc",
18+
"clean": "rm -rf lib",
19+
"prebuild": "npm run clean",
20+
"build": "tsc",
2321
"test": "jest",
24-
"prepublishOnly": "jest && npm run tsc"
22+
"prepare": "npm run build",
23+
"prepublishOnly": "npm test"
2524
},
2625
"repository": {
2726
"type": "git",

0 commit comments

Comments
 (0)