Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
8dd8bd0be1 | |||
0bd91c2bda | |||
6ef3e6e6f5 | |||
93709f920e | |||
75fa530f73 | |||
f5617d9d45 | |||
b46d1e19a7 | |||
c8d173807d | |||
5944c7e96f | |||
39ea160fdf |
@ -12,20 +12,12 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
auditProductionDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
@ -36,6 +28,7 @@ auditProductionDependencies:
|
|||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
auditDevDependencies:
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
@ -96,10 +89,9 @@ codequality:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
@ -119,11 +111,10 @@ trigger:
|
|||||||
pages:
|
pages:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smartgit",
|
"gitrepo": "smartgit",
|
||||||
"shortDescription": "smart wrapper for nodegit",
|
"description": "smart wrapper for nodegit",
|
||||||
"npmPackagename": "@pushrocks/smartgit",
|
"npmPackagename": "@pushrocks/smartgit",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
24980
package-lock.json
generated
24980
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -1,12 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartgit",
|
"name": "@pushrocks/smartgit",
|
||||||
"version": "2.0.1",
|
"version": "3.0.0",
|
||||||
"description": "smart wrapper for nodegit",
|
"description": "smart wrapper for nodegit",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -24,21 +26,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
"homepage": "https://gitlab.com/pushrocks/smartgit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartenv": "^4.0.16",
|
"@pushrocks/smartenv": "^5.0.2",
|
||||||
"@pushrocks/smartfile": "^8.0.10",
|
"@pushrocks/smartfile": "^10.0.4",
|
||||||
"@pushrocks/smartpath": "^4.0.3",
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@pushrocks/smartshell": "^2.0.28",
|
"@pushrocks/smartshell": "^2.0.30",
|
||||||
"@pushrocks/smartstring": "^3.0.24",
|
"@pushrocks/smartstring": "^4.0.2",
|
||||||
"@types/minimatch": "^3.0.5",
|
"@types/minimatch": "^3.0.5",
|
||||||
"isomorphic-git": "^1.10.1"
|
"isomorphic-git": "^1.19.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.28",
|
"@gitzone/tsbuild": "^2.1.63",
|
||||||
"@gitzone/tstest": "^1.0.59",
|
"@gitzone/tstest": "^1.0.72",
|
||||||
"@pushrocks/tapbundle": "^3.2.14",
|
"@pushrocks/tapbundle": "^5.0.4"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -75,7 +75,6 @@ Tip: use [smartssh](https://npmjs.com/smartssh) to setup your SSH environment
|
|||||||
|
|
||||||
[](https://push.rocks)
|
[](https://push.rocks)
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
15
test/test.ts
15
test/test.ts
@ -1,24 +1,29 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import * as smartgit from '../ts/index';
|
import * as smartgit from '../ts/index.js';
|
||||||
|
|
||||||
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
|
const __dirname = smartpath.get.dirnameFromImportMetaUrl(import.meta.url);
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
let testSmartgitInstance: smartgit.Smartgit;
|
let testSmartgitInstance: smartgit.Smartgit;
|
||||||
const testRepoDir = path.join(__dirname, '../.nogit/testrepo');
|
const testRepoDir = path.join(__dirname, '../.nogit/testrepo');
|
||||||
const testRepoDirSmartfile = path.join(__dirname, '../.nogit/pushrocks_smartfile')
|
const testRepoDirSmartfile = path.join(__dirname, '../.nogit/pushrocks_smartfile');
|
||||||
|
|
||||||
tap.test('should create a valid smartgit instance', async () => {
|
tap.test('should create a valid smartgit instance', async () => {
|
||||||
testSmartgitInstance = new smartgit.Smartgit();
|
testSmartgitInstance = new smartgit.Smartgit();
|
||||||
await testSmartgitInstance.init();
|
await testSmartgitInstance.init();
|
||||||
expect(testSmartgitInstance).to.be.instanceOf(smartgit.Smartgit);
|
expect(testSmartgitInstance).toBeInstanceOf(smartgit.Smartgit);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should create a new repo at .nogit', async () => {
|
tap.test('should create a new repo at .nogit', async () => {
|
||||||
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir);
|
const gitRepo = await testSmartgitInstance.createRepoByOpen(testRepoDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should clone a repo', async () => {
|
tap.test('should clone a repo', async () => {
|
||||||
const gitRepo = await testSmartgitInstance.createRepoByClone('https://gitlab.com/pushrocks/smartfile.git', testRepoDirSmartfile);
|
const gitRepo = await testSmartgitInstance.createRepoByClone(
|
||||||
|
'https://gitlab.com/pushrocks/smartfile.git',
|
||||||
|
testRepoDirSmartfile
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@pushrocks/smartgit',
|
||||||
|
version: '3.0.0',
|
||||||
|
description: 'smart wrapper for nodegit'
|
||||||
|
}
|
@ -1,4 +1,2 @@
|
|||||||
import plugins = require('./smartgit.plugins');
|
export * from './smartgit.classes.gitrepo.js';
|
||||||
|
export * from './smartgit.classes.smartgit.js';
|
||||||
export * from './smartgit.classes.gitrepo';
|
|
||||||
export * from './smartgit.classes.smartgit';
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './smartgit.plugins';
|
import * as plugins from './smartgit.plugins.js';
|
||||||
|
|
||||||
import { Smartgit } from './smartgit.classes.smartgit';
|
import { Smartgit } from './smartgit.classes.smartgit.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class GitRepo allows access to git directories from node
|
* class GitRepo allows access to git directories from node
|
||||||
@ -74,24 +74,23 @@ export class GitRepo {
|
|||||||
*/
|
*/
|
||||||
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
|
public async ensureRemote(remoteNameArg: string, remoteUrlArg: string): Promise<void> {
|
||||||
const remotes = await this.listRemotes();
|
const remotes = await this.listRemotes();
|
||||||
const existingRemote =
|
const existingRemote = remotes.find((itemArg) => itemArg.remote === remoteNameArg);
|
||||||
remotes.find((itemArg) => itemArg.remote === remoteNameArg);
|
|
||||||
if (existingRemote) {
|
if (existingRemote) {
|
||||||
if (existingRemote.url !== remoteUrlArg) {
|
if (existingRemote.url !== remoteUrlArg) {
|
||||||
await plugins.isomorphicGit.deleteRemote({
|
await plugins.isomorphicGit.deleteRemote({
|
||||||
remote: remoteNameArg,
|
remote: remoteNameArg,
|
||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
dir: this.repoDir
|
dir: this.repoDir,
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
await plugins.isomorphicGit.addRemote({
|
await plugins.isomorphicGit.addRemote({
|
||||||
remote: remoteNameArg,
|
remote: remoteNameArg,
|
||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
url: remoteUrlArg
|
url: remoteUrlArg,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +98,7 @@ export class GitRepo {
|
|||||||
*/
|
*/
|
||||||
public async getUrlForRemote(remoteName: string): Promise<string> {
|
public async getUrlForRemote(remoteName: string): Promise<string> {
|
||||||
const remotes = await this.listRemotes();
|
const remotes = await this.listRemotes();
|
||||||
const existingRemote = remotes.find(remoteArg => remoteArg.remote === remoteName);
|
const existingRemote = remotes.find((remoteArg) => remoteArg.remote === remoteName);
|
||||||
return existingRemote?.url;
|
return existingRemote?.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +107,7 @@ export class GitRepo {
|
|||||||
fs: this.smartgitRef.envDeps.fs,
|
fs: this.smartgitRef.envDeps.fs,
|
||||||
http: this.smartgitRef.envDeps.http,
|
http: this.smartgitRef.envDeps.http,
|
||||||
ref: branchName,
|
ref: branchName,
|
||||||
remote: remoteName
|
remote: remoteName,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './smartgit.plugins';
|
import * as plugins from './smartgit.plugins.js';
|
||||||
import { GitRepo } from './smartgit.classes.gitrepo';
|
import { GitRepo } from './smartgit.classes.gitrepo.js';
|
||||||
|
|
||||||
export class Smartgit {
|
export class Smartgit {
|
||||||
public smartenvInstance = new plugins.smartenv.Smartenv();
|
public smartenvInstance = new plugins.smartenv.Smartenv();
|
||||||
@ -8,26 +8,30 @@ export class Smartgit {
|
|||||||
http: any;
|
http: any;
|
||||||
} = {
|
} = {
|
||||||
fs: null,
|
fs: null,
|
||||||
http: null
|
http: null,
|
||||||
}
|
};
|
||||||
|
|
||||||
constructor() {};
|
constructor() {}
|
||||||
|
|
||||||
public async init() {
|
public async init() {
|
||||||
if (this.smartenvInstance.isNode) {
|
if (this.smartenvInstance.isNode) {
|
||||||
this.envDeps.fs = this.smartenvInstance.getSafeNodeModule('fs');
|
this.envDeps.fs = await this.smartenvInstance.getSafeNodeModule('fs');
|
||||||
this.envDeps.http = this.smartenvInstance.getSafeNodeModule('isomorphic-git/http/node');
|
this.envDeps.http = await this.smartenvInstance.getSafeNodeModule(
|
||||||
|
'isomorphic-git/http/node/index.js'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new Error('currently only node.js is supported.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
public async createRepoByClone(fromUrlArg: string, toDirArg: string) {
|
public async createRepoByClone(fromUrlArg: string, toDirArg: string) {
|
||||||
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg)
|
const repo = await GitRepo.fromCloningIntoDir(this, fromUrlArg, toDirArg);
|
||||||
};
|
}
|
||||||
|
|
||||||
public async createRepoByInit(dirArg: string) {
|
public async createRepoByInit(dirArg: string) {
|
||||||
const repo = await GitRepo.fromCreatingRepoInDir(this, dirArg);
|
const repo = await GitRepo.fromCreatingRepoInDir(this, dirArg);
|
||||||
return repo;
|
return repo;
|
||||||
};
|
}
|
||||||
|
|
||||||
public async createRepoByOpen(dirArg: string) {
|
public async createRepoByOpen(dirArg: string) {
|
||||||
const repo = await GitRepo.fromOpeningRepoDir(this, dirArg);
|
const repo = await GitRepo.fromOpeningRepoDir(this, dirArg);
|
||||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
Reference in New Issue
Block a user