From a67af87fb734f0b5dedf36501210d00ee0f529fc Mon Sep 17 00:00:00 2001 From: guidohollander Date: Thu, 1 Jun 2023 13:21:09 +0200 Subject: [PATCH] first commit --- .gitignore | 130 +++++++++++++++++ .vscode/launch.json | 20 +++ .vscode/tasks.json | 27 ++++ package-lock.json | 164 ++++++++++++++++++++++ package.json | 20 +++ solutions.json | 75 ++++++++++ src/SolutionImplementation.ts | 209 ++++++++++++++++++++++++++++ src/SolutionImplementationReader.ts | 23 +++ src/index.ts | 110 +++++++++++++++ src/promises.ts | 13 ++ src/types.ts | 36 +++++ tsconfig.json | 109 +++++++++++++++ 12 files changed, 936 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 solutions.json create mode 100644 src/SolutionImplementation.ts create mode 100644 src/SolutionImplementationReader.ts create mode 100644 src/index.ts create mode 100644 src/promises.ts create mode 100644 src/types.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a7d6d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,130 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e779ecc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}/dist/index.js", + "outFiles": [ + "${workspaceFolder}/**/*.js" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1f4d92e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,27 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "typescript", + "tsconfig": "tsconfig.json", + "option": "watch", + "problemMatcher": [ + "$tsc-watch" + ], + "group": "build", + "label": "tsc: watch - tsconfig.json" + }, + { + "type": "typescript", + "tsconfig": "tsconfig.json", + "problemMatcher": [ + "$tsc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "tsc: build - tsconfig.json" + } + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..689c3f5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,164 @@ +{ + "name": "chap1", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "chap1", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "node-svn-ultimate": "^1.2.1", + "semver": "^7.5.1" + }, + "devDependencies": { + "@types/node": "^20.2.3", + "@types/semver": "^7.5.0", + "typescript": "^5.0.4" + } + }, + "node_modules/@types/node": { + "version": "20.2.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.3.tgz", + "integrity": "sha512-pg9d0yC4rVNWQzX8U7xb4olIOFuuVL9za3bzMT2pu2SU0SNEi66i2qrvhE2qt0HvkhuCaWJu7pLNOt/Pj8BIrw==", + "dev": true + }, + "node_modules/@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, + "node_modules/fs-extra": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", + "integrity": "sha512-VerQV6vEKuhDWD2HGOybV6v5I73syoc/cXAbKlgTC7M/oFVEtklWlp9QH2Ijw3IaWDOQcMkldSPa7zXy79Z/UQ==", + "dependencies": { + "graceful-fs": "^4.1.2", + "jsonfile": "^2.1.0", + "klaw": "^1.0.0" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/jsonfile": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==", + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/klaw": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", + "integrity": "sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==", + "optionalDependencies": { + "graceful-fs": "^4.1.9" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-svn-ultimate": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/node-svn-ultimate/-/node-svn-ultimate-1.2.1.tgz", + "integrity": "sha512-WqNyOq3hW/A2Hi/MAMFu3PhnCzGdTnGaR6Cfr65OL7Qa8pLvlMbJ21t7Vko3CYngnI6Zn1JmKwtA3SlEcFC61A==", + "dependencies": { + "fs-extra": "^1.0.0", + "semver": "^5.3.0", + "uuid": "^3.0.0", + "xml2js": "^0.4.17" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/node-svn-ultimate/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "node_modules/semver": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } + }, + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..aa0381f --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "chap1", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "@types/node": "^20.2.3", + "@types/semver": "^7.5.0", + "typescript": "^5.0.4" + }, + "dependencies": { + "node-svn-ultimate": "^1.2.1", + "semver": "^7.5.1" + } +} diff --git a/solutions.json b/solutions.json new file mode 100644 index 0000000..9ddb5f3 --- /dev/null +++ b/solutions.json @@ -0,0 +1,75 @@ +[ + { + "name": "MBS_ANGUILLA", + "functionalName": "MBS Anguilla", + "customer": "ANGUILLA", + "customerCode": "aia_mbs", + "path": "D:\\repo\\mbs_anguilla_21\\", + "class": "MxS", + "url": "https://svn.bearingpointcaribbean.com/svn/MBS_ANGUILLA/trunk" + }, + { + "name": "MTS_ANGUILLA", + "functionalName": "MTS Anguilla", + "customer": "ANGUILLA", + "customerCode": "aia_mts", + "path": "D:\\repo\\mts_anguilla_21\\", + "class": "MxS", + "url": "https://svn.bearingpointcaribbean.com/svn/MTS_ANGUILLA/trunk" + }, + { + "name": "ONLINE_ANGUILLA", + "functionalName": "Online Anguilla", + "customer": "ANGUILLA", + "customerCode": "aia_online", + "path": "D:\\repo\\online_anguilla\\", + "class": "ONLINE", + "url": "https://svn.bearingpointcaribbean.com/svn/ONLINE_ANGUILLA/trunk" + }, + { + "name": "MTS_SKN", + "functionalName": "MTS Saint Kitts and Nevis", + "customer": "SKN", + "customerCode": "skn_mts", + "path": "D:\\repo\\mts_skn\\", + "class": "MxS", + "url": "https://svn.bearingpointcaribbean.com/svn/MTS_SKN/trunk" + }, + { + "name": "ONLINE_SKN", + "functionalName": "Online Saint Kitts and Nevis", + "customer": "SKN", + "customerCode": "skn_online", + "path": "D:\\repo\\online_skn\\", + "class": "ONLINE", + "url": "https://svn.bearingpointcaribbean.com/svn/ONLINE_SKN/trunk" + }, + { + "name": "BDSU_MTS", + "functionalName": "MTS Belastingdienst Suriname", + "customer": "Belastingdienst Suriname", + "customerCode": "bdsu_mts", + "path": "D:\\repo\\mts_bdsu\\", + "class": "MxS", + "url": "https://svn.bearingpointcaribbean.com/svn/BDSU_MTS/trunk", + "test": true + }, + { + "name": "MTS_GRENADA", + "functionalName": "MTS Grenada", + "customer": "GRENADA", + "customerCode": "gd_mts", + "path": "D:\\repo\\mts_grenada\\", + "class": "MxS", + "url": "https://svn.bearingpointcaribbean.com/svn/MTS_GRENADA/trunk" + }, + { + "name": "ONLINE_GD", + "functionalName": "Online Grenada", + "customer": "GRENADA", + "customerCode": "gd_online", + "path": "D:\\repo\\online_gd\\", + "class": "ONLINE", + "url": "https://svn.bearingpointcaribbean.com/svn/ONLINE_GD/trunk" + } +] \ No newline at end of file diff --git a/src/SolutionImplementation.ts b/src/SolutionImplementation.ts new file mode 100644 index 0000000..9c788e6 --- /dev/null +++ b/src/SolutionImplementation.ts @@ -0,0 +1,209 @@ +import semver from 'semver'; +import { SemVerIncrementType, ApiExternalsResponse } from './types'; +import { svnList, svnGetLatestTag, svnPropGet } from './promises'; + +export class SolutionImplementation { + private url: string = ''; + private baseURL: string = ''; + private repository: string = ''; + private repositoryURL: string = ''; + private componentFolder: string | null = null; + private _isSolutionComponent: boolean = false; + private _isImplementation: boolean = false; + private implementationURL: string = '' + private type: string = ''; + private version: string | null = null; + private nextVersion: string | null = null; + private previousVersion: string | null = null; + private component: string = ''; + private externals: []; + + constructor(url: string) { + this.parseUrl(url); + } + + private parseUrl(url: string): void { + + this.url = url; + + const regex = /^(https?:\/\/[^\/]+\/svn\/)/; + const match = url.match(regex); + + if (match && match.length > 1) { + this.baseURL = match[1]; + } else { + throw new Error('Invalid URL'); + } + + const segments = url.split('/'); + const svnIndex = segments.indexOf('svn'); + const trunkTagBranchIndex = segments.findIndex( + (segment, index) => index > svnIndex && (segment === 'trunk' || segment === 'tags' || segment === 'branches') + ); + this._isSolutionComponent = (trunkTagBranchIndex - svnIndex > 2); + + if (svnIndex !== -1 && svnIndex + 1 < segments.length) { + this.repository = segments[svnIndex + 1]; + this.repositoryURL = `${this.baseURL}${this.repository}`; + + if (trunkTagBranchIndex !== -1 && trunkTagBranchIndex - 1 > svnIndex) { + const nextSegment = segments[trunkTagBranchIndex - 1]; + + if (nextSegment !== 'trunk' && nextSegment !== 'tags' && nextSegment !== 'branches') { + if (this._isSolutionComponent) { + this.componentFolder = nextSegment; + } + } + } + + if (trunkTagBranchIndex !== -1 && trunkTagBranchIndex < segments.length) { + this.type = segments[trunkTagBranchIndex]; + + if (this.type === 'tags' || this.type === 'branches') { + if (trunkTagBranchIndex + 1 < segments.length) { + this.version = segments[trunkTagBranchIndex + 1]; + if (trunkTagBranchIndex + 2 < segments.length) { + this.component = segments[trunkTagBranchIndex + 2]; + } + } + } else { + if (trunkTagBranchIndex + 1 < segments.length) { + this.component = segments[trunkTagBranchIndex + 1]; + } + } + } + + this._isImplementation = (this.componentFolder === null && this.component === ''); + this.implementationURL = segments.slice(0, trunkTagBranchIndex + ((this.version !== null) ? 2 : 1)).join('/'); + + if (this._isImplementation) { + const rawExternals = this.getExternals(url); + } + + if (this._isImplementation) { + + } + + } else { + throw new Error('Invalid URL'); + } + } + + + getBaseURL(): string { + return this.baseURL; + } + + getURL(): string { + return this.url; + } + + getImplementationURL(): string { + return this.implementationURL + } + + getRepository(): string { + return this.repository; + } + + getRepositoryURL(): string { + return this.repositoryURL; + } + + getComponentFolder(): string | null { + return this.componentFolder; + } + + isSolutionComponent(): boolean { + return this._isSolutionComponent; + } + + isImplementation(): boolean { + return this._isImplementation; + } + + getType(): string { + return this.type; + } + + getVersion(): string | null { + return this.version; + } + + public async getNextVersion(semVerIncrementType: SemVerIncrementType): Promise { + await this.getLatestTag() + .then((result) => { + if (semver.valid(semver.coerce(result))) { + const sv: string = result; + this.nextVersion = semver.inc(sv, semVerIncrementType); + } else { + this.nextVersion = null + } + }) + .catch((error) => { + // Handle error + }); + return this.nextVersion; + + } + + public async getLatestTag(): Promise { + try { + const lastTagOrBranch = await svnGetLatestTag(this.implementationURL); + return lastTagOrBranch.name; + } catch (error) { + console.error('Error retrieving last tag or branch:', error); + throw error; + } + } + + getTypeAndVersion(): string { + if (this.type === 'tags' || this.type === 'branches') { + return `${this.type}/${this.version}`; + } else { + return `${this.type}`; + } + } + + getComponent(): string { + return this.component; + } + + getComponentDecoded(): string { + return decodeURIComponent(this.component); + } + + getExternalsRaw(): string { + return decodeURIComponent(this.component); + } + + // getExternalsCollection(): externalsCollection { + // return decodeURIComponent(this.component); + // } + + public async getExternals(): Promise { + const svnOptions = { trustServerCert: true }; + try { + const response: ApiExternalsResponse = await svnPropGet('svn:externals', this.url, svnOptions); + const rawExternals: string = response.target.property._ + return rawExternals; + } catch (error) { + console.error('Error retrieving last tag or branch:', error); + throw error; + } + } + +} + +// Helper function to retrieve the last tag or branch +// async function getLastTagOrBranch(url: string): Promise { +// try { +// const list = await svnListPromise(url); +// const sortedList = list.sort((a, b) => b.date.getTime() - a.date.getTime()); +// const lastTagOrBranch = sortedList[0].name; +// return lastTagOrBranch; +// } catch (error) { +// throw error; +// } +// } + diff --git a/src/SolutionImplementationReader.ts b/src/SolutionImplementationReader.ts new file mode 100644 index 0000000..306e93a --- /dev/null +++ b/src/SolutionImplementationReader.ts @@ -0,0 +1,23 @@ +import * as fs from 'fs'; +import { ISolutionImplementation } from './types'; +import { SolutionImplementation } from "./SolutionImplementation"; + + + +export class SolutionImplementationReader { + private solutionImplementations: ISolutionImplementation[]; + + constructor() { + const json = fs.readFileSync('solutions.json', 'utf-8'); + this.solutionImplementations = JSON.parse(json); + } + + public readSolutionUrl(): void { + this.solutionImplementations.forEach((solutionImplementation: ISolutionImplementation) => { + let s = new SolutionImplementation(solutionImplementation.url); + console.log(JSON.stringify(s, null, 2)); + }); + } +} + + diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..ff5eb1f --- /dev/null +++ b/src/index.ts @@ -0,0 +1,110 @@ +import { SolutionImplementation } from "./SolutionImplementation"; +import { SolutionImplementationReader } from "./SolutionImplementationReader"; + +// const trunkUrl = 'https://svn.bearingpointcaribbean.com/svn/MTS_ANGLO/Business_Licence/trunk/DSC%20Business%20license'; +// const tagUrl = 'https://svn.bearingpointcaribbean.com/svn/MTS_ANGLO/Interim_Stabilization_Levy/tags/1.0.0/DSC%20Interim%20stabilization%20levy'; +// const branchUrl = 'https://svn.bearingpointcaribbean.com/svn/MTS_ANGUILLA/branches/1.5.0/SC%20Address%20-%20Specific'; +// const trunkSolutionUrl = 'https://svn.bearingpointcaribbean.com/svn/MTS_ANGUILLA/trunk'; +// const tagSolutionUrl = 'https://svn.bearingpointcaribbean.com/svn/MTS_ANGUILLA/tags/2.1.1.1'; +// const branchSolutionUrl = 'https://svn.bearingpointcaribbean.com/svn/MTS_ANGUILLA/branches/2.1.1'; + +async function showOutPut() { + let solution = new SolutionImplementation(branchSolutionUrl); + console.log('solution.getURL():', solution.getURL()); + console.log('solution.getBaseURL():', solution.getBaseURL()); + console.log('solution.getRepository():', solution.getRepository()); + console.log('solution.getComponentFolder():', solution.getComponentFolder()); + console.log('solution.isSolutionComponent():', solution.isSolutionComponent()); + console.log('solution.isImplementation():', solution.isImplementation()); + console.log('solution.getType():', solution.getType()); + console.log('solution.getVersion():', solution.getVersion()); + console.log('solution.getTypeAndVersion():', solution.getTypeAndVersion()); + console.log('solution.getComponent():', solution.getComponent()); + console.log('solution.getComponentDecoded():', solution.getComponentDecoded()); + console.log('solution.getImplementationURL():', solution.getImplementationURL()); + console.log('solution.getLatestTag:', await solution.getLatestTag()); + console.log('solution.getNextVersion("minor"):', await solution.getNextVersion('minor')); + console.log('--'); +} + +// showOutPut(); + +// Usage +const solutionImplementations = []; +const solutionImplementationReader = new SolutionImplementationReader(); +solutionImplementations.push(solutionImplementationReader.readSolutionUrl(); + +// solution = new SolutionImplementation(tagUrl); +// console.log('solution.getURL():', solution.getURL()); +// console.log('solution.getBaseURL():', solution.getBaseURL()); +// console.log('solution.getRepository():', solution.getRepository()); +// console.log('solution.getComponentFolder():', solution.getComponentFolder()); +// console.log('solution.isSolutionComponent():', solution.isSolutionComponent()); +// console.log('solution.isImplementation():', solution.isImplementation()); +// console.log('solution.getType():', solution.getType()); +// console.log('solution.getVersion():', solution.getVersion()); +// console.log('solution.getTypeAndVersion():', solution.getTypeAndVersion()); +// console.log('solution.getComponent():', solution.getComponent()); +// console.log('solution.getComponentDecoded():', solution.getComponentDecoded()); +// console.log('solution.getImplementationURL():', solution.getImplementationURL()); +// console.log('--'); + +// solution = new SolutionImplementation(branchUrl); +// console.log('solution.getURL():', solution.getURL()); +// console.log('solution.getBaseURL():', solution.getBaseURL()); +// console.log('solution.getRepository():', solution.getRepository()); +// console.log('solution.getComponentFolder():', solution.getComponentFolder()); +// console.log('solution.isSolutionComponent():', solution.isSolutionComponent()); +// console.log('solution.isImplementation():', solution.isImplementation()); +// console.log('solution.getType():', solution.getType()); +// console.log('solution.getVersion():', solution.getVersion()); +// console.log('solution.getTypeAndVersion():', solution.getTypeAndVersion()); +// console.log('solution.getComponent():', solution.getComponent()); +// console.log('solution.getComponentDecoded():', solution.getComponentDecoded()); +// console.log('solution.getImplementationURL():', solution.getImplementationURL()); +// console.log('--'); + +// solution = new SolutionImplementation(trunkSolutionUrl); +// console.log('solution.getURL():', solution.getURL()); +// console.log('solution.getBaseURL():', solution.getBaseURL()); +// console.log('solution.getRepository():', solution.getRepository()); +// console.log('solution.getComponentFolder():', solution.getComponentFolder()); +// console.log('solution.isSolutionComponent():', solution.isSolutionComponent()); +// console.log('solution.isImplementation():', solution.isImplementation()); +// console.log('solution.getType():', solution.getType()); +// console.log('solution.getVersion():', solution.getVersion()); +// console.log('solution.getTypeAndVersion():', solution.getTypeAndVersion()); +// console.log('solution.getComponent():', solution.getComponent()); +// console.log('solution.getComponentDecoded():', solution.getComponentDecoded()); +// console.log('solution.getImplementationURL():', solution.getImplementationURL()); +// console.log('--'); + +// solution = new SolutionImplementation(tagSolutionUrl); +// console.log('solution.getURL():', solution.getURL()); +// console.log('solution.getBaseURL():', solution.getBaseURL()); +// console.log('solution.getRepository():', solution.getRepository()); +// console.log('solution.getComponentFolder():', solution.getComponentFolder()); +// console.log('solution.isSolutionComponent():', solution.isSolutionComponent()); +// console.log('solution.isImplementation():', solution.isImplementation()); +// console.log('solution.getType():', solution.getType()); +// console.log('solution.getVersion():', solution.getVersion()); +// console.log('solution.getTypeAndVersion():', solution.getTypeAndVersion()); +// console.log('solution.getComponent():', solution.getComponent()); +// console.log('solution.getComponentDecoded():', solution.getComponentDecoded()); +// console.log('solution.getImplementationURL():', solution.getImplementationURL()); +// console.log('--'); + +// solution = new SolutionImplementation(branchSolutionUrl); +// console.log('solution.getURL():', solution.getURL()); +// console.log('solution.getBaseURL():', solution.getBaseURL()); +// console.log('solution.getRepository():', solution.getRepository()); +// console.log('solution.getComponentFolder():', solution.getComponentFolder()); +// console.log('solution.isSolutionComponent():', solution.isSolutionComponent()); +// console.log('solution.isImplementation():', solution.isImplementation()); +// console.log('solution.getType():', solution.getType()); +// console.log('solution.getVersion():', solution.getVersion()); +// console.log('solution.getTypeAndVersion():', solution.getTypeAndVersion()); +// console.log('solution.getComponent():', solution.getComponent()); +// console.log('solution.getComponentDecoded():', solution.getComponentDecoded()); +// console.log('solution.getImplementationURL():', solution.getImplementationURL()); + diff --git a/src/promises.ts b/src/promises.ts new file mode 100644 index 0000000..b9a1523 --- /dev/null +++ b/src/promises.ts @@ -0,0 +1,13 @@ +import { promisify } from 'util'; +import * as nodeSVNUltimate from 'node-svn-ultimate'; + +// Promisify individual functions +const svnList = promisify(nodeSVNUltimate.commands.list); +const svnGetLatestTag = promisify(nodeSVNUltimate.util.getLatestTag); +const svnPropGet = promisify(nodeSVNUltimate.commands.propget); + +export { + svnList, + svnGetLatestTag, + svnPropGet + }; diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..26f3d51 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,36 @@ +export type SemVerIncrementType = 'minor' | 'major' | 'patch'; + +export interface User { + id: number; + name: string; + email: string; +} + +export enum Role { + ADMIN = 'admin', + USER = 'user', +} + +export interface ISolutionImplementation { + name: string; + functionalName: string; + customer: string; + customerCode: string; + path: string; + class: string; + url: string; +} + +export interface ApiExternalsResponse { + target: { + $: { + path: string; + }; + property: { + _: string; + $: { + name: string; + }; + }; + }; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..59d41ef --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,109 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + "rootDir": "src", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "dist", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +}