forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublishPrReleaseAndCreateFreshCraTemplate.js
47 lines (38 loc) · 1.31 KB
/
publishPrReleaseAndCreateFreshCraTemplate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict'
const path = require('path')
const reactScriptPath = path.join(__dirname, 'packages/react-scripts')
const { alterPackageJsonFile, getTravisPrereleaseVersion } = require(path.join(
reactScriptPath,
'scripts/utils/frontierInit'
))
const { runExternalCommandSync } = require(path.join(reactScriptPath, 'scripts/utils/osUtils'))
let originalVersion
let newVersion
alterPackageJsonFile(reactScriptPath, packageJson => {
originalVersion = packageJson.version
newVersion = getTravisPrereleaseVersion(packageJson.version)
console.log(`setting @fs/react-scripts version to "${newVersion}" temporarily to get published`)
packageJson.version = newVersion
return packageJson
})
runExternalCommandSync('npm', ['run', 'fs-publish', '--', '--allow-earlier-version'], { cwd: reactScriptPath })
alterPackageJsonFile(reactScriptPath, packageJson => {
packageJson.version = originalVersion
console.log(`setting @fs/react-scripts version back to "${originalVersion}"`)
return packageJson
})
const tmpDir = `${process.env.HOME}/tmp`
runExternalCommandSync('mkdir', ['-p', tmpDir])
runExternalCommandSync(
'npx',
[
'create-react-app',
'fresh-cra-template',
'--use-npm',
'--scripts-version',
`@fs/react-scripts@${newVersion}`,
'--template',
'@fs/cra-template',
],
{ cwd: tmpDir }
)