Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
cc00a78e2c | |||
cf7e69e74a | |||
5cc3aeb27c | |||
098a9c64c6 | |||
1fd2bb8e01 | |||
ca475fbfab | |||
c8dc59cdf2 | |||
217724d836 | |||
b0efd2671c | |||
b80e63dc65 | |||
7765ff77f9 |
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,4 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
114
.gitlab-ci.yml
114
.gitlab-ci.yml
@ -1,38 +1,76 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .yarn/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- security
|
||||||
- release
|
- test
|
||||||
- trigger
|
- release
|
||||||
- pages
|
- metadata
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
stage: test
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- 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
|
||||||
|
|
||||||
|
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:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
testLTS:
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -40,32 +78,60 @@ testSTABLE:
|
|||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
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:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
stage: metadata
|
||||||
stage: pages
|
|
||||||
script:
|
script:
|
||||||
- npmci command yarn global add npmpage
|
- npmci node install lts
|
||||||
- npmci command npmpage
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -13,6 +13,7 @@
|
|||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org",
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
20139
package-lock.json
generated
20139
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/gitlab",
|
"name": "@mojoio/gitlab",
|
||||||
"version": "1.0.4",
|
"version": "1.0.10",
|
||||||
"description": "api abstraction package for gitlab",
|
"description": "api abstraction package for gitlab",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -11,15 +11,33 @@
|
|||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.27",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.17",
|
||||||
"@gitzone/tstest": "^1.0.54",
|
"@gitzone/tstest": "^1.0.57",
|
||||||
"@pushrocks/tapbundle": "^3.2.14",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartrequest": "^1.1.51",
|
"@pushrocks/smartfile": "^8.0.10",
|
||||||
"@pushrocks/smarturl": "^2.0.1"
|
"@pushrocks/smartrequest": "^1.1.52",
|
||||||
}
|
"@pushrocks/smarturl": "^2.0.1",
|
||||||
|
"@tsclass/tsclass": "^3.0.34"
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
51
readme.md
51
readme.md
@ -1,29 +1,46 @@
|
|||||||
# glab
|
# @mojoio/gitlab
|
||||||
api abstraction package for gitlab
|
a gitlab api abstraction package
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
[](https://www.npmjs.com/package/glab)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/gitlab)
|
||||||
[](https://GitLab.com/mojoio/glab)
|
* [gitlab.com (source)](https://gitlab.com/mojoio/gitlab)
|
||||||
[](https://github.com/mojoio/glab)
|
* [github.com (source mirror)](https://github.com/mojoio/gitlab)
|
||||||
[](https://mojoio.gitlab.io/glab/)
|
* [docs (typedoc)](https://mojoio.gitlab.io/gitlab/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://GitLab.com/mojoio/glab/commits/master)
|
|
||||||
[](https://GitLab.com/mojoio/glab/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/glab)
|
-- | --
|
||||||
[](https://david-dm.org/mojoio/glab)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://www.bithound.io/github/mojoio/glab/master/dependencies/npm)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://www.bithound.io/github/mojoio/glab)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
Snyk | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
[](http://standardjs.com/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[](https://mojo.io)
|
[](https://mojo.io)
|
||||||
|
|
||||||
|
## 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). :)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
28
test/test.ts
28
test/test.ts
@ -1,23 +1,43 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as gitlab from '../ts/index';
|
import * as gitlab from '../ts/index';
|
||||||
|
|
||||||
let testGitlabAccount: gitlab.GitlabAccount;
|
let testGitlabAccount: gitlab.GitlabAccount;
|
||||||
|
|
||||||
tap.test('should create an anonymous Gitlab Account', async () => {
|
const test1 = tap.test('should create an anonymous Gitlab Account', async () => {
|
||||||
testGitlabAccount = gitlab.GitlabAccount.createAnonymousAccount();
|
testGitlabAccount = gitlab.GitlabAccount.createAnonymousAccount();
|
||||||
expect(testGitlabAccount).to.be.instanceOf(gitlab.GitlabAccount);
|
expect(testGitlabAccount).to.be.instanceOf(gitlab.GitlabAccount);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get the pushrocks group', async () => {
|
const test2 = tap.test('should get the pushrocks group', async () => {
|
||||||
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
|
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
|
||||||
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
|
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
|
||||||
console.log(pushrocksGroup);
|
console.log(pushrocksGroup);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get the pushrocks group', async () => {
|
const test3 = tap.test('should get the pushrocks group', async () => {
|
||||||
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
|
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
|
||||||
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
|
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
|
||||||
await pushrocksGroup.getProjects();
|
await pushrocksGroup.getProjects();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const test4 = tap.test('should get the readme of a project', async () => {
|
||||||
|
const pushrocksGroup = await testGitlabAccount.getGroupByName('pushrocks');
|
||||||
|
expect(pushrocksGroup).to.be.instanceOf(gitlab.GitlabGroup);
|
||||||
|
const projects = await pushrocksGroup.getProjects();
|
||||||
|
const selectedProject = projects.find((project) => {
|
||||||
|
return project.data?.name === 'smartfile';
|
||||||
|
});
|
||||||
|
expect(selectedProject.data.name).to.equal('smartfile');
|
||||||
|
const readme = await selectedProject.getReadmeAsMarkdown('master');
|
||||||
|
expect(readme.startsWith('# @pushrocks/smartfile')).to.be.true;
|
||||||
|
return projects;
|
||||||
|
});
|
||||||
|
|
||||||
|
const test5 = tap.test('should be able to create an article list', async () => {
|
||||||
|
const projects: gitlab.GitlabProject[] = (await test4.testResultPromise) as any;
|
||||||
|
for (const project of projects) {
|
||||||
|
console.log(await project.getProjectAsArticle());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -11,23 +11,29 @@ export class GitlabAccount {
|
|||||||
return GitlabGroup.getByName(nameArg, this);
|
return GitlabGroup.getByName(nameArg, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handles the basic request/response patterns with the gitlab.com API
|
* handles the basic request/response patterns with the gitlab.com API
|
||||||
*/
|
*/
|
||||||
public async request (methodArg: 'GET' | 'POST', routeArg: string, searchParamsArg: {[key: string]: string}) {
|
public async request(
|
||||||
if(!routeArg.startsWith('/')) {
|
methodArg: 'GET' | 'POST',
|
||||||
|
routeArg: string,
|
||||||
|
searchParamsArg: { [key: string]: string }
|
||||||
|
) {
|
||||||
|
if (!routeArg.startsWith('/')) {
|
||||||
throw new Error(`"${routeArg}" -> routeArg must start with a slash`);
|
throw new Error(`"${routeArg}" -> routeArg must start with a slash`);
|
||||||
}
|
}
|
||||||
const smarturlInstance = plugins.smarturl.Smarturl.createFromUrl(`https://gitlab.com/api/v4${routeArg}`, {
|
const smarturlInstance = plugins.smarturl.Smarturl.createFromUrl(
|
||||||
searchParams: searchParamsArg
|
`https://gitlab.com/api/v4${routeArg}`,
|
||||||
});
|
{
|
||||||
|
searchParams: searchParamsArg,
|
||||||
|
}
|
||||||
|
);
|
||||||
const response = await plugins.smartrequest.request(smarturlInstance.toString(), {
|
const response = await plugins.smartrequest.request(smarturlInstance.toString(), {
|
||||||
method: methodArg
|
method: methodArg,
|
||||||
});
|
});
|
||||||
|
|
||||||
// lets deal with pagination headers
|
// lets deal with pagination headers
|
||||||
const fintLinkName = (markup) => {
|
const findLinkName = (markup: string) => {
|
||||||
const pattern = /<([^\s>]+)(\s|>)+/;
|
const pattern = /<([^\s>]+)(\s|>)+/;
|
||||||
return markup.match(pattern)[1];
|
return markup.match(pattern)[1];
|
||||||
};
|
};
|
||||||
@ -37,6 +43,21 @@ export class GitlabAccount {
|
|||||||
original: string;
|
original: string;
|
||||||
link: string;
|
link: string;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
for (const link of links) {
|
||||||
|
linkObjects.push({
|
||||||
|
original: link,
|
||||||
|
link: findLinkName(link),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const next = linkObjects.find((linkObject) => linkObject.original.includes('rel="next"'));
|
||||||
|
if (next && response.body instanceof Array) {
|
||||||
|
const nextResponse = await this.request(
|
||||||
|
methodArg,
|
||||||
|
next.link.replace('https://gitlab.com/api/v4', ''),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
response.body = response.body.concat(nextResponse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return response.body;
|
return response.body;
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,173 @@
|
|||||||
import { GitlabGroup } from './gitlab.classes.group';
|
import { GitlabGroup } from './gitlab.classes.group';
|
||||||
import * as plugins from './gitlab.plugins';
|
import * as plugins from './gitlab.plugins';
|
||||||
|
|
||||||
|
export interface IGitlabData {
|
||||||
|
id: number;
|
||||||
|
description: string;
|
||||||
|
name: string;
|
||||||
|
name_with_namespace: string;
|
||||||
|
path: string;
|
||||||
|
path_with_namespace: string;
|
||||||
|
created_at: string;
|
||||||
|
default_branch: string;
|
||||||
|
tag_list: string[];
|
||||||
|
ssh_url_to_repo: string;
|
||||||
|
http_url_to_repo: string;
|
||||||
|
web_url: string;
|
||||||
|
readme_url: string;
|
||||||
|
avatar_url: null;
|
||||||
|
forks_count: number;
|
||||||
|
star_count: number;
|
||||||
|
last_activity_at: string;
|
||||||
|
namespace: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
path: string;
|
||||||
|
kind: string;
|
||||||
|
full_path: string;
|
||||||
|
parent_id: null;
|
||||||
|
avatar_url: string;
|
||||||
|
web_url: string;
|
||||||
|
};
|
||||||
|
container_registry_image_prefix: string;
|
||||||
|
_links: {
|
||||||
|
self: string;
|
||||||
|
issues: string;
|
||||||
|
merge_requests: string;
|
||||||
|
repo_branches: string;
|
||||||
|
labels: string;
|
||||||
|
events: string;
|
||||||
|
members: string;
|
||||||
|
};
|
||||||
|
packages_enabled: null;
|
||||||
|
empty_repo: boolean;
|
||||||
|
archived: boolean;
|
||||||
|
visibility: 'public' | 'private';
|
||||||
|
resolve_outdated_diff_discussions: null;
|
||||||
|
container_registry_enabled: boolean;
|
||||||
|
issues_enabled: boolean;
|
||||||
|
merge_requests_enabled: boolean;
|
||||||
|
wiki_enabled: boolean;
|
||||||
|
jobs_enabled: boolean;
|
||||||
|
snippets_enabled: boolean;
|
||||||
|
service_desk_enabled: null;
|
||||||
|
service_desk_address: null;
|
||||||
|
can_create_merge_request_in: boolean;
|
||||||
|
issues_access_level: 'enabled' | 'disabled';
|
||||||
|
repository_access_level: 'enabled' | 'disabled';
|
||||||
|
merge_requests_access_level: 'enabled' | 'disabled';
|
||||||
|
forking_access_level: 'enabled' | 'disabled';
|
||||||
|
wiki_access_level: 'enabled' | 'disabled';
|
||||||
|
builds_access_level: 'enabled' | 'disabled';
|
||||||
|
snippets_access_level: 'enabled' | 'disabled';
|
||||||
|
pages_access_level: 'enabled' | 'disabled';
|
||||||
|
operations_access_level: 'enabled' | 'disabled';
|
||||||
|
analytics_access_level: 'enabled' | 'disabled';
|
||||||
|
emails_disabled: null;
|
||||||
|
shared_runners_enabled: boolean;
|
||||||
|
lfs_enabled: boolean;
|
||||||
|
creator_id: number;
|
||||||
|
import_status: 'none';
|
||||||
|
open_issues_count: number;
|
||||||
|
ci_default_git_depth: null;
|
||||||
|
ci_forward_deployment_enabled: null;
|
||||||
|
public_jobs: boolean;
|
||||||
|
build_timeout: number;
|
||||||
|
auto_cancel_pending_pipelines: 'enabled' | 'disabled';
|
||||||
|
build_coverage_regex: '';
|
||||||
|
ci_config_path: '';
|
||||||
|
shared_with_groups: [];
|
||||||
|
only_allow_merge_if_pipeline_succeeds: boolean;
|
||||||
|
allow_merge_on_skipped_pipeline: null;
|
||||||
|
restrict_user_defined_variables: boolean;
|
||||||
|
request_access_enabled: boolean;
|
||||||
|
only_allow_merge_if_all_discussions_are_resolved: boolean;
|
||||||
|
remove_source_branch_after_merge: null;
|
||||||
|
printing_merge_request_link_enabled: boolean;
|
||||||
|
merge_method: 'merge';
|
||||||
|
suggestion_commit_message: null;
|
||||||
|
auto_devops_enabled: boolean;
|
||||||
|
auto_devops_deploy_strategy: 'continuous';
|
||||||
|
autoclose_referenced_issues: boolean;
|
||||||
|
approvals_before_merge: number;
|
||||||
|
mirror: boolean;
|
||||||
|
external_authorization_classification_label: '';
|
||||||
|
marked_for_deletion_at: null;
|
||||||
|
marked_for_deletion_on: null;
|
||||||
|
requirements_enabled: boolean;
|
||||||
|
security_and_compliance_enabled: null;
|
||||||
|
compliance_frameworks: [];
|
||||||
|
issues_template: '';
|
||||||
|
merge_requests_template: '';
|
||||||
|
}
|
||||||
|
|
||||||
export class GitlabProject {
|
export class GitlabProject {
|
||||||
// STATIC
|
// STATIC
|
||||||
public static async getProjectsForGroup(gitlabGroupArg: GitlabGroup) {
|
public static async getProjectsForGroup(gitlabGroupArg: GitlabGroup): Promise<GitlabProject[]> {
|
||||||
const response = await gitlabGroupArg.gitlabAccountRef.request('GET', `/groups/${gitlabGroupArg.data.id}/projects`, {
|
const response = await gitlabGroupArg.gitlabAccountRef.request(
|
||||||
per_page: '100'
|
'GET',
|
||||||
});
|
`/groups/${gitlabGroupArg.data.id}/projects`,
|
||||||
console.log(response);
|
{
|
||||||
|
per_page: '100',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const allProjects: GitlabProject[] = [];
|
||||||
for (const projectData of response) {
|
for (const projectData of response) {
|
||||||
console.log(projectData);
|
allProjects.push(new GitlabProject(projectData, gitlabGroupArg));
|
||||||
}
|
}
|
||||||
console.log(response.length);
|
return allProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
gitlabGroupRef: GitlabGroup;
|
gitlabGroupRef: GitlabGroup;
|
||||||
data: any;
|
data: IGitlabData;
|
||||||
|
|
||||||
constructor(dataArg: any, gitlabGroupRefArg: GitlabGroup) {
|
constructor(dataArg: IGitlabData, gitlabGroupRefArg: GitlabGroup) {
|
||||||
this.data = dataArg;
|
this.data = dataArg;
|
||||||
this.gitlabGroupRef = gitlabGroupRefArg;
|
this.gitlabGroupRef = gitlabGroupRefArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getReadmeAsMarkdown() {};
|
public async getFileFromProject(
|
||||||
|
filePathArg: string,
|
||||||
|
refArg: string
|
||||||
|
): Promise<plugins.smartfile.Smartfile> {
|
||||||
|
const response = await this.gitlabGroupRef.gitlabAccountRef.request(
|
||||||
|
'GET',
|
||||||
|
`/projects/${this.data.id}/repository/files/${filePathArg}`,
|
||||||
|
{
|
||||||
|
ref: refArg,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return plugins.smartfile.Smartfile.fromBuffer(
|
||||||
|
filePathArg,
|
||||||
|
Buffer.from(response.content, response.encoding)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getReadmeAsMarkdown(refArg: string = 'master'): Promise<string> {
|
||||||
|
const readmeFile = await this.getFileFromProject('readme.md', refArg);
|
||||||
|
return readmeFile.contents.toString('utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getNpmKeywords(refArg: string = 'master'): Promise<string[]> {
|
||||||
|
const packageJsonFile = await this.getFileFromProject('package.json', refArg);
|
||||||
|
const packageJsonObject: any = JSON.parse(packageJsonFile.contents.toString('utf8'));
|
||||||
|
return packageJsonObject.keywords ? packageJsonObject.keywords : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getProjectAsArticle(): Promise<plugins.tsclass.content.IArticle> {
|
||||||
|
return {
|
||||||
|
url: this.data.web_url,
|
||||||
|
author: null,
|
||||||
|
content: await this.getReadmeAsMarkdown().catch(err => null),
|
||||||
|
tags: await this.getNpmKeywords().catch(err => null),
|
||||||
|
title: this.data.name,
|
||||||
|
timestamp: new Date(this.data.last_activity_at).getTime(),
|
||||||
|
featuredImageUrl: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async syncNpmKeywordsToGitlabTopics() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
|
// @tsclass scope
|
||||||
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
export {
|
||||||
|
tsclass
|
||||||
|
}
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
import * as smarturl from '@pushrocks/smarturl';
|
import * as smarturl from '@pushrocks/smarturl';
|
||||||
|
|
||||||
export {
|
export { smartfile, smartrequest, smarturl };
|
||||||
smartrequest,
|
|
||||||
smarturl
|
|
||||||
};
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * from './gitlab.classes.group';
|
export * from './gitlab.classes.group';
|
||||||
export * from './gitlab.classes.account';
|
export * from './gitlab.classes.account';
|
||||||
|
export * from './gitlab.classes.project';
|
Loading…
x
Reference in New Issue
Block a user