Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

isren

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isren - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.prettierrc

18

__tests__/Harness.js

@@ -6,17 +6,15 @@ 'use strict';

const projectSearch = jest.fn();
const projectSearchAll = jest.fn();
const issueSearch = jest.fn();
const groupSearch = jest.fn();
jest.spyOn(require('gitlab'), 'Gitlab').mockImplementation(() => ({
jest.spyOn(require('@gitbeaker/node'), 'Gitlab').mockImplementation(() => ({
Projects: {
search: projectSearch,
all: projectSearchAll
all: projectSearch,
},
Issues: {
all: issueSearch
all: issueSearch,
},
Groups: {
search: groupSearch
}
all: groupSearch,
},
}));

@@ -40,3 +38,2 @@

projectSearch.mockClear();
projectSearchAll.mockClear();
issueSearch.mockClear();

@@ -54,3 +51,3 @@ groupSearch.mockClear();

const beginsWith = input =>
const beginsWith = (input) =>
new RegExp(`^${input.toString().replace(/[()[\]\\/]/gim, '\\$&')}`);

@@ -60,3 +57,2 @@

projectSearch,
projectSearchAll,
issueSearch,

@@ -72,3 +68,3 @@ groupSearch,

writeFile,
beginsWith
beginsWith,
};

@@ -5,3 +5,2 @@ 'use strict';

projectSearch,
projectSearchAll,
issueSearch,

@@ -11,3 +10,3 @@ groupSearch,

consoleError,
beginsWith
beginsWith,
} = require('../Harness');

@@ -17,3 +16,3 @@ const ERRORS = require('../../src/ERRORS');

describe.only('GitLab implementation', () => {
describe('GitLab implementation', () => {
describe('Core', () => {

@@ -53,3 +52,3 @@ test('will exit and print errors if no settings exists', async () => {

new GitLab('https://testweb.gitlab.jp:1234/team/foo', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -104,3 +103,3 @@

'/gitlab-com/support-forum/issues',
'https://gitlab.com'
'https://gitlab.com',
]);

@@ -115,3 +114,3 @@ expect(consoleError).toHaveBeenCalledTimes(0);

const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -128,12 +127,13 @@ await git.authenticate();

test('will return no errors and the api context if the user has access to the project', async () => {
projectSearchAll.mockResolvedValueOnce([]);
projectSearch.mockResolvedValueOnce([
{
id: 114,
web_url: 'https://gitlab.com/gitlab-com/support-forum'
}
web_url: 'https://gitlab.com/gitlab-com/support-forum',
path_with_namespace: 'gitlab-com/support-forum',
},
]);
groupSearch.mockResolvedValueOnce([]);
const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -154,11 +154,13 @@ const { api, projectId, groupId } = await git.authenticate();

test('will return no errors and the api context if the user has access to the group', async () => {
projectSearch.mockResolvedValueOnce([]);
groupSearch.mockResolvedValueOnce([
{
id: 123,
web_url: 'https://gitlab.com/groups/gitlab-com'
}
web_url: 'https://gitlab.com/groups/gitlab-com',
full_path: 'gitlab-com',
},
]);
const git = new GitLab('https://gitlab.com/groups/gitlab-com', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -181,12 +183,13 @@ const { api, projectId, groupId } = await git.authenticate();

test('will not return any issues if the user does not have access to the project', async () => {
projectSearchAll.mockResolvedValueOnce([]);
projectSearch.mockResolvedValueOnce([
{
id: 114,
web_url: 'https://gitlab.com/gitlab-com/support-forum'
}
web_url: 'https://gitlab.com/gitlab-com/support-forum',
path_with_namespace: 'gitlab-com/support-forum',
},
]);
groupSearch.mockResolvedValueOnce([]);
const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -204,12 +207,13 @@ const { api } = await git.authenticate();

test('will not return any issues if the user does not have access to the group', async () => {
projectSearchAll.mockResolvedValueOnce([]);
projectSearch.mockResolvedValueOnce([
{
id: 114,
web_url: 'https://gitlab.com/gitlab-com/support-forum'
}
web_url: 'https://gitlab.com/gitlab-com/support-forum',
path_with_namespace: 'gitlab-com/support-forum',
},
]);
groupSearch.mockResolvedValueOnce([]);
const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -230,16 +234,17 @@ const { api } = await git.authenticate();

issue: 'foo issue',
test: 'pass'
}
test: 'pass',
},
];
projectSearchAll.mockResolvedValueOnce([]);
projectSearch.mockResolvedValueOnce([
projectSearch.mockResolvedValue([
{
id: 114,
web_url: 'https://gitlab.com/gitlab-com/support-forum'
}
web_url: 'https://gitlab.com/gitlab-com/support-forum',
path_with_namespace: 'gitlab-com/support-forum',
},
]);
issueSearch.mockResolvedValueOnce(MOCK_ISSUES);
groupSearch.mockResolvedValue([]);
issueSearch.mockResolvedValue(MOCK_ISSUES);
const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -265,15 +270,17 @@ const { api, projectId, groupId } = await git.authenticate();

issue: 'foo issue',
test: 'pass'
}
test: 'pass',
},
];
groupSearch.mockResolvedValueOnce([
projectSearch.mockResolvedValue([]);
groupSearch.mockResolvedValue([
{
id: 123,
web_url: 'https://gitlab.com/groups/gitlab-com'
}
web_url: 'https://gitlab.com/groups/gitlab-com',
full_path: 'gitlab-com',
},
]);
issueSearch.mockResolvedValueOnce(MOCK_ISSUES);
issueSearch.mockResolvedValue(MOCK_ISSUES);
const git = new GitLab('https://gitlab.com/groups/gitlab-com', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -300,17 +307,17 @@ const { api, projectId, groupId } = await git.authenticate();

web_url: 'https://gitlab.com/gitlab-com/support-forum',
path_with_namespace: 'foo/bar/baz'
}
path_with_namespace: 'gitlab-com/support-forum',
},
];
projectSearchAll.mockReturnValue(projects);
projectSearch.mockReturnValue(projects);
issueSearch.mockReturnValue([
projectSearch.mockResolvedValue(projects);
groupSearch.mockResolvedValue([]);
issueSearch.mockResolvedValue([
{
project_id: 114,
issue: 'foo issue',
test: 'pass'
}
test: 'pass',
},
]);
const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -334,4 +341,4 @@ const { api, projectId, groupId } = await git.authenticate();

project_id: 114,
project_name: 'foo/bar/baz'
}
project_name: 'gitlab-com/support-forum',
},
]);

@@ -344,3 +351,3 @@ });

const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -361,3 +368,3 @@ git.addProjectNames();

const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -378,3 +385,3 @@ git.addProjectNames({});

const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -395,3 +402,3 @@ git.addProjectNames({}, {});

const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -412,3 +419,3 @@ git.addProjectNames({}, null);

const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -429,3 +436,3 @@ git.addProjectNames({}, '');

const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -448,4 +455,4 @@ git.addProjectNames({}, 1);

id: 1,
path_with_namespace: 'test/me'
}
path_with_namespace: 'gitlab-com/support-forum',
},
];

