From 904b63b2aa25433ed69b7f62efce4911a6e40b1f Mon Sep 17 00:00:00 2001 From: Isiah Meadows Date: Wed, 10 Jul 2019 14:04:44 -0400 Subject: [PATCH] Drop `m.version` (#2466) * Drop `m.version` It's caused way too much grief over the years, and I've finally decided it's worth pitching. For those who need it, it's easy to get, especially if you use it through Node or a build system. And for those who are just loading it globally, you have to explicitly specify the version anyways, so you'd be just as golden if you followed it up with a simple inline script that does `m.version = "the version you loaded"`. Oh, and also, you shouldn't be coding specifically for version numbers, either - it's a known anti-pattern. Instead, you should prefer feature detection and just do the right thing. * Update changelog [skip ci] --- docs/change-log.md | 1 + docs/nav-methods.md | 1 - docs/version.md | 27 --------------------------- index.js | 1 - package.json | 2 +- scripts/update-version.js | 10 ---------- tests/test-api.js | 7 ------- 7 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 docs/version.md delete mode 100644 scripts/update-version.js diff --git a/docs/change-log.md b/docs/change-log.md index 900be74d..e8022755 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -60,6 +60,7 @@ - redraw: `mithril/redraw` now just exposes the `m.redraw` callback ([#2458](https://github.com/MithrilJS/mithril.js/pull/2458) [@isiahmeadows](https://github.com/isiahmeadows)) - The `.schedule`, `.unschedule`, and `.render` properties of the former `redrawService` are all removed. - If you want to know how to work around it, look at the call to `mount` in Mithril's source for `m.route`. That should help you in finding ways around the removed feature. (It doesn't take that much more code.) +- api: `m.version` has been removed. If you really need the version for whatever reason, just read the `version` field of `mithril/package.json` directly. ([#2466](https://github.com/MithrilJS/mithril.js/pull/2466) [@isiahmeadows](https://github.com/isiahmeadows)) #### News diff --git a/docs/nav-methods.md b/docs/nav-methods.md index 83a82d35..c05957e3 100644 --- a/docs/nav-methods.md +++ b/docs/nav-methods.md @@ -12,7 +12,6 @@ - [m.trust](trust.md) - [m.fragment](fragment.md) - [m.redraw](redraw.md) - - [m.version](version.md) - [Promise](promise.md) - Optional - [Stream](stream.md) diff --git a/docs/version.md b/docs/version.md deleted file mode 100644 index 683cd41e..00000000 --- a/docs/version.md +++ /dev/null @@ -1,27 +0,0 @@ -# version - -- [Signature](#signature) -- [How it works](#how-it-works) - ---- - -### Signature - -`m.version` - -Argument | Type | Required | Description ------------ | -------------------- | -------- | --- -**returns** | String | | Returns the version number - ---- - -### How it works - -The `m.version` property is a string containing the [semver](http://semver.org/) value for the current release. - -Semver (or Semantic Versioning) specifies that a version number must follow the syntax "0.0.0", where the first number is the MAJOR number, the second is the MINOR number and the third is the PATCH number. - -- The MAJOR number changes when there are backwards-incompatible API changes, -- The MINOR number changes when functionality is added in a backwards-compatible manner, and -- The PATCH number changes when there are backwards-compatible bug fixes - diff --git a/index.js b/index.js index e308e1e9..96f18631 100644 --- a/index.js +++ b/index.js @@ -18,7 +18,6 @@ m.parseQueryString = require("./querystring/parse") m.buildQueryString = require("./querystring/build") m.parsePathname = require("./pathname/parse") m.buildPathname = require("./pathname/build") -m.version = "2.0.0-rc.7" m.vnode = require("./render/vnode") m.PromisePolyfill = require("./promise/polyfill") diff --git a/package.json b/package.json index d2792860..4724ce15 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "cover": "istanbul cover --print both ospec/bin/ospec", "release": "npm version -m 'v%s'", "preversion": "npm run test", - "version": "node scripts/update-version && npm run build && git add index.js mithril.js mithril.min.js", + "version": "npm run build && git add index.js mithril.js mithril.min.js", "postversion": "git push --follow-tags" }, "devDependencies": { diff --git a/scripts/update-version.js b/scripts/update-version.js deleted file mode 100644 index 7de01395..00000000 --- a/scripts/update-version.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict" - -const fs = require("fs") -const version = require("../package.json").version -const index = require.resolve("../index") - -fs.writeFile(index, - fs.readFile(index, "utf-8") - .replace(/(version\s*=\s*)(['"]).*?\2/, `$1$2${version}$2`) -) diff --git a/tests/test-api.js b/tests/test-api.js index 542322d8..de3b318f 100644 --- a/tests/test-api.js +++ b/tests/test-api.js @@ -24,13 +24,6 @@ o.spec("api", function() { o(vnode.tag).equals("div") }) }) - o.spec("m.version", function() { - o("works", function() { - o(typeof m.version).equals("string") - o(m.version.indexOf(".") > -1).equals(true) - o((/\d/).test(m.version)).equals(true) - }) - }) o.spec("m.trust", function() { o("works", function() { var vnode = m.trust("
")