From 7de59a4aaa79885fced8d776b5e5a0708de595ad Mon Sep 17 00:00:00 2001 From: christopher Date: Tue, 3 Nov 2020 16:15:27 +0530 Subject: [PATCH] issues --- .github/workflows/node.js.yml | 31 +++++++++++ .github/workflows/publish.js.yml | 47 +++++++++++++++++ .gitignore | 8 +++ gulpfile.js | 88 ++++++++++++++++++++++++++++++++ package.json | 46 +++++++++++++++++ 5 files changed, 220 insertions(+) create mode 100644 .github/workflows/node.js.yml create mode 100644 .github/workflows/publish.js.yml create mode 100644 .gitignore create mode 100644 gulpfile.js create mode 100644 package.json diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..18ec230 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + pull_request: + branches: [ master ] + types: [opened, closed, edited, synchronize] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install + run: npm i + diff --git a/.github/workflows/publish.js.yml b/.github/workflows/publish.js.yml new file mode 100644 index 0000000..a8b062f --- /dev/null +++ b/.github/workflows/publish.js.yml @@ -0,0 +1,47 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: set environment variables + uses: allenevans/set-env@v1.0.0 + with: + GIT_USER: ${{ secrets.WEB_GITLAB_USER }} + GIT_TOKEN: ${{ secrets.WEB_GITLAB_TOKEN }} + GIT_MAIL: ${{ secrets.USER_MAIL }} + + - name: Install + run: npm i + + - name: Get changed files + run: | + git diff --name-only HEAD^ HEAD + + - name: Publish + run: npm run publish + env: + GIT_USER: ${{ secrets.WEB_GITLAB_USER }} + GIT_TOKEN: ${{ secrets.WEB_GITLAB_TOKEN }} + GIT_MAIL: ${{ secrets.USER_MAIL }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..328a3b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.npmrc +dist/ +.vscode/ +coverage/ +index.js +index.d.ts +gulpfile.js +node_modules/ \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..5d4e8a2 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,88 @@ +var fs = require('fs'); +var gulp = require('gulp'); +var glob = require('glob'); +var shelljs = require('shelljs'); +var path = require('path'); +var branch = 'master'; +var user = process.env.GIT_USER; +var token = process.env.GIT_TOKEN; +var user_mail = process.env.GIT_MAIL; +var is_temp = process.env.IS_TEMP; +var changedFileNames; +var changes; +/** + * Source shipping to gitlab + */ +gulp.task('ship-to-gitlab', function (done) { + changedFileNames = changedFileNameList(); + console.log('--changedFileNames----' + changedFileNames); + var gitPath = 'https://' + user + ':' + token + `@gitlab.syncfusion.com/content/winui-docs`; + console.log('Clone has been started...!'); + var clone = shelljs.exec('git clone ' + gitPath + ' -b ' + branch + ' ' + `../../../gitlabRepo/winui-docs`, { + silent: false + }); + if (clone.code !== 0) { + console.log(clone.stderr); + done(); + return; + } else { + console.log('Clone has been completed...!'); + // update src from github to gitlab - replace files from cloned repo + + for (var changedFileName of changedFileNames.split(',')) { + + if (changedFileName !== null && changedFileName !== '') { + + if (fs.existsSync('../winui-docs/' + changedFileName)) { + // It will update the modified files + if (fs.existsSync('../../../gitlabRepo/winui-docs/' + changedFileName)) { + shelljs.cp('-rf', `../winui-docs/` + changedFileName, `../../../gitlabRepo/winui-docs/` + changedFileName); + } + else { + // It will update the newly added files + if (fs.existsSync('../../../gitlabRepo/winui-docs/')) { + shelljs.cp('-rf', `../winui-docs/` + changedFileName, `../../../gitlabRepo/winui-docs/` + changedFileName); + } + } + + } + else { + // It will remove the deleted files + if (fs.existsSync('../../../gitlabRepo/winui-docs/' + changedFileName)) { + shelljs.rm('-rf', `../../../gitlabRepo/winui-docs/` + changedFileName); + + } + } + + } + + } + + shelljs.cd(`../../../gitlabRepo/winui-docs`); + shelljs.exec('git add .'); + shelljs.exec('git pull'); + shelljs.exec('git commit -m \"source updation from github repo \" --no-verify'); + shelljs.exec('git push'); + shelljs.cd('../../'); + } +}) + +// Controls List +function changedFileNameList() { + shelljs.exec(`git config --global user.email "${user_mail}"`); + shelljs.exec(`git config --global user.name "${user}"`); + changes = shelljs.exec(`git diff --name-status HEAD^ HEAD`); + var controls = ''; + var changesList = changes.stdout.split('\n'); + if (changesList !== null && changesList !== '') { + for (var comp of changesList) { + controls += comp.replace(/A\s+/g, "").replace(/M\s+/g, "").replace(/D\s+/g, "").replace(/R100\s+/g, "").split(/\s+/g) + ','; + } + return controls; + } +} + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..c14a034 --- /dev/null +++ b/package.json @@ -0,0 +1,46 @@ +{ + "name": "@Syncfusion/winui-docs", + "version": "1.0.0", + "description": "Syncfusion TypeScript common documentation", + "author": "Syncfusion Inc.", + "license": "UNLICENSED", + "dependencies": { + "core-js": "^2.5.7", + "cheerio": "^1.0.0-rc.2", + "gulp": "^3.9.1", + "gulp-csslint": "^1.0.1", + "gulp-csslint-report": "^2.0.0", + "gulp-gzip": "^1.4.2", + "lodash": "^4.17.11", + "markdownlint": "^0.11.0", + "markdown-link-extractor": "^1.2.0", + "markdown-spellcheck": "^1.3.1", + "prismjs": "^1.15.0", + "require-dir": "^1.0.0", + "shelljs": "^0.8.2", + "styled-components": "^3.4.9", + "typeface-merriweather": "0.0.43", + "typeface-montserrat": "0.0.43", + "typo-js": "^1.0.3", + "typescript": "^2.6.2", + "typography": "^0.16.17", + "typography-theme-wordpress-2016": "^0.15.10", + "webpack": "4.28.4", + "terser": "3.14.1" + }, + "devDependencies": { + "eslint": "^4.19.1", + "eslint-plugin-react": "^7.11.1", + "gh-pages": "^1.2.0", + "json-loader": "^0.5.7", + "prettier": "^1.14.2" + }, + "config": { + "ghooks": { + "pre-commit": "gulp test" + } + }, + "scripts": { + "publish": "gulp ship-to-gitlab" + } +}