mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-09 13:36:54 -06:00
PR-468832: Change version and name of app on npx.
This commit is contained in:
parent
84062c69e1
commit
42ab5d06a1
11
bin/cli.js
11
bin/cli.js
@ -13,6 +13,9 @@ const runCommand = command => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const actualVersion = runCommand(`cd ${repoName} && node -p "require('./package.json').version"`)
|
||||||
|
if(!actualVersion) process.exit(-1);
|
||||||
|
|
||||||
const repoName = process.argv[2];
|
const repoName = process.argv[2];
|
||||||
const gitCheckoutCommand = `git clone --depth 1 https://github.com/aleleba/create-react-ssr ${repoName}`;
|
const gitCheckoutCommand = `git clone --depth 1 https://github.com/aleleba/create-react-ssr ${repoName}`;
|
||||||
const installDepsCommand = `cd ${repoName} && npm install`;
|
const installDepsCommand = `cd ${repoName} && npm install`;
|
||||||
@ -24,6 +27,8 @@ const deleteBinCommand = `cd ${repoName} && sed -i 's+"bin": "./bin/cli.js",++g'
|
|||||||
const deleteBinCommandWindows = `cd ${repoName} && copy package.json package2.json && del package.json && type package2.json | findstr /v cli.js > package.json && del package2.json`
|
const deleteBinCommandWindows = `cd ${repoName} && copy package.json package2.json && del package.json && type package2.json | findstr /v cli.js > package.json && del package2.json`
|
||||||
const deleteBinCommandApple = `cd ${repoName} && sed -i .copy 's+"bin": "./bin/cli.js",++g' package.json && sed -i .copy '/^[[:space:]]*$/d' package.json &&
|
const deleteBinCommandApple = `cd ${repoName} && sed -i .copy 's+"bin": "./bin/cli.js",++g' package.json && sed -i .copy '/^[[:space:]]*$/d' package.json &&
|
||||||
rm -rf package.json.copy`
|
rm -rf package.json.copy`
|
||||||
|
const replaceNewVersionCommand = `cd ${repoName} && sed -i 's+"version": "${actualVersion}",+"version": "0.0.1",+g' package.json`
|
||||||
|
const replaceNameAppCommand = `cd ${repoName} && sed -i 's+"name": "@aleleba/create-react-ssr",+"name": "${repoName}",+g' package.json`
|
||||||
|
|
||||||
console.log(`Cloning the repository with name ${repoName}`);
|
console.log(`Cloning the repository with name ${repoName}`);
|
||||||
const checkedOut = runCommand(gitCheckoutCommand);
|
const checkedOut = runCommand(gitCheckoutCommand);
|
||||||
@ -36,6 +41,12 @@ if(!installedDeps) process.exit(-1);
|
|||||||
const deleteBin = isAppple ? runCommand(deleteBinCommandApple) : (isWin ? runCommand(deleteBinCommandWindows) : runCommand(deleteBinCommand));
|
const deleteBin = isAppple ? runCommand(deleteBinCommandApple) : (isWin ? runCommand(deleteBinCommandWindows) : runCommand(deleteBinCommand));
|
||||||
if(!deleteBin) process.exit(-1);
|
if(!deleteBin) process.exit(-1);
|
||||||
|
|
||||||
|
const replaceNewVersion = runCommand(replaceNewVersionCommand)
|
||||||
|
if(!replaceNewVersion) process.exit(-1);
|
||||||
|
|
||||||
|
const replaceNameApp = runCommand(replaceNameAppCommand)
|
||||||
|
if(!replaceNameApp) process.exit(-1);
|
||||||
|
|
||||||
console.log(`Cleaning History of Git for ${repoName}`);
|
console.log(`Cleaning History of Git for ${repoName}`);
|
||||||
const cleanGitHistory = isWin ? runCommand(cleanGitHistoryCommandWindows) : runCommand(cleanGitHistoryCommand);
|
const cleanGitHistory = isWin ? runCommand(cleanGitHistoryCommandWindows) : runCommand(cleanGitHistoryCommand);
|
||||||
if(!cleanGitHistory) process.exit(-1);
|
if(!cleanGitHistory) process.exit(-1);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@aleleba/create-react-ssr",
|
"name": "@aleleba/create-react-ssr",
|
||||||
"version": "3.0.28",
|
"version": "3.0.29",
|
||||||
"description": "Starter Kit of server side render of react",
|
"description": "Starter Kit of server side render of react",
|
||||||
"bin": "./bin/cli.js",
|
"bin": "./bin/cli.js",
|
||||||
"main": "src/server/index",
|
"main": "src/server/index",
|
||||||
|
Loading…
Reference in New Issue
Block a user