@@ -455,9 +462,10 @@ const issues = [

project_id: 1,
issue: 'anything'
}
issue: 'anything',
},
];
projectSearchAll.mockReturnValue(projects);
projectSearch.mockReturnValue(projects);
groupSearch.mockReturnValue([]);
const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -475,4 +483,4 @@ const { api } = await git.authenticate();

issue: 'anything',
project_name: 'test/me'
}
project_name: 'gitlab-com/support-forum',
},
]);

@@ -485,4 +493,4 @@ });

id: 2,
path_with_namespace: 'test/me'
}
path_with_namespace: 'gitlab-com/support-forum',
},
];

@@ -492,9 +500,10 @@ const issues = [

project_id: 1,
issue: 'anything'
}
issue: 'anything',
},
];
projectSearchAll.mockReturnValue(projects);
projectSearch.mockReturnValue(projects);
groupSearch.mockReturnValue([]);
const git = new GitLab('https://gitlab.com/gitlab-com/support-forum', {
auth: 'token_secret'
auth: 'token_secret',
});

@@ -512,4 +521,4 @@ const { api } = await git.authenticate();

issue: 'anything',
project_name: ''
}
project_name: '',
},
]);

@@ -516,0 +525,0 @@ });

@@ -9,4 +9,10 @@ # Changelog

## [1.1.0 - 12/04/2020]
- Replacing gitlab dep with the latest version
- Fixing .env parsing issues
- Adding .prettierrc
## [1.0.0 - 01/07/2020]
- Initial release
module.exports = {
testRegex: '(__tests__.*|(.|/)).(test|spec).[jt]sx?$'
testRegex: '(__tests__.*|(.|/)).(test|spec).[jt]sx?$',
verbose: true,
automock: false,
};
{
"name": "isren",
"version": "1.0.0",
"version": "1.1.0",
"description": "isren - ISsue Rendering ENgine",
"main": "./src/index.js",
"scripts": {
"test": "jest",
"test": "NODE_ENV=test jest ",
"coverage": "jest --coverage",
"format": "prettier '**/**.js' --single-quote --write",
"format": "prettier '**/**.js' --write",
"start": "node ./src/CLI.js",

@@ -30,11 +30,11 @@ "lint": "eslint '**/**.js'"

"eslint-plugin-standard": "^4.0.0",
"jest": "^24.8.0",
"jest": "^26.6.3",
"prettier": "^1.19.1"
},
"dependencies": {
"@gitbeaker/node": "^25.6.0",
"commander": "^4.0.1",
"csv-stringify": "^5.3.0",
"dotenv": "^8.0.0",
"gitlab": "^11.5.1"
"dotenv": "^8.0.0"
}
}
#!/usr/bin/env node
require('dotenv').config();
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../', '.env') });
const program = require('commander');

@@ -4,0 +5,0 @@ const index = require('./index');

@@ -7,2 +7,3 @@ {

"MISSING_PROJECT": "Project not found!",
"DUPLICATE_PROJECT_GROUP_NAME": "A project and group with the same name exist!",
"MISSING_ISSUES": "Issue listing failed!",

@@ -9,0 +10,0 @@ "NYI_IS_IMPLEMENTATION": "isImplementation() is not defined for",

'use strict';
const { URL } = require('url');
const { Gitlab: Git } = require('gitlab');
const { Gitlab: Git } = require('@gitbeaker/node');
const Implementation = require('./index');

@@ -62,35 +62,32 @@ const Logger = require('../Logger');

token: this.auth,
host
host,
rejectUnauthorized: !this.insecure,
});
const [, groups, group] = path.split('/');
// Determine what type of url we have.
let projectName, groupName;
if (/groups/gi.test(groups)) {
groupName = group;
} else {
groupName = groups;
projectName = group;
}
try {
const GROUPS = await api.Groups.all();
const PROJECTS = await api.Projects.all();
const PATH = path.slice(1).replace(/^(groups\/)/gi, '');
const group = GROUPS.find((g) => g.full_path === PATH);
const project = PROJECTS.find((p) => p.path_with_namespace === PATH);
try {
if (projectName !== undefined) {
const [currentProject] = (
await api.Projects.search(projectName)
).filter(projectInfo => projectInfo.web_url.includes(path));
const projectId = currentProject.id;
Logger.debug(
`path=${PATH}, groups count=${GROUPS.length}, project count=${
PROJECTS.length
}, group=${!!group}, project=${!!project}`
);
if (!group && !project) return Logger.fatal(ERRORS.MISSING_PROJECT);
if (group && project)
return Logger.fatal(ERRORS.DUPLICATE_PROJECT_GROUP_NAME);
if (group) {
console.log(
`Authentication success! Current project is ${path}(#${projectId})`
`Authentication success! Current group is ${group.full_path}(#${group.id})`
);
return { api, projectId };
return { api, groupId: group.id };
}
const [currentGroup] = (
await api.Groups.search(groupName)
).filter(groupInfo => groupInfo.web_url.includes(path));
const groupId = currentGroup.id;
console.log(
`Authentication success! Current group is ${path}(#${groupId})`
`Authentication success! Current project is ${project.path_with_namespace}(#${project.id})`
);
return { api, groupId };
return { api, projectId: project.id };
} catch (e) {

@@ -121,3 +118,3 @@ if (e.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE') {

projectId,
...options
...options,
});

@@ -128,3 +125,3 @@ }

groupId,
...options
...options,
});

@@ -168,3 +165,3 @@ }

return issues.map(issue => {
return issues.map((issue) => {
issue.project_name = projects[issue.project_id] || '';

@@ -171,0 +168,0 @@ return issue;

@@ -17,2 +17,3 @@ 'use strict';

this.auth = this.cmd.auth || AUTH;
this.insecure = false;

@@ -30,6 +31,4 @@ // Output type normalization from string to array of strings.

// Note: The `rejectUnauthorized` parameter is not working, this is a
// temporary work-around
if (this.cmd.insecure) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
this.insecure = true;
}

@@ -36,0 +35,0 @@

@@ -10,2 +10,13 @@ 'use strict';

/**
* Log a debug message.
*
* @param {String|Array} message
* The debug message to log
*/
debug(...message) {
if (!this.debugMode) return;
console.log(...message);
},
/**
* Log an error.

@@ -12,0 +23,0 @@ *

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc