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

export-gitlab-variables

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

export-gitlab-variables - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

.editorconfig

39

cli.ts
#!/usr/bin/env node
import axios from 'axios'
import { Command } from 'commander';
import { spawn } from 'child_process'
import axios, {AxiosInstance} from 'axios'
import {Command} from 'commander';
import {spawn} from 'child_process'
async function fetchAllGitlabVariables(gitlabApi: AxiosInstance, opts: { project: string }) {
const variables: Variable[] = [];
let page = 1;
do {
const {
data: currentPage
} = await gitlabApi.get<Variable[]>(`/api/v4/projects/${opts.project}/variables?per_page=100&page=${page}`)
const isLastPage = currentPage.length == 0;
if (isLastPage) {
break;
}
variables.push(...currentPage)
page += 1;
} while (true);
return variables;
}
async function main() {

@@ -22,3 +44,8 @@ const program = new Command();

const opts = program.opts();
const opts = program.opts() as {
project: string
url: string
environment: string
accessToken: string
};

@@ -32,3 +59,3 @@ const gitlabApi = axios.create({

const { data: variables } = await gitlabApi.get<Variable[]>(`/api/v4/projects/${opts.project}/variables?per_page=1000`)
const variables = await fetchAllGitlabVariables(gitlabApi, opts);

@@ -45,3 +72,3 @@ const newEnvVariables = variables.filter(variable => {

})
.reduce((acc, cur) => ({ ...acc, [cur.key]: cur.value }), {})
.reduce((acc, cur) => ({...acc, [cur.key]: cur.value}), {})

@@ -48,0 +75,0 @@ const combinedEnvs = {

@@ -57,2 +57,29 @@ #!/usr/bin/env node

var child_process_1 = require("child_process");
function fetchAllGitlabVariables(gitlabApi, opts) {
return __awaiter(this, void 0, void 0, function () {
var variables, page, currentPage, isLastPage;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
variables = [];
page = 1;
_a.label = 1;
case 1: return [4 /*yield*/, gitlabApi.get("/api/v4/projects/" + opts.project + "/variables?per_page=100&page=" + page)];
case 2:
currentPage = (_a.sent()).data;
isLastPage = currentPage.length == 0;
if (isLastPage) {
return [3 /*break*/, 4];
}
variables.push.apply(variables, currentPage);
page += 1;
_a.label = 3;
case 3:
if (true) return [3 /*break*/, 1];
_a.label = 4;
case 4: return [2 /*return*/, variables];
}
});
});
}
function main() {

@@ -78,5 +105,5 @@ return __awaiter(this, void 0, void 0, function () {

});
return [4 /*yield*/, gitlabApi.get("/api/v4/projects/" + opts.project + "/variables?per_page=1000")];
return [4 /*yield*/, fetchAllGitlabVariables(gitlabApi, opts)];
case 1:
variables = (_b.sent()).data;
variables = _b.sent();
newEnvVariables = variables.filter(function (variable) {

@@ -83,0 +110,0 @@ var isDefault = variable.environment_scope == '*';

2

package.json
{
"name": "export-gitlab-variables",
"version": "1.0.2",
"version": "1.0.3",
"description": "Fetch and export Gitlab variables for use by child process",

@@ -5,0 +5,0 @@ "bin": {

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