-
Notifications
You must be signed in to change notification settings - Fork 385
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
Showing
5 changed files
with
177 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
* text eol=lf | ||
|
||
# images | ||
*.gif binary | ||
*.jpg binary | ||
*.png binary | ||
*.svg binary | ||
*.ico binary | ||
|
||
# fonts | ||
*.eot binary | ||
*.ttf binary | ||
*.woff binary |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
branches: | ||
except: | ||
- gh-pages |
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
const { join } = require('path'); | ||
const { readFileSync, writeFileSync } = require('fs'); | ||
const { execSync } = require('child_process'); | ||
const { prompt } = require('inquirer'); | ||
const { valid, lt, inc, prerelease } = require('semver'); | ||
|
||
console.log('===================='); | ||
console.log(`| Publishing npm packages`); | ||
console.log('===================='); | ||
|
||
const currentVersion = require('../lerna.json').version; | ||
const suggestedVersion = inc(currentVersion, (prerelease(currentVersion) !== null ? 'prerelease' : 'patch')); | ||
|
||
prompt({ | ||
name: 'version', | ||
message: `Enter new version [current: ${currentVersion}]:`, | ||
default: suggestedVersion, | ||
validate: (input) => { | ||
if(valid(input) === null) | ||
return 'Version is invalid'; | ||
if(lt(input, currentVersion)) | ||
return 'New version should be greate than current'; | ||
|
||
return true; | ||
} | ||
}) | ||
.then(({ version }) => { | ||
console.log(); | ||
|
||
console.log('Fetching the latest changes from upstream...'); | ||
execSync('git checkout master'); | ||
execSync('git fetch upstream master'); | ||
execSync('git merge --ff-only'); | ||
|
||
console.log('Cleaning previous build result...'); | ||
const rmScript = "require('fs-extra').removeSync(require('path').join(process.cwd(), 'dist'))"; | ||
execSync(`./node_modules/.bin/lerna exec --loglevel silent -- node -e "\\"${rmScript}\\""`); | ||
|
||
console.log('Installing dependencies...'); | ||
execSync('npm install'); | ||
|
||
console.log('Building...'); | ||
execSync('npm run build'); | ||
|
||
console.log('Genereting CHANGELOG.md...'); | ||
const changelogFile = join(process.cwd(), 'CHANGELOG.md'); | ||
execSync('./node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s'); | ||
writeFileSync( | ||
changelogFile, | ||
String(readFileSync(changelogFile)) | ||
.replace('name=""', `name="${version}"`) | ||
.replace('[](', `[${version}](`) | ||
.replace('...v)', `...v${version})`), | ||
); | ||
|
||
prompt({ | ||
message: 'Ready to publish. Please check build result and CHANGELOG.md. Is it ok?', | ||
name: 'publishNpm', | ||
type: 'confirm', | ||
default: false, | ||
}) | ||
.then(({ publishNpm }) => { | ||
if (!publishNpm) { | ||
console.log('Npm publishing is aborted...'); | ||
return; | ||
} | ||
|
||
console.log('Login into npm...'); | ||
try { execSync('npm logout', { stdio: 'ignore' }); } catch (e) {} | ||
execSync('npm login', { stdio: 'inherit' }); | ||
|
||
console.log('Publishing npm...'); | ||
execSync(`./node_modules/.bin/lerna publish --exact --force-publish * --repo-version ${version} --yes --skip-git`); | ||
|
||
console.log('Logout from npm...'); | ||
execSync('npm logout', { stdio: 'ignore' }); | ||
|
||
console.log('Preparing pull request...'); | ||
const commitMessage = `chore: publish ${version}`; | ||
const branchName = `v${version.replace(/\./g, '-')}`; | ||
execSync(`git checkout -b "${branchName}"`); | ||
execSync('git add .'); | ||
execSync(`git commit -m "${commitMessage}"`); | ||
execSync(`git push origin ${branchName}`); | ||
execSync(`git checkout master`); | ||
|
||
console.log('--------------------'); | ||
console.log(`You have to pull request changes from branch ${branchName}!`); | ||
console.log(`Don\'t forget to create a release on GitHub!`); | ||
console.log('--------------------'); | ||
|
||
prompt({ | ||
message: 'It is a good point to publish site. Proceed?', | ||
name: 'publishSite', | ||
type: 'confirm', | ||
default: false, | ||
}) | ||
.then(({ publishSite }) => { | ||
if (!publishSite) { | ||
console.log('Site publishing is aborted...'); | ||
return; | ||
} | ||
|
||
execSync(`npm run publish:site`); | ||
}); | ||
}); | ||
}); | ||
|
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const { join } = require('path'); | ||
const { execSync } = require('child_process'); | ||
const { publish } = require('gh-pages'); | ||
const { copySync, removeSync } = require('fs-extra'); | ||
|
||
|
||
const SITE_DIRECTORY = join(process.cwd(), 'site'); | ||
const GENERATED_SITE_DIRECTORY = join(process.cwd(), 'site/_site'); | ||
const REPO = 'devexpress/devextreme-reactive'; | ||
const BRANCH = 'gh-pages'; | ||
const COMMIT_MESSAGE = 'chore: update site'; | ||
|
||
|
||
console.log('===================='); | ||
console.log(`| Publishing site to ${REPO}@${BRANCH}`); | ||
console.log('| Assume that repo is clean and up to date') | ||
console.log('===================='); | ||
console.log(); | ||
|
||
console.log('Building site content...'); | ||
execSync('npm run build:site'); | ||
|
||
console.log('Cleaning generated site...'); | ||
removeSync(GENERATED_SITE_DIRECTORY); | ||
|
||
console.log('Generating site...'); | ||
execSync(`bundle exec jekyll build --source ${SITE_DIRECTORY} --destination ${GENERATED_SITE_DIRECTORY}`, { cwd: SITE_DIRECTORY }); | ||
|
||
console.log('Coping github staff...'); | ||
copySync(join(__dirname, 'gh-pages-files'), GENERATED_SITE_DIRECTORY); | ||
|
||
console.log('Publishing...'); | ||
publish(GENERATED_SITE_DIRECTORY, { | ||
branch: BRANCH, | ||
repo: `https://github.com/${REPO}.git`, | ||
message: COMMIT_MESSAGE, | ||
src: ['**/*', '.gitattributes'], | ||
}, (err) => { | ||
if (err) { | ||
console.log(String(err)); | ||
return; | ||
} | ||
console.log(`Published!`); | ||
}); |