Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbolino committed Aug 25, 2019
0 parents commit b1a87fb
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ENDPOINT=https://gitlab.example.com/api/v4/
API_KEY=123456789ABCDEFGHIJKL
METHOD=ssh
PORT=22
INCLUDE_BRANCHES=true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/confs/static-repos.json
/vendor
/composer.lock
/.idea
/.php_cs.cache
/.env
18 changes: 18 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use PhpCsFixer\Config;
use Symfony\Component\Finder\Finder;

$finder = Finder::create()
->in(__DIR__)
->name('*.php')
->exclude('vendor')
->ignoreDotFiles(true)
->ignoreVCS(true);

return Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder);
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Gitlab NPM repository

Small script that loops through all branches and tags of all projects in a Gitlab installation
and if it contains a `package.json`, and has a non empty `name` it is added.

This script is not a full repository like npmjs.com, but only implements the install command.

## Installation

1. Run `composer install`
2. Copy `.env.example` to `.env`
3. Get a "personal access token" with scopes: `api,read_repository`
4. For some reason npm sends `/` like `%2F`, so you need to set `AllowEncodedSlashes NoDecode` inside your `<VirtualHost>`

## Usage

Simply include a package.json in your project, all branches and tags using
[semver](https://semver.org/) will be detected. "v1.2.3" will be converted to "1.2.3"

To use your repository, use this command to install the packages:
```
npm install project-name --registry http://npm.gitlab.localhost/
```

## Warning

This script could allow access to private repositories. Because I haven't figured out the
correct way for npm authorization, the current .htaccess restricts to local usage.
So be sure to update the .htaccess to match your requirements.

## Author
* [Maglr](https://github.com/maglr)
2 changes: 2 additions & 0 deletions cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"require": {
"m4tthumphrey/php-gitlab-api": "^9.0",
"php-http/guzzle6-adapter": "^1.1",
"vlucas/phpdotenv": "^3.4",
"ext-json": "*",
"ext-curl": "*"
},
"scripts": {
"post-install-cmd": [
"chmod 777 cache || true"
]
}
}
1 change: 1 addition & 0 deletions docs
6 changes: 6 additions & 0 deletions public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DirectoryIndex /index.php
FallbackResource /index.php

Require ip ::1
Require ip 127.0.0.1
Require ip 192.168.1
Loading

0 comments on commit b1a87fb

Please sign in to comment.