Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
7387db4a
Commit
7387db4a
authored
5 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Add update version script from manyverse
parent
9ef84f9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/update-version.js
+70
-0
70 additions, 0 deletions
tools/update-version.js
with
70 additions
and
0 deletions
tools/update-version.js
0 → 100755
+
70
−
0
View file @
7387db4a
#!/usr/bin/env node
// from https://gitlab.com/staltz/manyverse/blob/master/tools/update-version.js
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const
ReactNativeVersion
=
require
(
'
react-native-version
'
)
const
readline
=
require
(
'
readline
'
)
const
leftPad
=
require
(
'
left-pad
'
)
const
path
=
require
(
'
path
'
)
const
fs
=
require
(
'
fs
'
)
const
currentVersion
=
JSON
.
parse
(
fs
.
readFileSync
(
'
./package.json
'
)).
version
const
rl
=
readline
.
createInterface
({
input
:
process
.
stdin
,
output
:
process
.
stdout
,
})
function
createTodaysVersion
(
attempt
)
{
const
today
=
new
Date
()
const
yy
=
today
.
getFullYear
()
-
2000
// So it's two digits
const
mm
=
leftPad
(
today
.
getMonth
()
+
1
,
2
,
'
0
'
)
const
d
=
today
.
getDate
()
if
(
attempt
===
0
)
{
return
`0.
${
yy
}${
mm
}
.
${
d
}
-beta`
}
else
{
const
letter
=
String
.
fromCharCode
(
97
+
attempt
)
// 0=a, 1=b, 2=c, ...
return
`0.
${
yy
}${
mm
}
.
${
d
}
-beta.
${
letter
}
`
}
}
let
nextVersion
for
(
let
i
=
0
/* letter a */
;
i
<=
25
/* letter z */
;
i
++
)
{
nextVersion
=
createTodaysVersion
(
i
)
if
(
nextVersion
!==
currentVersion
)
break
}
if
(
nextVersion
===
currentVersion
)
{
console
.
error
(
'
I dont know what else to generate beyong
'
+
nextVersion
)
process
.
exit
(
1
)
}
rl
.
question
(
'
Next version will be `
'
+
nextVersion
+
'
`, okay? y/n
'
,
yn
=>
{
if
(
yn
!==
'
y
'
&&
yn
!==
'
Y
'
)
{
console
.
log
(
'
Release cancelled.
\n
'
)
process
.
exit
(
1
)
return
}
const
pkgJSON
=
JSON
.
parse
(
fs
.
readFileSync
(
'
./package.json
'
))
const
pkgLockJSON
=
JSON
.
parse
(
fs
.
readFileSync
(
'
./package-lock.json
'
))
pkgJSON
.
version
=
nextVersion
pkgLockJSON
.
version
=
nextVersion
fs
.
writeFileSync
(
'
./package.json
'
,
JSON
.
stringify
(
pkgJSON
,
null
,
2
))
fs
.
writeFileSync
(
'
./package-lock.json
'
,
JSON
.
stringify
(
pkgLockJSON
,
null
,
2
))
ReactNativeVersion
.
version
(
{
neverAmend
:
true
,
target
:
'
android
'
,
},
path
.
resolve
(
__dirname
,
'
../
'
),
).
catch
(
err
=>
{
console
.
error
(
err
)
process
.
exit
(
1
)
})
rl
.
close
()
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment