From 66e45154e3db2198cce8a267919299c8fd11f42b Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sat, 15 Aug 2020 13:51:24 +0000 Subject: [PATCH] fix(core): update --- .gitignore | 4 +- .gitlab-ci.yml | 102 ++++++++++++++++++++++----------- .vscode/launch.json | 29 ++++++++++ .vscode/settings.json | 26 +++++++++ README.md | 76 ------------------------ npmextra.json | 1 - package.json | 21 ++++--- ts/smartgit.classes.gitrepo.ts | 4 +- 8 files changed, 138 insertions(+), 125 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json delete mode 100644 README.md diff --git a/.gitignore b/.gitignore index 91c0db0..ef13c79 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,6 @@ node_modules/ # builds dist/ -dist_web/ -dist_serve/ -dist_ts_web/ +dist_*/ # custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d4acf4..9a4467e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,14 +3,14 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci cache: paths: - - .npmci_cache/ - key: "$CI_BUILD_STAGE" + - .npmci_cache/ + key: '$CI_BUILD_STAGE' stages: -- security -- test -- release -- metadata + - security + - test + - release + - metadata # ==================== # security stage @@ -18,48 +18,74 @@ stages: mirror: stage: security script: - - npmci git mirror + - npmci git mirror + only: + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv -snyk: +auditProductionDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - npmci npm prepare - - npmci command npm install -g snyk - - npmci command npm install --ignore-scripts - - npmci command snyk test + - npmci command npm install --production --ignore-scripts + - npmci command npm config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high --only=prod --production tags: - - docker - - notpriv + - docker + +auditDevDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci + stage: security + script: + - npmci npm prepare + - npmci command npm install --ignore-scripts + - npmci command npm config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high --only=dev + tags: + - docker + allow_failure: true # ==================== # test stage # ==================== -testLTS: +testStable: stage: test script: - - npmci npm prepare - - npmci node install lts - - npmci npm install - - npmci npm test + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - notpriv + - docker + +testBuild: + stage: test + script: + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci command npm run build + coverage: /\d+.?\d+?\%\s*coverage/ + tags: + - docker release: stage: release script: - - npmci node install lts - - npmci npm publish + - npmci node install stable + - npmci npm publish only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv # ==================== # metadata stage @@ -67,33 +93,39 @@ release: codequality: stage: metadata allow_failure: true + only: + - tags script: - npmci command npm install -g tslint typescript + - npmci npm prepare - npmci npm install - npmci command "tslint -c tslint.json ./ts/**/*.ts" tags: - - docker - - priv + - lossless + - docker + - priv trigger: stage: metadata script: - - npmci trigger + - npmci trigger only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv pages: - image: hosttoday/ht-docker-node:npmci stage: metadata script: + - npmci node install lts - npmci command npm install -g @gitzone/tsdoc - npmci npm prepare - npmci npm install - npmci command tsdoc tags: + - lossless - docker - notpriv only: @@ -101,5 +133,5 @@ pages: artifacts: expire_in: 1 week paths: - - public + - public allow_failure: true diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..112db52 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "current file", + "type": "node", + "request": "launch", + "args": [ + "${relativeFile}" + ], + "runtimeArgs": ["-r", "@gitzone/tsrun"], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": "test.ts", + "type": "node", + "request": "launch", + "args": [ + "test/test.ts" + ], + "runtimeArgs": ["-r", "@gitzone/tsrun"], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3648eaa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "json.schemas": [ + { + "fileMatch": ["/npmextra.json"], + "schema": { + "type": "object", + "properties": { + "npmci": { + "type": "object", + "description": "settings for npmci" + }, + "gitzone": { + "type": "object", + "description": "settings for gitzone", + "properties": { + "projectType": { + "type": "string", + "enum": ["website", "element", "service", "npm", "wcc"] + } + } + } + } + } + } + ] +} diff --git a/README.md b/README.md deleted file mode 100644 index bb51599..0000000 --- a/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# @pushrocks/smartgit -smart wrapper for nodegit - -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartgit) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartgit) -* [github.com (source mirror)](https://github.com/pushrocks/smartgit) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartgit/) - -## Status for master -[![build status](https://gitlab.com/pushrocks/smartgit/badges/master/build.svg)](https://gitlab.com/pushrocks/smartgit/commits/master) -[![coverage report](https://gitlab.com/pushrocks/smartgit/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartgit/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartgit.svg)](https://www.npmjs.com/package/@pushrocks/smartgit) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartgit/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartgit) -[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) - -## Usage - -We recommend the use of TypeScript for best in class intellisense - -```javascript -// import smartgit: -import { GitRepo } from 'smartgit'; - -// Initialize smartgit: -// -- note: there are 3 ways to initialize smartgit -// -- -- 1. with a existing Git repo -// -- -- 2. with a cloned Git repo -// -- -- 3. with a new Git repo - -// -- 1. existing Git Repo: -let myExistingGitRepo = new GitRepo('/path/to/existing/git/repo/'); - -// -- 2. cloned Git Repo: -let myClonedGitRepo: GitRepo; -smartgit.createRepoFromClone('git@github.com:username/reponame.git').then(gitRepo => { - // non blocking - myClonedGitRepo = gitRepo; -}); - -// -- 3. new Git Repo -let myNewGitRepo: GitRepo; -smartgit - .createRepoFromInit('/path/to/new/folder') // smartgit will create any new folder, be careful - .then(gitRepo => { - // non blocking - myNewGitRepo = gitRepo; - }); - -// Using smartgit instance -// -- most used actions -// -- all actions return promises, so make sure to use promise chaining for any dependent tasks -myExistingGitRepo.addAll(); // returns promise, stages all changed files -myExistingGitRepo.add(['relative/path/to/file.txt', 'another/file2.txt']); // returns promise, stages specific files -myExistingGitRepo.commit('my commit message'); // returns promise, commits staged files -myExistingGitRepo - .status() // returns promise - .then(status => { - // Use TypeScript for status type information - }); -myExistingGitRepo.check(); // returns promise, checks repo health -myExistingGitRepo.remoteAdd('git@github.com:username/reponame.git'); -``` - -Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment - -[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) - -For further information read the linked docs at the top of this readme. - -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) - -[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com) diff --git a/npmextra.json b/npmextra.json index bcc94e9..ce3af4f 100644 --- a/npmextra.json +++ b/npmextra.json @@ -7,7 +7,6 @@ "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" - }, "gitzone": { "projectType": "npm", diff --git a/package.json b/package.json index 66a9da0..2bf0636 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "@pushrocks/smartgit", "version": "1.0.14", "description": "smart wrapper for nodegit", - "main": "dist/index.js", - "typings": "dist/index.d.ts", + "main": "dist_ts/index.js", + "typings": "dist_ts/index.d.ts", "scripts": { "test": "(tstest test/)", "build": "(tsbuild)" @@ -42,13 +42,18 @@ }, "private": false, "files": [ - "ts/*", - "ts_web/*", - "dist/*", - "dist_web/*", - "assets/*", + "ts/**/*", + "ts_web/**/*", + "dist/**/*", + "dist_*/**/*", + "dist_ts/**/*", + "dist_ts_web/**/*", + "assets/**/*", "cli.js", "npmextra.json", "readme.md" + ], + "browserslist": [ + "last 1 chrome versions" ] -} +} \ No newline at end of file diff --git a/ts/smartgit.classes.gitrepo.ts b/ts/smartgit.classes.gitrepo.ts index 16a23ac..986fb67 100644 --- a/ts/smartgit.classes.gitrepo.ts +++ b/ts/smartgit.classes.gitrepo.ts @@ -12,7 +12,7 @@ export class GitRepo { const dirArg = plugins.path.resolve(toArg); const ngRespository = await plugins.nodegit.Clone.clone(fromArg, toArg, { bare: 0, - checkoutBranch: 'master' + checkoutBranch: 'master', }); return new GitRepo(ngRespository); } @@ -46,7 +46,7 @@ export class GitRepo { /** * ensures the existance of a remote within a repository * @param remoteNameArg - * @param remoteUrlArg + * @param remoteUrlArg */ public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise { const existingUrl = await this.getUrlForRemote(remoteNameArg);