Skip to content

Commit

Permalink
chore(demo) fix deployment (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumechervetaxa authored Feb 15, 2019
1 parent 16871de commit 7fa3948
Showing 1 changed file with 51 additions and 29 deletions.
80 changes: 51 additions & 29 deletions scripts/publish-docs.js
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);
}

0 comments on commit 7fa3948

Please sign in to comment.