-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16871de
commit 7fa3948
Showing
1 changed file
with
51 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,65 @@ | ||
|
||
const fs = require('fs-extra'); | ||
const args = process.argv; | ||
const VERSION = require('../storybook/storybook/package.json').version; | ||
const GITHUB_TOKEN = args[2]; | ||
|
||
try { | ||
const dir = './tmp'; | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirSync(dir); | ||
} | ||
|
||
const dir = './tmp'; | ||
if (!fs.existsSync(dir)){ | ||
fs.mkdirSync(dir); | ||
} | ||
const execSync = require('child_process').execSync; | ||
let child = execSync( | ||
`git clone https://toto:${GITHUB_TOKEN}@github.com/AxaGuilDEv/AxaGuilDEv.github.io ./tmp/AxaGuilDEv.github.io/` | ||
); | ||
console.log('error', child.error); | ||
console.log('stdout ', child.stdout); | ||
console.log('stderr ', child.stderr); | ||
|
||
const execSync = require('child_process').execSync; | ||
let child = execSync(`git clone https://toto:${GITHUB_TOKEN}@github.com/AxaGuilDEv/AxaGuilDEv.github.io ./tmp/AxaGuilDEv.github.io/`); | ||
console.log('error', child.error); | ||
console.log('stdout ', child.stdout); | ||
console.log('stderr ', child.stderr); | ||
const PREVIOUS_VERSION = require('../tmp/AxaGuilDEv.github.io/react-toolkit/latest/version.json') | ||
.version; | ||
|
||
const PREVIOUS_VERSION = require('./tmp/AxaGuilDEv.github.io/react-toolkit/latest/version.json').version; | ||
|
||
fs.moveSync('./tmp/AxaGuilDEv.github.io/react-toolkit/latest', `./tmp/AxaGuilDEv.github.io/react-toolkit/v${PREVIOUS_VERSION}`); | ||
fs.moveSync( | ||
'./tmp/AxaGuilDEv.github.io/react-toolkit/latest', | ||
`./tmp/AxaGuilDEv.github.io/react-toolkit/v${PREVIOUS_VERSION}` | ||
); | ||
|
||
const environment = require(`./tmp/AxaGuilDEv.github.io/react-toolkit/v${PREVIOUS_VERSION}/demo/environment.json`); | ||
environment.baseUrl = `/react-toolkit/v${PREVIOUS_VERSION}/demo/`; | ||
const environment = require(`../tmp/AxaGuilDEv.github.io/react-toolkit/v${PREVIOUS_VERSION}/demo/environment.json`); | ||
environment.baseUrl = `/react-toolkit/v${PREVIOUS_VERSION}/demo/`; | ||
|
||
fs.writeFileSync(`./tmp/AxaGuilDEv.github.io/react-toolkit/v${PREVIOUS_VERSION}/demo/environment.json`, JSON.stringify(environment), 'utf8'); | ||
fs.writeFileSync( | ||
`./tmp/AxaGuilDEv.github.io/react-toolkit/v${PREVIOUS_VERSION}/demo/environment.json`, | ||
JSON.stringify(environment), | ||
'utf8' | ||
); | ||
|
||
fs.copySync(`./storybook/styles/distDemo`, `./tmp/AxaGuilDEv.github.io/react-toolkit/latest/design`); | ||
fs.copySync(`./storybook/storybook/storybook-static`, `./tmp/AxaGuilDEv.github.io/react-toolkit/latest/storybook`); | ||
fs.copySync(`./examples/demo/build`, `./tmp/AxaGuilDEv.github.io/react-toolkit/latest/demo`); | ||
const versionToSave = { version: VERSION }; | ||
fs.writeJSONSync('./tmp/AxaGuilDEv.github.io/react-toolkit/latest/version.json', versionToSave); | ||
fs.copySync( | ||
`./storybook/styles/distDemo`, | ||
`./tmp/AxaGuilDEv.github.io/react-toolkit/latest/design` | ||
); | ||
fs.copySync( | ||
`./storybook/storybook/storybook-static`, | ||
`./tmp/AxaGuilDEv.github.io/react-toolkit/latest/storybook` | ||
); | ||
fs.copySync( | ||
`./examples/demo/build`, | ||
`./tmp/AxaGuilDEv.github.io/react-toolkit/latest/demo` | ||
); | ||
const versionToSave = { version: VERSION }; | ||
fs.writeJSONSync( | ||
'./tmp/AxaGuilDEv.github.io/react-toolkit/latest/version.json', | ||
versionToSave | ||
); | ||
|
||
child = execSync(`cd ./tmp/AxaGuilDEv.github.io/ && git add . && git commit -m "doc(toolkit) publish website ${VERSION}" && git push`); | ||
console.log('error', child.error); | ||
console.log('stdout ', child.stdout); | ||
console.log('stderr ', child.stderr); | ||
child = execSync( | ||
`cd ./tmp/AxaGuilDEv.github.io/ && git add . && git commit -m "doc(toolkit) publish website ${VERSION}" && git push` | ||
); | ||
console.log('error', child.error); | ||
console.log('stdout ', child.stdout); | ||
console.log('stderr ', child.stderr); | ||
|
||
console.log('success!') | ||
} catch (err) { | ||
console.error(err) | ||
} | ||
console.log('success!'); | ||
} catch (err) { | ||
console.error(err); | ||
} |