diff --git a/package.json b/package.json index a02d163e7..a627c02da 100644 --- a/package.json +++ b/package.json @@ -1,120 +1,111 @@ { - "name": "mobx", - "version": "5.1.2", - "description": "Simple, scalable state management.", - "main": "lib/mobx.js", - "umd:main": "lib/mobx.umd.js", - "module": "lib/mobx.module.js", - "unpkg": "lib/mobx.umd.min.js", - "jsnext:main": "lib/mobx.module.js", - "react-native": "lib/mobx.module.js", - "typings": "lib/mobx.d.ts", - "scripts": { - "test": "yarn jest", - "watch": "yarn jest --watch", - "test:mixed-versions": "jest --testRegex mixed-versions", - "test:all": "yarn small-build && yarn jest -i && yarn test:flow && yarn test:mixed-versions", - "test:webpack": "node scripts/webpack-regression-tests.js", - "test:flow": "node_modules/.bin/flow check", - "test:performance": "npm run small-build && PERSIST=true time node --expose-gc test/perf/index.js", - "test:travis": "yarn test:all && yarn test:performance && yarn test -i --coverage && yarn test:webpack && yarn size", - "prettier": "prettier --write --print-width 100 --tab-width 4 --no-semi \"**/*.js\" \"**/*.jsx\" \"**/*.tsx\" \"**/*.ts\"", - "_prepublish": "npm run small-build", - "quick-build": "tsc --pretty", - "small-build": "node scripts/build.js", - "lint": "tslint -c tslint.json src/*.ts src/types/*.ts src/api/*.ts src/core/*.ts src/utils/*.ts", - "size": "size-limit --babili 20KB lib/mobx.js", - "precommit": "lint-staged" - }, - "repository": { - "type": "git", - "url": "https://github.com/mobxjs/mobx.git" - }, - "author": "Michel Weststrate", - "license": "MIT", - "bugs": { - "url": "https://github.com/mobxjs/mobx/issues" - }, - "files": [ - "lib", - "LICENSE" - ], - "homepage": "https://mobx.js.org/", - "devDependencies": { - "@types/jest": "^21.1.9", - "@types/node": "^7.0.22", - "babel-core": "7.0.0-beta.3", - "babel-jest": "^23.6.0", - "babel-plugin-transform-regenerator": "^6.26.0", - "babel-preset-es2015": "7.0.0-beta.3", - "babel-preset-react": "7.0.0-beta.3", - "babel-preset-stage-1": "7.0.0-beta.3", - "browserify": "^12.0.1", - "chalk": "^1.1.3", - "coveralls": "^2.11.4", - "envify": "^4.1.0", - "flow-bin": "^0.59.0", - "fs-extra": "^3.0.1", - "husky": "^0.14.3", - "iterall": "^1.0.2", - "jest": "^23.6.0", - "lint-staged": "^3.6.1", - "lodash.intersection": "^3.2.0", - "ncp": "^2.0.0", - "nscript": "^0.1.10", - "prettier": "^1.4.4", - "regenerator-runtime": "^0.11.1", - "rollup": "^0.41.6", - "rollup-plugin-filesize": "^1.3.2", - "rollup-plugin-node-resolve": "^3.0.0", - "serializr": "^1.3.0", - "size-limit": "^0.2.0", - "tape": "^4.2.2", - "ts-jest": "^22.0.0", - "tslib": "^1.7.1", - "typescript": "^2.9.0", - "uglify-es": "^3.3.9" - }, - "dependencies": {}, - "keywords": [ - "mobx", - "mobservable", - "observable", - "react-component", - "react", - "reactjs", - "reactive", - "model", - "frp", - "functional-reactive-programming", - "state management", - "data flow" - ], - "lint-staged": { - "*.{ts,tsx,js,jsx}": [ - "prettier --write --print-width 100 --tab-width 4 --no-semi", - "git add" - ] - }, - "jest": { - "transform": { - "^.+\\.tsx?$": "ts-jest", - "^.+\\.jsx?$": "babel-jest" + "name": "mobx", + "version": "5.1.2", + "description": "Simple, scalable state management.", + "main": "lib/mobx.js", + "umd:main": "lib/mobx.umd.js", + "module": "lib/mobx.module.js", + "unpkg": "lib/mobx.umd.min.js", + "jsnext:main": "lib/mobx.module.js", + "react-native": "lib/mobx.module.js", + "typings": "lib/mobx.d.ts", + "scripts": { + "test": "yarn jest", + "watch": "yarn jest --watch", + "test:mixed-versions": "jest --testRegex mixed-versions", + "test:all": + "yarn small-build && yarn jest -i && yarn test:flow && yarn test:mixed-versions", + "test:webpack": "node scripts/webpack-regression-tests.js", + "test:flow": "node_modules/.bin/flow check", + "test:performance": + "npm run small-build && PERSIST=true time node --expose-gc test/perf/index.js", + "test:travis": + "yarn test:all && yarn test:performance && yarn test -i --coverage && yarn test:webpack && yarn size", + "prettier": + "prettier --write --print-width 100 --tab-width 4 --no-semi \"**/*.js\" \"**/*.jsx\" \"**/*.tsx\" \"**/*.ts\"", + "_prepublish": "npm run small-build", + "quick-build": "tsc --pretty", + "small-build": "node scripts/build.js", + "lint": + "tslint -c tslint.json src/*.ts src/types/*.ts src/api/*.ts src/core/*.ts src/utils/*.ts", + "size": "size-limit --babili 20KB lib/mobx.js", + "precommit": "lint-staged" }, - "testRegex": "test/base/.*\\.(t|j)sx?$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "jsx", - "json" - ], - "testPathIgnorePatterns": [ - "/node_modules/", - "/\\./" + "repository": { + "type": "git", + "url": "https://github.com/mobxjs/mobx.git" + }, + "author": "Michel Weststrate", + "license": "MIT", + "bugs": { + "url": "https://github.com/mobxjs/mobx/issues" + }, + "files": ["lib", "LICENSE"], + "homepage": "https://mobx.js.org/", + "devDependencies": { + "@types/jest": "^21.1.9", + "@types/node": "^7.0.22", + "babel-core": "7.0.0-beta.3", + "babel-jest": "^23.6.0", + "babel-plugin-transform-regenerator": "^6.26.0", + "babel-preset-es2015": "7.0.0-beta.3", + "babel-preset-react": "7.0.0-beta.3", + "babel-preset-stage-1": "7.0.0-beta.3", + "browserify": "^12.0.1", + "chalk": "^1.1.3", + "coveralls": "^2.11.4", + "envify": "^4.1.0", + "flow-bin": "^0.59.0", + "fs-extra": "^3.0.1", + "husky": "^0.14.3", + "iterall": "^1.0.2", + "jest": "^23.6.0", + "lint-staged": "^3.6.1", + "lodash.intersection": "^3.2.0", + "ncp": "^2.0.0", + "prettier": "^1.4.4", + "regenerator-runtime": "^0.11.1", + "rollup": "^0.41.6", + "rollup-plugin-filesize": "^1.3.2", + "rollup-plugin-node-resolve": "^3.0.0", + "serializr": "^1.3.0", + "shelljs": "^0.8.2", + "size-limit": "^0.2.0", + "tape": "^4.2.2", + "ts-jest": "^22.0.0", + "tslib": "^1.7.1", + "typescript": "^2.9.0", + "uglify-es": "^3.3.9" + }, + "dependencies": {}, + "keywords": [ + "mobx", + "mobservable", + "observable", + "react-component", + "react", + "reactjs", + "reactive", + "model", + "frp", + "functional-reactive-programming", + "state management", + "data flow" ], - "watchPathIgnorePatterns": [ - "/node_modules/" - ] - } -} \ No newline at end of file + "lint-staged": { + "*.{ts,tsx,js,jsx}": [ + "prettier --write --print-width 100 --tab-width 4 --no-semi", + "git add" + ] + }, + "jest": { + "transform": { + "^.+\\.tsx?$": "ts-jest", + "^.+\\.jsx?$": "babel-jest" + }, + "testRegex": "test/base/.*\\.(t|j)sx?$", + "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json"], + "testPathIgnorePatterns": ["/node_modules/", "/\\./"], + "watchPathIgnorePatterns": ["/node_modules/"] + } +} diff --git a/scripts/publish.js b/scripts/publish.js index 041e23f6b..310de9066 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -1,41 +1,82 @@ -#!node_modules/.bin/nscript -/* To run this script, nscript is needed: [sudo] npm install -g nscript /* Publish.js, publish a new version of the npm package as found in the current directory */ /* Run this file from the root of the repository */ -module.exports = function(shell, npm, git) { + +const shell = require("shelljs") +const fs = require("fs") +const readline = require("readline") + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}) + +function run(command, options) { + const continueOnErrors = options && options.continueOnErrors + const ret = shell.exec(command, options) + if (!continueOnErrors && ret.code !== 0) { + shell.exit(1) + } + return ret +} + +function exit(code, msg) { + console.error(msg) + shell.exit(code) +} + +async function prompt(question, defaultValue) { + return new Promise(resolve => { + rl.question(`${question} [${defaultValue}]: `, resolve) + }) +} + +async function main() { // build - npm("run", "small-build") + run("npm run small-build") - var pkg = JSON.parse(shell.read("package.json")) + const pkg = JSON.parse(fs.readFileSync("package.json", "utf8")) // Bump version number - var nrs = pkg.version.split(".") + let nrs = pkg.version.split(".") nrs[2] = 1 + parseInt(nrs[2], 10) - var version = (pkg.version = shell.prompt( + const version = (pkg.version = await prompt( "Please specify the new package version of '" + pkg.name + "' (Ctrl^C to abort)", nrs.join(".") )) - if (!version.match(/^\d+\.\d+\.\d+$/)) shell.exit(1, "Invalid semantic version: " + version) + if (!version.match(/^\d+\.\d+\.\d+$/)) { + exit(1, "Invalid semantic version: " + version) + } - // Check registery data - if (npm.silent().test("info", pkg.name)) { + // Check registry data + const npmInfoRet = run(`npm info ${pkg.name} --json`, { + continueOnErrors: true, + silent: true + }) + if (npmInfoRet.code === 0) { //package is registered in npm? - var publishedPackageInfo = JSON.parse(npm.get("info", pkg.name, "--json")) + var publishedPackageInfo = JSON.parse(npmInfoRet.stdout) if ( publishedPackageInfo.versions == version || - publishedPackageInfo.versions.indexOf(version) != -1 - ) - shell.exit(2, "Version " + pkg.version + " is already published to npm") + publishedPackageInfo.versions.includes(version) + ) { + exit(2, "Version " + pkg.version + " is already published to npm") + } - shell.write("package.json", JSON.stringify(pkg, null, 2)) + fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2), "utf8") // Finally, commit and publish! - npm("publish") - git("commit", "-am", "Published version " + version) - git("tag", version) + run("npm publish") + run(`git commit -am "Published version ${version}"`) + run(`git tag ${version}`) - git("push") - git("push", "--tags") + run("git push") + run("git push --tags") console.log("Published!") - } else shell.exit(1, pkg.name + " is not an existing npm package") + } else { + exit(1, pkg.name + " is not an existing npm package") + } } + +main().catch(e => { + throw e +}) diff --git a/yarn.lock b/yarn.lock index d0d383115..daf6fa8d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1311,13 +1311,6 @@ boxen@^1.1.0: term-size "^1.2.0" widest-line "^2.0.0" -brace-expansion@^1.0.0: - version "1.1.8" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1708,10 +1701,6 @@ color-name@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" -colors@^1.0.3: - version "1.1.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" - colors@^1.1.2: version "1.3.0" resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.0.tgz#5f20c9fef6945cb1134260aab33bfbdc8295e04e" @@ -1731,10 +1720,6 @@ combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5: dependencies: delayed-stream "~1.0.0" -commander@^2.6.0: - version "2.11.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" - commander@^2.9.0: version "2.15.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" @@ -2506,10 +2491,6 @@ fb-watchman@^2.0.0: dependencies: bser "^2.0.0" -fibers@^1.0.2: - version "1.0.15" - resolved "https://registry.yarnpkg.com/fibers/-/fibers-1.0.15.tgz#22f039c8f18b856190fbbe4decf056154c1eae9c" - figures@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" @@ -2739,22 +2720,24 @@ glob2base@^0.0.12: dependencies: find-index "^0.1.1" -glob@^4.3.2: - version "4.5.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" +glob@^5.0.15: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: inflight "^1.0.4" inherits "2" - minimatch "^2.0.1" + minimatch "2 || 3" once "^1.3.0" + path-is-absolute "^1.0.0" -glob@^5.0.15: - version "5.0.15" - resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" +glob@^7.0.0: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" dependencies: + fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "2 || 3" + minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" @@ -2906,10 +2889,6 @@ hoek@2.x.x: version "2.16.3" resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" -home-dir@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/home-dir/-/home-dir-0.2.0.tgz#765cac335384b51f31fd0448e4cdd8066e1e2c8f" - home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -4345,12 +4324,6 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: dependencies: brace-expansion "^1.1.7" -minimatch@^2.0.1: - version "2.0.10" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" - dependencies: - brace-expansion "^1.0.0" - minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -4576,16 +4549,6 @@ npmlog@^4.0.2: gauge "~2.7.3" set-blocking "~2.0.0" -nscript@^0.1.10: - version "0.1.10" - resolved "https://registry.yarnpkg.com/nscript/-/nscript-0.1.10.tgz#25b5925f84a62769b07c1fe6372d7c7cfad4e904" - dependencies: - colors "^1.0.3" - commander "^2.6.0" - fibers "^1.0.2" - glob "^4.3.2" - home-dir "^0.2.0" - number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" @@ -5115,6 +5078,12 @@ realpath-native@^1.0.0: dependencies: util.promisify "^1.0.0" +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + regenerate-unicode-properties@^5.1.1: version "5.1.3" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-5.1.3.tgz#54f5891543468f36f2274b67c6bc4c033c27b308" @@ -5525,6 +5494,14 @@ shell-quote@^1.4.3, shell-quote@^1.6.1: array-reduce "~0.0.0" jsonify "~0.0.0" +shelljs@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.2.tgz#345b7df7763f4c2340d584abb532c5f752ca9e35" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + shellwords@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"