Skip to content

Commit

Permalink
fix(build): Publish only dist folder
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The structure of published packaged changed, but it should not affect public APIs
  • Loading branch information
gund committed Nov 5, 2017
1 parent 49f6414 commit 878d6b8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 10 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"commit": "git-cz",
"prepublish": "npm run build",
"build": "node scripts/build.js",
"build:release": "node scripts/release.js",
"pretest": "npm run cleancoverage",
"test": "karma start",
"pretest:once": "npm run cleancoverage",
Expand All @@ -18,7 +19,8 @@
"cleancoverage": "rimraf coverage",
"check-coverage": "istanbul check-coverage --functions 75 --lines 75 --branches 75 --statements 75",
"ci": "npm run test:once && npm run check-coverage",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"presemantic-release": "npm run build:release",
"semantic-release": "semantic-release pre && npm publish dist && semantic-release post"
},
"keywords": [
"angular",
Expand Down Expand Up @@ -52,6 +54,7 @@
"codecov": "^2.1.0",
"codelyzer": "^3.2.1",
"commitizen": "^2.9.6",
"copyfiles": "^1.2.0",
"cz-conventional-changelog": "^2.0.0",
"istanbul": "^0.4.5",
"jasmine-core": "^2.5.2",
Expand Down
40 changes: 40 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { writeFileSync } = require('fs')
const copyfiles = require('copyfiles')

writeNewPackage('dist/package.json')
copyFiles({
files: [
'README.MD',
'LICENSE',
'.npmignore',
'yarn.lock',
],
to: 'dist',
})

function writeNewPackage(to) {
const package = require('../package.json')

const pathKeys = ['main', 'typings', 'module', 'es2015']
pathKeys.forEach(k => package[k] = updatePath(package[k]))

delete package.scripts
delete package.devDependencies

console.log(`Writing new package.json to ${to}...`)
writeFileSync(
to,
JSON.stringify(package, null, ' '),
'utf-8')
console.log('OK')
}

function copyFiles({ files, to }) {
console.log(`Copying files to ${to} [${files.join(', ')}]`)
copyfiles([...files, to], {}, () => null)
console.log('OK')
}

function updatePath(path) {
return path.replace('dist/', '')
}
40 changes: 31 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# yarn lockfile v1


"@angular/common@^5.0.0-rc.3":
"@angular/common@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@angular/common/-/common-5.0.0.tgz#f96d66a517b995d1ba9b28309f15c2e359675825"
dependencies:
tslib "^1.7.1"

"@angular/compiler-cli@^5.0.0-rc.3":
"@angular/compiler-cli@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-5.0.0.tgz#0ecbb937d84a4f8dd94f0c2a47b07d2e4694c853"
dependencies:
Expand All @@ -17,31 +17,31 @@
reflect-metadata "^0.1.2"
tsickle "^0.24.0"

"@angular/compiler@^5.0.0-rc.3":
"@angular/compiler@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-5.0.0.tgz#b9ffbf18c8a39d8b7dacec473193a90e24cc2bc9"
dependencies:
tslib "^1.7.1"

"@angular/core@^5.0.0-rc.3":
"@angular/core@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@angular/core/-/core-5.0.0.tgz#4f976a225f7dddf34992f2cad824c9543a46f4c8"
dependencies:
tslib "^1.7.1"

"@angular/platform-browser-dynamic@^5.0.0-rc.3":
"@angular/platform-browser-dynamic@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-5.0.0.tgz#887e106c8b103b0415cf6156a425da6d83f4c89d"
dependencies:
tslib "^1.7.1"

"@angular/platform-browser@^5.0.0-rc.3":
"@angular/platform-browser@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@angular/platform-browser/-/platform-browser-5.0.0.tgz#c7038f7cde80705b62014897231e182eec976fed"
dependencies:
tslib "^1.7.1"

"@angular/platform-server@^5.0.0-rc.3":
"@angular/platform-server@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@angular/platform-server/-/platform-server-5.0.0.tgz#877d25ef814af92fffc7b0b523b971a6ff222018"
dependencies:
Expand Down Expand Up @@ -1178,6 +1178,17 @@ copy-descriptor@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"

copyfiles@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/copyfiles/-/copyfiles-1.2.0.tgz#a8da3ac41aa2220ae29bd3c58b6984294f2c593c"
dependencies:
glob "^7.0.5"
ltcdr "^2.2.1"
minimatch "^3.0.3"
mkdirp "^0.5.1"
noms "0.0.0"
through2 "^2.0.1"

core-js@^2.2.0, core-js@^2.4.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e"
Expand Down Expand Up @@ -3555,6 +3566,10 @@ lru-cache@^4.0.1:
pseudomap "^1.0.2"
yallist "^2.1.2"

ltcdr@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ltcdr/-/ltcdr-2.2.1.tgz#5ab87ad1d4c1dab8e8c08bbf037ee0c1902287cf"

map-cache@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
Expand Down Expand Up @@ -3861,6 +3876,13 @@ node-uuid@~1.4.7:
version "1.4.8"
resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907"

noms@0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859"
dependencies:
inherits "^2.0.1"
readable-stream "~1.0.31"

nopt@3.x, nopt@~3.0.1:
version "3.0.6"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
Expand Down Expand Up @@ -4552,7 +4574,7 @@ readable-stream@^2.2.2:
string_decoder "~1.0.0"
util-deprecate "~1.0.1"

readable-stream@~1.0.2:
readable-stream@~1.0.2, readable-stream@~1.0.31:
version "1.0.34"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c"
dependencies:
Expand Down Expand Up @@ -5505,7 +5527,7 @@ through2@2.0.1, through2@^2.0.0:
readable-stream "~2.0.0"
xtend "~4.0.0"

through2@^2.0.2:
through2@^2.0.1, through2@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
dependencies:
Expand Down

0 comments on commit 878d6b8

Please sign in to comment.