Skip to content

Commit 8f0542c

Browse files
BrianHicksRichard Feldman
andcommitted
update npm installers for 0.19.0
Co-authored-by: Richard Feldman <richard.t.feldman@gmail.com>
1 parent a968e81 commit 8f0542c

File tree

11 files changed

+233
-65
lines changed

11 files changed

+233
-65
lines changed

installers/npm/PUBLISHING.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Publishing a new release
2+
3+
A new version of Elm came out. Huzzah! Here's how to update the `npm` installer.
4+
5+
## 1. Create tarballs of binaries
6+
7+
You can find a list of what binaries we'll need to tar up in `index.js`.
8+
9+
For example:
10+
11+
```javascript
12+
var root = "https://github.com/elm-lang/elm-platform/releases/download/" + binVersion + "-exp/elm-platform";
13+
14+
module.exports = binwrap({
15+
binaries: ["elm", "elm-make", "elm-repl", "elm-reactor", "elm-package"],
16+
urls: {
17+
"darwin-x64": root + "-macos.tar.gz",
18+
"win32-x64": root + "-windows.tar.gz",
19+
"win32-ia32": root + "-windows.tar.gz",
20+
"linux-x64": root + "-linux-64bit.tar.gz"
21+
}
22+
});
23+
```
24+
25+
If this is the end of your `index.js`, you'll need to create these files:
26+
27+
1. `elm-platform-macos.tar.gz`
28+
2. `elm-platform-windows.tar.gz`
29+
3. `elm-platform-linux-64bit.tar.gz`
30+
31+
Each of these tarballs should have **only binaries** inside them - no directories!
32+
33+
So create them by making a directory, putting all the binaries in it, `cd`-ing
34+
into that directory, and then running something like this:
35+
36+
```shell
37+
$ tar cvzf elm-platform-linux-64bit.tar.gz *
38+
```
39+
40+
Make sure each tarball contains all the binaries listed in that `binaries:` list
41+
in `index.js`. (The Windows ones should have `.exe` at the end; `binwrap`
42+
expects that they will, for Windows only.)
43+
44+
## 2. Update the `bin/` binary wrappers
45+
46+
Inside the npm installer's `bin/` directory, there should be a file for each of
47+
the binaries that will be included in this release.
48+
49+
Each of these must be executable! If you're not sure whether they are,
50+
run `chmod +x` on them just to be sure.
51+
52+
Their paths must also must all be listed in `package.json` in two places:
53+
54+
1. The `"files":` field
55+
2. The `"bin":` field
56+
57+
If the executables are the same as they were for the last release, great!
58+
You can proceed to the next step. If any binaries were removed, make sure to
59+
remove them from these lists!
60+
61+
## 3. Update `package.json` for a beta release
62+
63+
In `package.json`, bump the version to the next applicable release, and add
64+
a `"-beta"` suffix to it.
65+
66+
For example, if it was on `"0.18.0"` you might bump it to `"0.19.0-beta"`.
67+
The version number should match the release of Elm, such that if people do
68+
`npm install elm@0.19.0@beta` they get what they would expect.
69+
70+
## 4. Tag the beta release
71+
72+
Commit this change and tag it with the name of the release **without** the
73+
`-beta` suffix. (We will overwrite this tag later.)
74+
75+
For example:
76+
77+
```shell
78+
$ git tag 0.19.0
79+
$ git push origin 0.19.0
80+
```
81+
82+
Now this tag should exist on GitHub, allowing us to upload binaries to it.
83+
84+
## 5. Upload binaries
85+
86+
Visit the [Create a New Release](https://github.com/elm-lang/elm-platform/releases/new)
87+
page and use the `Tag version` dropdown to select the tag you just pushed. Give
88+
it a title like `0.19.0`. Don't mention the `-beta` in it. The "beta" concept
89+
is for `npm` only.
90+
91+
Upload the tarballs you created in step 1.
92+
93+
## 6. Publish beta release
94+
95+
Run this to publish the beta release. The `--tag beta` is **crucial** here.
96+
Without it, `npm` will by default publish a new top-level release, which would
97+
mean that what you just published would become what everyone gets when they
98+
`npm install -g elm` without any additional qualifiers.
99+
100+
```shell
101+
$ npm publish --tag beta
102+
```
103+
104+
Afterwards you should be able to do `npm info elm | less` and see something
105+
like this in the JSON:
106+
107+
```
108+
'dist-tags': { latest: '0.18.0', beta: '0.19.0-beta' }
109+
```
110+
111+
If you messed this up, and the `latest` tag now points to the beta you just
112+
published, don't panic - it's fixable! `dist-tags` can always be modified after
113+
the fact. Read up on `npm` [dist-tags](https://docs.npmjs.com/cli/dist-tag)
114+
to learn how to fix things.
115+
116+
## 7. Verify beta installer
117+
118+
Make an empty directory and run `npm init` inside it.
119+
120+
Then run this:
121+
122+
```shell
123+
$ npm install elm@beta --ignore-scripts
124+
```
125+
126+
This should succeed with an exit code of `0`.
127+
If it did, look in `node_modules/.bin/` for the binaries you expect.
128+
They should be present, and they should also work as expected when you run them.
129+
Because you installed them with `--ignore-scripts`, the first thing they should
130+
do is to download themselves and then execute whatever command you requested
131+
(e.g. `node_modules/.bin/elm make Main.elm`). If you run the same command a
132+
second time, it should run faster because it doesn't have to download the binary
133+
first.
134+
135+
Now try it again with `--ignore-scripts` turned off:
136+
137+
```shell
138+
$ rm -r node_modules
139+
$ npm install elm@beta --ignore-scripts=false
140+
```
141+
142+
This time it should download the binaries during the installation phase. Once
143+
again you should be able to run the binaries from `node_modules/.bin/`, and
144+
this time they should be fast from the first run because they're already
145+
downloaded.
146+
147+
## 8. Publish for real
148+
149+
It's a good idea to ask others to try out the beta installer before doing this!
150+
Especially on multiple operating systems.
151+
152+
To publish the real version:
153+
154+
1. Edit `package.json` to remove the `-beta` suffix from the version.
155+
2. Commit that change and push it.
156+
3. Use `git tag --force` to overwrite the previous tag (e.g. `0.19.0` - whatever you used before).
157+
4. Force push the tag, e.g. `git push origin 0.19.0 --force-with-lease`.
158+
5. `npm publish`
159+
160+
You're done! Now whenever anyone does `npm install -g elm` they'll get the
161+
version you just uploaded.
162+
163+
The reason we only used the `-beta` suffix for `npm` was so that when we ran
164+
tests on the beta version, it was all against the same (non-beta) URLs we'd end
165+
up using for the real version. This means there's no opportunity for us to
166+
introduce some sort of mismatch between the beta that we verified and the real
167+
version.

installers/npm/UPLOADING.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

installers/npm/bin/elm

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env node
2+
3+
// This file exists for the benefit of npm users who have --ignore-scripts
4+
// enabled. (Enabling this flag globally is a good security measure.)
5+
// Since they won't run the post-install hook, the binaries won't be downloaded
6+
// and installed.
7+
//
8+
// Since this file is included in "bin" in package.json, npm will install
9+
// it automatically in a place that should be on the PATH. All the file does
10+
// is to download the appropriate binary (just like the post-install hook would
11+
// have), replace this file with that binary, and run the binary.
12+
//
13+
// In this way, the first time a user with --ignore-scripts enabled runs this
14+
// binary, it will download and install itself, and then run as normal. From
15+
// then on, it will run as normal without re-downloading.
16+
17+
var install = require("..").install;
18+
var spawn = require("child_process").spawn;
19+
var path = require("path");
20+
var fs = require("fs");
21+
22+
// Make sure we get the right path even if we're executing from the symlinked
23+
// node_modules/.bin/ executable
24+
var targetPath = fs.realpathSync(process.argv[1]);
25+
26+
// cd into the directory above bin/ so install() puts bin/ in the right place.
27+
process.chdir(path.join(path.dirname(targetPath), ".."));
28+
29+
install(process.platform, process.arch).then(function() {
30+
spawn(targetPath, process.argv.slice(2), {
31+
stdio: "inherit"
32+
}).on("exit", process.exit);
33+
});

installers/npm/binaries/elm

Lines changed: 0 additions & 1 deletion
This file was deleted.

installers/npm/binaries/elm-make

Lines changed: 0 additions & 1 deletion
This file was deleted.

installers/npm/binaries/elm-package

Lines changed: 0 additions & 1 deletion
This file was deleted.

installers/npm/binaries/elm-reactor

Lines changed: 0 additions & 1 deletion
This file was deleted.

installers/npm/binaries/elm-repl

Lines changed: 0 additions & 1 deletion
This file was deleted.

installers/npm/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var binwrap = require("binwrap");
2+
var path = require("path");
3+
4+
var packageInfo = require(path.join(__dirname, "package.json"));
5+
// Use major.minor.patch from version string - e.g. "1.2.3" from "1.2.3-alpha"
6+
var binVersion = packageInfo.version.replace(/^(\d+\.\d+\.\d+).*$/, "$1");
7+
8+
var root =
9+
"https://github.com/elm/compiler/releases/download/" +
10+
binVersion +
11+
"/binaries-for-";
12+
13+
module.exports = binwrap({
14+
binaries: ["elm"],
15+
urls: {
16+
"darwin-x64": root + "mac.tar.gz",
17+
"win32-x64": root + "windows.tar.gz",
18+
"win32-ia32": root + "windows.tar.gz",
19+
"linux-x64": root + "linux.tar.gz"
20+
}
21+
});

installers/npm/install.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)