Skip to content

Commit a3395b7

Browse files
committed
Initial commit.
0 parents  commit a3395b7

File tree

10 files changed

+726
-0
lines changed

10 files changed

+726
-0
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@neogeek/eslint-config-standards"]
3+
}

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ko_fi: scottdoxey

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
3+
package-lock.json

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Scott Doxey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# get-unity
2+
3+
> 🕹 Command line tool for getting the download URL for the latest or specific version of Unity.
4+
5+
## Install
6+
7+
```bash
8+
$ npm install -g get-unity
9+
```
10+
11+
## Usage
12+
13+
### Get the latest major release of Unity.
14+
15+
```bash
16+
$ get-unity
17+
```
18+
19+
### Get the latest minor release of Unity.
20+
21+
```bash
22+
$ get-unity 2019.x
23+
```
24+
25+
### Get the latest patch release of Unity.
26+
27+
```bash
28+
$ get-unity 2019.2.x
29+
```
30+
31+
### Exporting URL to an enviroment variable.
32+
33+
```bash
34+
$ UNITY_URL=$(get-unity 2019.2.x)
35+
$ echo $UNITY_URL
36+
```
37+
38+
## API
39+
40+
### `getUnityUrls`
41+
42+
```javascript
43+
const { getUnityUrls } = require("get-unity");
44+
45+
getUnityUrls("2019").then(urls => console.log(urls));
46+
```

bin/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
3+
const os = require('os');
4+
5+
const getUnityUrls = require('../lib/get-unity-urls');
6+
7+
const osKeyMap = {
8+
'Darwin': 'mac',
9+
'Windows_NT': 'win64'
10+
};
11+
12+
const PROCESS_CMD_LINE_ARGS_LENGTH = 2;
13+
14+
const requestedVersion = process.argv.slice(PROCESS_CMD_LINE_ARGS_LENGTH).pop();
15+
16+
getUnityUrls(requestedVersion).then(urls =>
17+
process.stdout.write(`${urls[osKeyMap[os.type()]]}`));

data/editor-installers.json

Lines changed: 574 additions & 0 deletions
Large diffs are not rendered by default.

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const getUnityUrls = require('./lib/get-unity-urls');
2+
3+
module.exports = {
4+
getUnityUrls
5+
};

lib/get-unity-urls.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const editorInstallers = require('../data/editor-installers.json');
2+
3+
const getUnityUrls = (filter = '') =>
4+
new Promise(resolve => {
5+
6+
const versions = Object.keys(editorInstallers);
7+
8+
const [latest] = versions;
9+
10+
const match =
11+
versions.find(version =>
12+
version.match(new RegExp(
13+
`^${filter.replace(
14+
'x',
15+
'[0-9]+'
16+
)}`,
17+
'u'
18+
))) || latest;
19+
20+
resolve(editorInstallers[match]);
21+
22+
});
23+
module.exports = getUnityUrls;

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "get-unity",
3+
"description": "Command line tool for getting the download URL for the latest or specific version of Unity.",
4+
"version": "1.0.0",
5+
"main": "index.js",
6+
"bin": {
7+
"get-unity": "bin/index.js"
8+
},
9+
"engines": {
10+
"node": ">=12.0"
11+
},
12+
"license": "MIT",
13+
"devDependencies": {
14+
"@neogeek/eslint-config-standards": "github:neogeek/eslint-config-standards",
15+
"babel-eslint": "10.0.3",
16+
"eslint": "6.6.0"
17+
},
18+
"keywords": [
19+
"unity"
20+
],
21+
"authors": [
22+
{
23+
"name": "Scott Doxey",
24+
"email": "hello@scottdoxey.com",
25+
"homepage": "http://scottdoxey.com/"
26+
}
27+
],
28+
"homepage": "https://github.com/neogeek/get-unity",
29+
"repository": {
30+
"type": "git",
31+
"url": "git://github.com/neogeek/get-unity.git"
32+
}
33+
}

0 commit comments

Comments
 (0)