File tree Expand file tree Collapse file tree 5 files changed +42
-9
lines changed Expand file tree Collapse file tree 5 files changed +42
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "extends": ["@neogeek/eslint-config-standards"]
2
+ "extends": ["@neogeek/eslint-config-standards"],
3
+ "rules": {
4
+ "no-ternary": "off"
5
+ }
3
6
}
Original file line number Diff line number Diff line change @@ -45,6 +45,22 @@ $ UNITY_URL=$(get-unity --file=ProjectSettings/ProjectVersion.txt)
45
45
$ echo $UNITY_URL
46
46
```
47
47
48
+ ## Help
49
+
50
+ ``` bash
51
+ Command line tool for getting the download URL for the latest or specific version of Unity.
52
+
53
+ Usage
54
+ $ get-unity < version> [options]
55
+
56
+ Options
57
+ --file, -f Search file for Unity version number.
58
+ --force, -r Force update to local cache of editor versions.
59
+ --offline, -o Prevent request to update local cache of editor versions.
60
+ --help, -h Display this help message.
61
+ --version, -v Display the current installed version.
62
+ ```
63
+
48
64
## API
49
65
50
66
### ` checkCacheExpiry(string path, integer ttl) `
@@ -105,12 +121,12 @@ Output:
105
121
2019.2.9f1
106
122
```
107
123
108
- ### ` updateEditorInstallers([string filePath]) `
124
+ ### ` updateEditorInstallers([string filePath, int ttl ]) `
109
125
110
126
``` javascript
111
127
const { updateEditorInstallers } = require (" get-unity" );
112
128
113
- updateEditorInstallers (" ./data/editor-installers.json" ).then (() =>
129
+ updateEditorInstallers (" ./data/editor-installers.json" , 3600000 ).then (() =>
114
130
console .log (" Done" )
115
131
);
116
132
```
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const cli = meow(
22
22
23
23
Options
24
24
${ chalk . yellow ( '--file, -f' ) } Search file for Unity version number.
25
+ ${ chalk . yellow ( '--force, -r' ) } Force update to local cache of editor versions.
25
26
${ chalk . yellow ( '--offline, -o' ) } Prevent request to update local cache of editor versions.
26
27
${ chalk . yellow ( '--help, -h' ) } Display this help message.
27
28
${ chalk . yellow ( '--version, -v' ) } Display the current installed version.
@@ -32,6 +33,11 @@ const cli = meow(
32
33
'alias' : 'f' ,
33
34
'type' : 'string'
34
35
} ,
36
+ 'force' : {
37
+ 'alias' : 'r' ,
38
+ 'default' : false ,
39
+ 'type' : 'boolean'
40
+ } ,
35
41
'help' : {
36
42
'alias' : 'h' ,
37
43
'default' : false ,
@@ -61,6 +67,8 @@ const EDITOR_INSTALLERS_FILE_PATH = join(
61
67
'../data/editor-installers.json'
62
68
) ;
63
69
70
+ const DEFAULT_CACHE_TTL = 3600000 ;
71
+
64
72
updateNotifier ( { pkg} ) . notify ( ) ;
65
73
66
74
if ( cli . flags . file ) {
@@ -92,7 +100,12 @@ if (cli.flags.offline) {
92
100
93
101
} else {
94
102
95
- updateEditorInstallers ( EDITOR_INSTALLERS_FILE_PATH )
103
+ updateEditorInstallers (
104
+ EDITOR_INSTALLERS_FILE_PATH ,
105
+ cli . flags . force
106
+ ? 0
107
+ : DEFAULT_CACHE_TTL
108
+ )
96
109
. catch ( ( { message} ) => {
97
110
98
111
process . stderr . write ( `${ chalk . red ( 'Error:' ) } ${ message } ` ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ const EDITOR_INSTALLERS_FILE_PATH = join(
21
21
22
22
const JSON_TAB_WIDTH = 2 ;
23
23
24
- const CACHE_TTL = 3600000 ;
24
+ const DEFAULT_CACHE_TTL = 3600000 ;
25
25
26
26
const parseVersionFromUnityArchive = body => {
27
27
@@ -55,16 +55,16 @@ const parseVersionFromUnityArchive = body => {
55
55
56
56
} ;
57
57
58
- const updateEditorInstallers = ( filePath = EDITOR_INSTALLERS_FILE_PATH ) =>
58
+ const updateEditorInstallers = ( filePath = EDITOR_INSTALLERS_FILE_PATH , ttl = DEFAULT_CACHE_TTL ) =>
59
59
checkCacheExpiry (
60
60
filePath ,
61
- CACHE_TTL
61
+ ttl
62
62
)
63
63
. catch ( ( ) =>
64
64
fetchWithLocalCache (
65
65
'https://unity3d.com/get-unity/download/archive' ,
66
66
ARCHIVE_FILE_PATH ,
67
- CACHE_TTL
67
+ ttl
68
68
)
69
69
. then ( parseVersionFromUnityArchive )
70
70
. then ( data =>
Original file line number Diff line number Diff line change 25
25
"jest" : " 24.9.0"
26
26
},
27
27
"scripts" : {
28
- "test" : " jest"
28
+ "test" : " jest" ,
29
+ "postinstall" : " node bin/index.js --force"
29
30
},
30
31
"keywords" : [
31
32
" unity"
You can’t perform that action at this time.
0 commit comments