Chore/retire left pad

This commit is contained in:
Sofiya Tepikin
2022-08-15 19:24:34 +00:00
parent b433fa805f
commit 137c2672d7
3 changed files with 31 additions and 33 deletions
-6
View File
@@ -12958,12 +12958,6 @@
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
"dev": true "dev": true
}, },
"left-pad": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz",
"integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==",
"dev": true
},
"leven": { "leven": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz",
-1
View File
@@ -71,7 +71,6 @@
"husky": "^8.0.0", "husky": "^8.0.0",
"jest": "^28.1.3", "jest": "^28.1.3",
"jetifier": "^1.6.6", "jetifier": "^1.6.6",
"left-pad": "^1.3.0",
"metro-react-native-babel-preset": "^0.58.0", "metro-react-native-babel-preset": "^0.58.0",
"prettier": "2.4.0", "prettier": "2.4.0",
"pretty-quick": "^3.1.1", "pretty-quick": "^3.1.1",
+31 -26
View File
@@ -5,13 +5,11 @@
const ReactNativeVersion = require('react-native-version') const ReactNativeVersion = require('react-native-version')
const readline = require('readline') const readline = require('readline')
const leftPad = require('left-pad')
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
module.exports = () => { module.exports = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const currentVersion = JSON.parse(fs.readFileSync('./package.json')).version const currentVersion = JSON.parse(fs.readFileSync('./package.json')).version
const rl = readline.createInterface({ const rl = readline.createInterface({
@@ -22,7 +20,8 @@ module.exports = () => {
function createTodaysVersion(attempt) { function createTodaysVersion(attempt) {
const today = new Date() const today = new Date()
const yy = today.getFullYear() - 2000 // So it's two digits const yy = today.getFullYear() - 2000 // So it's two digits
const mm = leftPad(today.getMonth() + 1, 2, '0') const monthString = (today.getMonth() + 1).toString()
const mm = monthString.padStart(2, '0')
const d = today.getDate() const d = today.getDate()
if (attempt === 0) { if (attempt === 0) {
return `1.${yy}${mm}.${d}` return `1.${yy}${mm}.${d}`
@@ -42,28 +41,34 @@ module.exports = () => {
process.exit(1) process.exit(1)
} }
rl.question('Next version will be `' + nextVersion + '`, okay? y/n ', async yn => { rl.question(
if (yn !== 'y' && yn !== 'Y') { 'Next version will be `' + nextVersion + '`, okay? y/n ',
reject('Release cancelled.\n') async (yn) => {
return if (yn !== 'y' && yn !== 'Y') {
reject('Release cancelled.\n')
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)
)
await ReactNativeVersion.version(
{
neverAmend: true,
target: 'android',
},
path.resolve(__dirname, '../')
)
rl.close()
resolve()
} }
)
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))
await ReactNativeVersion.version(
{
neverAmend: true,
target: 'android',
},
path.resolve(__dirname, '../'),
)
rl.close()
resolve()
})
}) })
} }