From 8b05434689a00c67967b7d70e618023981e274bd Mon Sep 17 00:00:00 2001 From: eidng8 Date: Thu, 7 May 2020 11:43:44 +0800 Subject: [PATCH 01/39] add menu --- package-lock.json | 24 +++---- package.json | 13 ++-- scripts/make-release-note.js | 98 ++++++++++++++++++++++++++ scripts/release.bat | 50 +++++++++++++ src/components/types.ts | 4 +- src/components/xml-edit.vue | 94 ++++++++++++++++-------- src/components/xml-popup-attribute.vue | 87 +++++++++++++++++++++++ src/components/xml-popup-class.ts | 4 +- src/components/xml-popup-interface.ts | 11 +++ src/components/xml-popup.vue | 2 +- src/styles/dark.scss | 2 +- src/styles/popup.scss | 3 +- src/styles/xml-edit.scss | 9 +++ src/translations/translation.ts | 17 +---- 14 files changed, 348 insertions(+), 70 deletions(-) create mode 100644 scripts/make-release-note.js create mode 100644 scripts/release.bat create mode 100644 src/components/xml-popup-attribute.vue create mode 100644 src/components/xml-popup-interface.ts diff --git a/package-lock.json b/package-lock.json index 2acdb9f..d2e242a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1501,7 +1501,8 @@ "@types/lodash": { "version": "4.14.150", "resolved": "https://registry.npm.taobao.org/@types/lodash/download/@types/lodash-4.14.150.tgz", - "integrity": "sha1-ZJ/kRoTD8fy2Fk2UPFphl36M8L0=" + "integrity": "sha1-ZJ/kRoTD8fy2Fk2UPFphl36M8L0=", + "dev": true }, "@types/minimatch": { "version": "3.0.3", @@ -8423,28 +8424,23 @@ "dev": true }, "g8-popup-menu": { - "version": "0.0.3", - "resolved": "https://registry.npm.taobao.org/g8-popup-menu/download/g8-popup-menu-0.0.3.tgz?cache=0&sync_timestamp=1588749996751&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fg8-popup-menu%2Fdownload%2Fg8-popup-menu-0.0.3.tgz", - "integrity": "sha1-ho/xp/uDHnGoaj5DjG97+62VdJ0=", + "version": "0.0.4", + "resolved": "https://registry.npm.taobao.org/g8-popup-menu/download/g8-popup-menu-0.0.4.tgz?cache=0&sync_timestamp=1588815578502&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fg8-popup-menu%2Fdownload%2Fg8-popup-menu-0.0.4.tgz", + "integrity": "sha1-3pzJV3SNSsDzLEAbvY2yO0W0/Zs=", "requires": { - "@types/lodash": "^4.14.150", "core-js": "^3.6.4", - "g8-vue-tree": "^0.2.1", "lodash": "^4.17.15", "vue": "^2.6.11", "vue-class-component": "^7.2.3", - "vue-property-decorator": "^8.4.1", - "xml-js": "^1.6.11", - "xmldom-ts": "^0.3.1", - "xpath-ts": "^1.3.13" + "vue-property-decorator": "^8.4.1" } }, "g8-vue-tree": { - "version": "0.2.1", - "resolved": "https://registry.npm.taobao.org/g8-vue-tree/download/g8-vue-tree-0.2.1.tgz", - "integrity": "sha1-nY7KQTxr4xPpmZd213sinyUiXG8=", + "version": "0.2.2", + "resolved": "https://registry.npm.taobao.org/g8-vue-tree/download/g8-vue-tree-0.2.2.tgz", + "integrity": "sha1-1LoWDJQGqjf/Aqlon5va1y3nMoI=", "requires": { - "core-js": "^3.6.4", + "core-js": "^3.6.5", "vue": "^2.6.11", "vue-class-component": "^7.2.3", "vue-property-decorator": "^8.4.1" diff --git a/package.json b/package.json index b99103a..ede53b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "g8-xml-edit", "version": "0.0.1", - "description": "A Vue.js tree view component showing XML structure.", + "description": "A Vue.js component showing and editing XML in tree view.", "repository": "git@github.com:eidng8/xml-edit.git", "bugs": "git@github.com:eidng8/xml-edit/issues", "author": "eidng8", @@ -18,10 +18,13 @@ "keywords": [ "typescript", "vue", + "vue-component", "xml" ], "scripts": { - "build": "vue-cli-service build --target lib --mode production ./src/index.ts", + "build": "npm run build-app && npm run build-sass", + "build-app": "vue-cli-service build --target lib --mode production ./src/index.ts", + "build-sass": "node-sass --output-style compressed src/styles/index.scss > dist/g8-xml-edit.css", "docs": "vue-docgen", "serve": "vue-cli-service serve", "start": "npm run serve", @@ -34,10 +37,9 @@ "wba": "cross-env WBA=1 npm run build" }, "dependencies": { - "@types/lodash": "^4.14.150", "core-js": "^3.6.4", - "g8-popup-menu": "0.0.3", - "g8-vue-tree": "^0.2.1", + "g8-popup-menu": "0.0.4", + "g8-vue-tree": "^0.2.2", "lodash": "^4.17.15", "vue": "^2.6.11", "vue-class-component": "^7.2.3", @@ -49,6 +51,7 @@ "devDependencies": { "@bundle-analyzer/webpack-plugin": "^0.5.1", "@types/jest": "^24.0.19", + "@types/lodash": "^4.14.150", "@types/nightwatch": "^1.1.3", "@typescript-eslint/eslint-plugin": "^2.26.0", "@typescript-eslint/parser": "^2.26.0", diff --git a/scripts/make-release-note.js b/scripts/make-release-note.js new file mode 100644 index 0000000..e25d224 --- /dev/null +++ b/scripts/make-release-note.js @@ -0,0 +1,98 @@ +/* + * GPLv3 https://www.gnu.org/licenses/gpl-3.0.en.html + * + * Author: eidng8 + */ + +/* + * The change log must have at least two versions. + */ + +const fs = require('fs'); +const path = require('path'); +const version = require('../package.json').version; + +updateReleaseNotes( + updateChangeLog(path.resolve(path.join(__dirname, '../CHANGELOG.md'))), +); +console.log(version); + +/** + * Updates `Unreleased` to current version + * @param {string} file + * @return {string} + */ +function updateChangeLog(file) { + let log = fs.readFileSync(file).toString('utf-8'); + // find the `unreleased` & last version log header + const regex = /## \[(.+)]\(.+\)/gm; + const first = regex.exec(log); + const second = regex.exec(log); + // replace the `unreleased` header and comparison to current version + log = log + .replace(first[0], header(version)) + .replace( + /^\[Full Changelog]\(.+\)$/m, + `[Full Changelog](${linkCompare(second[1], version)})`, + ); + // update changelog file + fs.writeFileSync(file, log, { encoding: 'utf-8' }); + return log; +} + +/** + * Extracts current version log to release notes + * @param {string} log + */ +function updateReleaseNotes(log) { + // extract current version log to release notes + const match = /## \[.+?## \[/ms.exec(log)[0]; + const note = path.resolve(path.join(__dirname, '../RELEASE.md')); + const text = `# Vue-Tree v${version} + +A Vue.js multi-level popup menu. +Released under [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html). + + +${match.substr(0, match.length - 4)}`; + fs.writeFileSync(note, text, { + encoding: 'utf-8', + flag: 'w+', + }); +} + +/** + * @param {string} path + * @return {string} + */ +function linkRepo(path) { + path = path.trim(); + while ('/' == path[0]) path = path.slice(1); + return `https://github.com/eidng8/xml-edit/${path}`; +} + +/** + * @param {string} version + * @return {string} + */ +function linkVersion(version) { + return linkRepo(`tree/${version}`); +} + +/** + * @param {string} v1 + * @param {string} v2 + * @return {string} + */ +function linkCompare(v1, v2) { + return linkRepo(`compare/${v1}...${v2}`); +} + +/** + * @param {string} version + * @return {string} + */ +function header(version) { + const dt = new Date().toISOString().split('T')[0]; + return `## [${version}](${linkVersion(version)}) (${dt} UTC)`; +} diff --git a/scripts/release.bat b/scripts/release.bat new file mode 100644 index 0000000..45e22e5 --- /dev/null +++ b/scripts/release.bat @@ -0,0 +1,50 @@ +@ECHO OFF +SETLOCAL EnableDelayedExpansion + +set CWD=%cd% + +cd /d "%~dp0" +cd .. + +if exist release rd /s /q release +mkdir release +cd release +git clone --branch master "https://github.com/eidng8/xml-edit.git" +cd xml-edit +git config user.email "cheung.jackey@gmail.com" +git config user.name eidng8 + +set RELEASE=%1 +if "%RELEASE%"=="" set RELEASE=patch +call npm --no-git-tag-version version "%RELEASE%" || goto ERR + +bash.exe -lc github_changelog_generator || goto ERR +for /f "tokens=*" %%v in ('node scripts\make-release-note.js') do set VERSION=%%v + +git add . || goto ERR +git commit --no-verify -m "Release %VERSION%" || goto ERR +git push --no-verify || goto ERR +git tag --sign -m "%date%" "Release-v%VERSION%" +git push --no-verify --tags || goto ERR + +git checkout dev +git merge master +git push --no-verify + + +goto END + + +:ERR +echo Error occurred! +cd ..\.. +rd /s /q release +cd "%CWD%" +pause +exit 1 + +:END +cd ..\.. +rd /s /q release +git pull +cd "%CWD%" diff --git a/src/components/types.ts b/src/components/types.ts index 980a5c0..6856646 100644 --- a/src/components/types.ts +++ b/src/components/types.ts @@ -70,14 +70,14 @@ export class SaveNodeMouseEvent extends MouseEvent { /** * This node will not have `parent` or `nodes`. */ - data!: XmlNodeTypes | XmlEditDeclaration; + data!: XmlNodeTypes | XmlEditDeclaration | XmlAttribute; } export class SaveNodeKeyboardEvent extends KeyboardEvent { /** * This node will not have `parent` or `nodes`. */ - data!: XmlNodeTypes | XmlEditDeclaration; + data!: XmlNodeTypes | XmlEditDeclaration | XmlAttribute; } export function isDeclarationNode( diff --git a/src/components/xml-edit.vue b/src/components/xml-edit.vue index 00ed511..ad849fe 100644 --- a/src/components/xml-edit.vue +++ b/src/components/xml-edit.vue @@ -6,7 +6,7 @@