diff --git a/scripts/artifacts.json b/artifacts.json similarity index 100% rename from scripts/artifacts.json rename to artifacts.json diff --git a/package.json b/package.json index 7797f2548..55ff6508a 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,18 @@ "version": "1.0.5", "scripts": { "clean": "shx rm -rf lib lib-esm _doc build release *.log", - "build": "tsc && tsc -m es6 --outDir lib-esm && npm run fixdts", + "compile": "tsc && tsc -m es6 --outDir lib-esm && npm run fixdts", "fixdts": "dts-downlevel 'lib/**/*.d.ts' 'lib-esm/**/*.d.ts'", - "package": "npm run clean && npm run build && npm run bundle", + "fixmaps": "modify_sourcemap_paths", + "build": "npm run clean && npm run compile && npm run bundle && npm run fixmaps", "bundle": "npm run bundle_router && npm run bundle_monolithic_router && npm run bundle_events && npm run bundle_resolve", "bundle_monolithic_router": "rollup -c --environment ROUTER,MONOLITHIC && rollup -c --environment ROUTER,MINIFY,MONOLITHIC", "bundle_router": "rollup -c --environment ROUTER && rollup -c --environment ROUTER,MINIFY", "bundle_events": "rollup -c --environment EVENTS && rollup -c --environment EVENTS,MINIFY", "bundle_resolve": "rollup -c --environment RESOLVE && rollup -c --environment RESOLVE,MINIFY", - "prepare": "npm run package", + "prepare": "npm run build", + "changelog": "update_changelog", + "release": "npm run noimplicitany && node ./scripts/release.js", "install": "node migrate/migratewarn.js", "noimplicitany": "tsc --noEmit --noImplicitAny --moduleResolution node --target es6 test/noimplicitany.ts", "test": "npm run test:integrate", @@ -26,7 +29,7 @@ "debug": "karma start --singleRun=false --autoWatch=true --autoWatchInterval=1 --browsers=Chrome", "docs": "./scripts/docs.js", "publishdocs": "node scripts/publishdocs.js", - "artifacts": "node scripts/artifact_tagging.js" + "artifacts": "artifact_tagging" }, "homepage": "https://ui-router.github.io", "contributors": [ @@ -80,6 +83,7 @@ "@types/angular-mocks": "^1.5.5", "@types/jasmine": "^2.2.34", "@types/jquery": "^1.10.31", + "@uirouter/publish-scripts": "^1.0.4", "awesome-typescript-loader": "3.0.0-beta.10", "babel-core": "^5.8.14", "clone": "^1.0.2", diff --git a/scripts/artifact_tagging.js b/scripts/artifact_tagging.js deleted file mode 100755 index 96ab13e77..000000000 --- a/scripts/artifact_tagging.js +++ /dev/null @@ -1,109 +0,0 @@ -#!env node -"use strict"; - -const CONFIG = require('./artifacts.json'); -const COMMIT_ARTIFACTS = CONFIG.ARTIFACTS; - -let shx = require('shelljs'); -let readlineSync = require('readline-sync'); -let fs = require('fs'); -let path = require('path'); -let util = require('./util'); -let _exec = util._exec; - -let pkg = require('../package.json'); -let version = pkg.version; - -shx.cd(path.join(__dirname, '..')); - -var widen = false, npm = false, githubtag = false; -var coreDep = pkg.dependencies['@uirouter/core']; -var isNarrow = /^[[=~]?(\d.*)/.exec(coreDep); -var widenedDep = isNarrow && '^' + isNarrow[1]; - -if (isNarrow && readlineSync.keyInYN('Widen @uirouter/core dependency from ' + coreDep + ' to ' + widenedDep + '?')) { - widen = false; -} - -if (readlineSync.keyInYN('Publish to NPM')) { - npm = true; -} - - -if (readlineSync.keyInYN('publish to Github Tag?')) { - githubtag = true; -} - -if (!npm && !githubtag) { - process.exit(1); -} - -var label = githubtag && npm ? "npm package and github tag" : npm ? "npm package" : "github tag"; - -const YYYYMMDD = (function() { - var date = new Date(); - var year = date.getFullYear(); - - var month = date.getMonth() + 1; - month = (month < 10 ? "0" : "") + month; - - var day = date.getDate(); - day = (day < 10 ? "0" : "") + day; - - return year + month + day; -})(); - -let tagname = `SNAPSHOT-${YYYYMMDD}`; -let pkgver = `-SNAPSHOT.${YYYYMMDD}`; - -if (githubtag) { - tagname += readlineSync.question(`Suffix for tag ${tagname} (optional)?`); -} - -if (npm) { - pkgver += readlineSync.question(`Suffix for package version ${pkgver} (optional)?`); -} - -if (!readlineSync.keyInYN(`Ready to publish ${label}?`)) { - process.exit(1); -} - -util.ensureCleanMaster('master'); - -// then tag and push tag -_exec(`git checkout -b ${tagname}-prep`); - -pkg.dependencies['@uirouter/core'] = widenedDep; -pkg.version += pkgver; - -fs.writeFileSync("package.json", JSON.stringify(pkg, undefined, 2)); -_exec(`git commit -m "Widening @uirouter/core dependency range to ${widenedDep}" package.json`); - -_exec(`npm run package`); - -if (npm) { - let output = _exec(`npm dist-tag ls ${pkg.name}`).stdout; - let latest = output.split(/[\r\n]/) - .map(line => line.split(": ")) - .filter(linedata => linedata[0] === 'latest')[0]; - - if (!latest) { - throw new Error(`Could not determine value of "latest" dist-tag for ${pkg.name}`); - } - - _exec(`npm publish`); - _exec(`npm dist-tag add ${pkg.name}@${latest} latest`); -} - -if (githubtag) { - _exec(`git add --force ${COMMIT_ARTIFACTS.join(' ')}`); - _exec(`git rm yarn.lock`); - - _exec(`git commit -m 'chore(*): commiting build files'`); - _exec(`git tag ${tagname}`); - _exec(`git push -u origin ${tagname}`); -} - -_exec(`git checkout master`); -_exec(`git branch -D ${tagname}-prep`); - diff --git a/scripts/ensure_clean_master.js b/scripts/ensure_clean_master.js deleted file mode 100755 index a0cfbcec0..000000000 --- a/scripts/ensure_clean_master.js +++ /dev/null @@ -1,5 +0,0 @@ -#!env node -if(require.main === module && process.argv[2]) - branch = process.argv[2]; - -require('./util').ensureCleanMaster(branch); diff --git a/scripts/release.js b/scripts/release.js index f8e0ed25a..4af9e81a3 100755 --- a/scripts/release.js +++ b/scripts/release.js @@ -7,7 +7,7 @@ require('shelljs/global'); let readlineSync = require('readline-sync'); let fs = require('fs'); let path = require('path'); -let util = require('./util'); +let util = require('@uirouter/publish-scripts/util'); let _exec = util._exec; cd(path.join(__dirname, '..')); @@ -30,7 +30,7 @@ if (!readlineSync.keyInYN('Ready to publish?')) { util.ensureCleanMaster('master'); -_exec('npm run package'); +_exec('npm run build'); _exec(`npm run docs`); console.log('Updating version in bower.json to ${version}'); diff --git a/scripts/show_changelog.js b/scripts/show_changelog.js deleted file mode 100755 index 6c6c218be..000000000 --- a/scripts/show_changelog.js +++ /dev/null @@ -1,28 +0,0 @@ -#!env node -"use strict"; -let conventionalChangelog = require('conventional-changelog'); - -let options = { - preset: 'angular' -}; - -if(require.main === module) { - let context, gitOpts; - - if (process.argv[2]) { - context = {}; - gitOpts = {}; - context.previousTag = process.argv[2]; - gitOpts.from = process.argv[2]; - } - - if (process.argv[3]) { - context.currentTag = process.argv[3]; - } - - showChangelog(context, gitOpts); -} - -function showChangelog(context, gitOpts) { - conventionalChangelog(options, context, gitOpts).pipe(process.stdout); -} diff --git a/scripts/show_core_changelog.js b/scripts/show_core_changelog.js deleted file mode 100755 index 78ef3b2d4..000000000 --- a/scripts/show_core_changelog.js +++ /dev/null @@ -1,69 +0,0 @@ -#!env node -"use strict"; - -var gitSemverTags = require('git-semver-tags'); -var shelljs = require('shelljs'); -var path = require('path'); -var fs = require('fs'); - -var CORE_PKG = `@uirouter/core`; -var ALT_CORE_PKG = `ui-router-core`; -var CORE_DIR = path.join(__dirname, "..", "..", 'core'); -var SHOWCHANGELOG_SCRIPT = path.join(CORE_DIR, "scripts", "show_changelog.js"); - -var currentPackage = require('../package.json'); -if (!currentPackage.dependencies || (!currentPackage.dependencies[CORE_PKG] && !currentPackage[ALT_CORE_PKG])) { - console.error(stringify(currentPackage.dependencies)); - throw new Error("No dependency on " + CORE_PKG + " found in package.json.") -} - -if (!fs.existsSync(CORE_DIR)) { - throw new Error(CORE_PKG + " not found at " + path.resolve(CORE_DIR)); -} - -if (!fs.existsSync(SHOWCHANGELOG_SCRIPT)) { - throw new Error("show_changelog.js not found at " + path.resolve(SHOWCHANGELOG_SCRIPT)); -} - -shelljs.config.silent = true; -gitSemverTags(function (err, val) { - var fromTag; - if (require.main === module && process.argv[2]) { - fromTag = process.argv[2]; - } else { - var prevRaw = shelljs.exec('git show ' + val[0] + ':package.json', {silent:true}).stdout; - var prevPackage; - try { - prevPackage = JSON.parse(prevRaw); - } catch (error) { - console.error("Unable to parse previous package.json in ${val[0]}"); - console.error(prevRaw); - throw error; - } - - if (!prevPackage.dependencies) { - console.error(stringify(prevPackage)); - throw new Error(`previous package.json in ${val[0]} has no "dependencies" key.`); - } else if (!prevPackage.dependencies[CORE_PKG] && !prevPackage.dependencies[ALT_CORE_PKG]) { - console.error(stringify(prevPackage.dependencies)); - throw new Error(`previous package.json in ${val[0]} has no "dependencies['${CORE_PKG}']" key.`); - } - - var prevDep = prevPackage.dependencies[CORE_PKG] || prevPackage.dependencies[ALT_CORE_PKG]; - fromTag = prevDep.replace(/[=~^]/, ""); - } - - let pkg = require("../package.json"); - let currentDep = pkg.dependencies[CORE_PKG] || pkg.dependencies[ALT_CORE_PKG]; - var toTag = currentDep.replace(/[=~^]/g, ""); - - shelljs.pushd(CORE_DIR); - // console.log("node " + SHOWCHANGELOG_SCRIPT + " " + fromTag + " " + toTag) - shelljs.config.silent = false; - shelljs.exec("node " + SHOWCHANGELOG_SCRIPT + " " + fromTag + " " + toTag) -}); - - -function stringify(object) { - return JSON.stringify(object, null, 2); -} \ No newline at end of file diff --git a/scripts/update_changelog.js b/scripts/update_changelog.js deleted file mode 100755 index ce6186443..000000000 --- a/scripts/update_changelog.js +++ /dev/null @@ -1,15 +0,0 @@ -#!env node -"use strict"; - -require('shelljs/global'); -let path = require('path'); -let _exec = require('./util')._exec; - -cd(path.resolve(__dirname, '..')); - -echo('Updating CHANGELOG...'); -cp('CHANGELOG.md', 'CHANGELOG.bak'); -_exec('node ./scripts/show_changelog.js >> CHANGELOG.new'); -_exec('node ./scripts/show_core_changelog.js >> CHANGELOG.new'); -_exec('cat CHANGELOG.new CHANGELOG.bak > CHANGELOG.md'); -rm('CHANGELOG.bak', 'CHANGELOG.new'); diff --git a/scripts/util.js b/scripts/util.js deleted file mode 100755 index 89b76f3cf..000000000 --- a/scripts/util.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; - -require('shelljs/global'); -let fs = require('fs'); - -function ensureCleanMaster(branch) { - branch = branch || 'master'; - if (exec('git symbolic-ref HEAD').stdout.trim() !== `refs/heads/${branch}`) - throw new Error(`Not on ${branch} branch, aborting`); - if (exec('git status --porcelain').stdout.trim() !== '') - throw new Error('Working copy is dirty, aborting'); -} - -function _exec(command) { - echo(command); - echo(); - var result = exec(command); - if (result.code === 0) return result; - echo(`Aborting; non-zero return value (${result.code}) from: ${command}`); - exit(result.code) -} - -function asJson (obj) { return JSON.stringify(obj, null, 2); } - -let ensure = (type) => (path) => { - let is = false; - try { is = fs.lstatSync(path)['is' + type](); } catch (e) { console.log(e); } - if (!is) echo(`Not a ${type}: ${path}`) && exit(-3); -}; -let assertDir = ensure('Directory'); -let assertFile = ensure('File'); - -module.exports = { - ensureCleanMaster: ensureCleanMaster, - _exec: _exec, - asJson: asJson, - assertDir: assertDir, - assertFile: assertFile -}; diff --git a/yarn.lock b/yarn.lock index 64bc241fd..bd961c6dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -62,9 +62,20 @@ dependencies: "@types/node" "*" -"@uirouter/core@5.0.5": - version "5.0.5" - resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-5.0.5.tgz#4fafae8b89e1bee321b0ed32e69ab66547c055c6" +"@uirouter/core@^5.0.6": + version "5.0.6" + resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-5.0.6.tgz#251e1fc4d6ce8fe47e374bb86971e68a2ef1b323" + +"@uirouter/publish-scripts@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@uirouter/publish-scripts/-/publish-scripts-1.0.4.tgz#12de0110b88985cceb5ea0a020810ea8de8ecb38" + dependencies: + conventional-changelog "^1.1.4" + conventional-changelog-ui-router-core "file:../conventional-changelog-ui-router-core" + find-parent-dir "^0.3.0" + git-semver-tags "^1.2.1" + readline-sync "^1.4.7" + shelljs "^0.7.8" JSONStream@^1.0.4: version "1.3.1" @@ -868,6 +879,13 @@ conventional-changelog-jshint@^0.1.0: compare-func "^1.3.1" q "^1.4.1" +"conventional-changelog-ui-router-core@file:../conventional-changelog-ui-router-core": + version "1.4.2" + dependencies: + compare-func "^1.3.1" + github-url-from-git "^1.4.0" + q "^1.4.1" + conventional-changelog-writer@^1.1.0: version "1.4.1" resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-1.4.1.tgz#3f4cb4d003ebb56989d30d345893b52a43639c8e" @@ -883,7 +901,7 @@ conventional-changelog-writer@^1.1.0: split "^1.0.0" through2 "^2.0.0" -conventional-changelog@^1.1.0, conventional-changelog@^1.1.3: +conventional-changelog@^1.1.0, conventional-changelog@^1.1.3, conventional-changelog@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-1.1.4.tgz#108bc750c2a317e200e2f9b413caaa1f8c7efa3b" dependencies: @@ -1453,6 +1471,10 @@ finalhandler@1.0.3, finalhandler@~1.0.3: statuses "~1.3.1" unpipe "~1.0.0" +find-parent-dir@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54" + find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -1621,6 +1643,13 @@ git-semver-tags@^1.2.0: meow "^3.3.0" semver "^5.0.1" +git-semver-tags@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-1.2.1.tgz#6ccd2a52e735b736748dc762444fcd9588e27490" + dependencies: + meow "^3.3.0" + semver "^5.0.1" + gitconfiglocal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" @@ -3191,7 +3220,7 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" -readline-sync@^1.4.5: +readline-sync@^1.4.5, readline-sync@^1.4.7: version "1.4.7" resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.7.tgz#001bfdd4c06110c3c084c63bf7c6a56022213f30" @@ -3545,7 +3574,7 @@ shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" -shelljs@^0.7.0: +shelljs@^0.7.0, shelljs@^0.7.8: version "0.7.8" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" dependencies: