Composer require private repository from gitlab ssh ignored - ssh

I'm trying to pull a private repository from gitlab with composer without any success.
This is what I have in my composer.json file under repositories:
"repositories": [
{
"type": "vcs",
"url": "git#gitlab.com:the-vendor/dashboard-api.git"
}
]
When I clone the project like this: git#gitlab.com:the-vendor/dashboard-api.git manually, everything works fine.
Now when I require the project like so:
"require": {
"the-vendor/dashboard": "dev-orchestrate"
}
I also tried: "dev-main", "dev-main#dev", "dev-orchestrate#dev".
And run: composer update the-vendor/dashboard I get the following error:
Failed to download the-vendor/dashboard-api:The "https://gitlab.com/api/v4/projects/joij%2Fdashboard-api" file could not be downloaded (HTTP/2 404 ):
{"message":"404 Project Not Found"}
Your credentials are required to fetch private repository metadata (git#gitlab.com:the-vendor/dashboard-api.git)
A token will be created and stored in "/root/.composer/auth.json", your password will never be stored
To revoke access to this token you can visit https://gitlab.com/-/profile/personal_access_tokens
Username:
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
I'm not sure what to make of this. Composer should be able to clone the project through ssh. But instead I get that vague 404 and then I have to give my username and password.
I also tried this:
"repositories": [
{
"type": "git",
"url": "git#gitlab.com:the-vendor/dashboard-api.git"
}
]
But then it behaves as if there is no "repositories" in the composer json at all, and I get this error:
Problem 1
- Root composer.json requires the-vendor/dashboard, it could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
This is the composer.json of the dashboard-api:
{
"name": "the-vendor/dashboard",
"type": "project",
"description": "TheVendor Dashboards",
"keywords": ["framework", "laravel"],
"license": "proprietary",
"require": {
"php": "^8.1",
"elasticsearch/elasticsearch": "v7.17.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.2",
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7",
"ext-pdo": "*"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"phpspec/prophecy": "1.15.0",
"spatie/laravel-ignition": "^1.0"
},
"autoload": {
"psr-4": {
"TheVendor\\Dashboard\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"#php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"providers": [
"TheVendor\\Dashboard\\Providers\\AppServiceProvider",
"TheVendor\\Dashboard\\Providers\\ESClientServiceProvider",
"TheVendor\\Dashboard\\Providers\\ESCreateIndexesServiceProvider"
],
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
I wonder if anyone knows what I'm missing.

Alright! I found the problem. There is no need to go for an auth.json with an API Token. This is where I went wrong:
The main branch had a different package name! The branch I was trying to pull had the right one, but if the main composer.json has a different package name you get this error:
Root composer.json requires the-vendor/dashboard, it could not be found in any version, there may be a typo in the package name.
Once you have that, and require the package like this:
"require": [
"the-vendor/dashboard": "dev-orchestrate"
]
With this in the root of composer.json
"repositories": [
{
"type": "git",
"url": "git#gitlab.com:the-vendor/dashboard-api.git"
}
]
It will simply use ssh to clone the private repository

Related

semantic-release in a GitLab pipeline with multiple users

I'm running a semantic-release job in a GitLab pipeline, it works great but only for my user (I configured it). No one else seems able to trigger a release, even if I merge their code. No errors, everything seems to run smoothly. I'm assuming there's some kind of authentication issue and/or everyone needs their own token or something like that? (I've only configured a token via my account and I'm not sure how I'd instruct someone to do that for multiple accounts in GitLab.)
The pipeline looks like this:
variables:
GL_TOKEN: $GL_TOKEN
stages:
- release
publish:
image: node:lts-alpine
stage: release
before_script:
- apk update
- apk add zip unzip git
- npm ci
script:
- npm run build
- npx semantic-release
only:
refs:
- main
and the config (in the package.json) is:
"release": {
"branches": [
"main"
],
"plugins": [
"#semantic-release/commit-analyzer",
"#semantic-release/release-notes-generator",
[
"#google/semantic-release-replace-plugin",
{
"replacements": [
{
"files": [
"style.css"
],
"from": "Version: .*",
"to": "Version: ${nextRelease.version}",
"results": [
{
"file": "style.css",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
},
{
"files": [
"package.json"
],
"from": "\"version\": \".*\",",
"to": "\"version\": \"${nextRelease.version}\",",
"results": [
{
"file": "package.json",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
}
]
}
],
[
"#semantic-release/git",
{
"assets": [
"style.css",
"package.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}
],
[
"#semantic-release/exec",
{
"prepareCmd": "node bin/makezip.js"
}
],
[
"#semantic-release/gitlab",
{
"assets": [
{
"path": "file.zip",
"label": "compiled release"
}
]
}
]
]
}
I would suggest creating token per project and using that instead of your personal token.
You can create project token from project Settings > Access Token
This should solve your issue.

Avoiding 2nd semantic-release Commit on Bitbucket Cloud

I'm using Bitbucket Cloud and everything works wonderfully using pipelines, except I always get an extra commit after my release/tag commit, as follows:
Notes added by 'git notes add' -- author: semantic-release-bot
Is there any way to avoid this?
Here's my config:
"release": {
"plugins": [
"#semantic-release/commit-analyzer",
[
"#semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"#semantic-release/npm",
{
"npmPublish": false
}
],
[
"#semantic-release/git",
{
"assets": ["CHANGELOG.md"]
}
]
]
},
#Sammy - Have you tried to set the message for the commit? Bitbucket recommends using [skip ci] in pipelines
{
"path": "#semantic-release/git",
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}

Npm Publish Issue - Artifactory

I am publishing an npm library to an npm repo on artifactory. The library is built using angular and the dist folder and package.json looks correct. When publishing, the request it's self is published but not the actual artifact.
All i see on artifactory is a single file and not a folder containing my package
Running
npm publish
Package.json
{
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.0",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
}
}
What actually gets published to artifactory in a single file.
{
"_id": "#abce/embedded-auth",
"name": "#abce/embedded-auth",
"dist-tags": {
"latest": "1.0.0-dev.1"
},
"versions": {
"1.0.0-dev.1": {
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.1",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce-auth.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
},
"readme": "ERROR: No README data found!",
"_id": "#abce/embedded-auth#1.0.0-dev.1",
"_npmVersion": "6.4.1",
"_nodeVersion": "10.15.3",
"_npmUser": {
"name": "deployment",
"email": "bob#bob.ie"
},
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"dist": {
"integrity": "sha512-rpTN1sMpwnMwehzWUqbV+zElzaOlF5ekQRCQMncy6c+i4TAp5jbBobvzrhgl0ORqHgJn3Eo+EcrRgYLSjV7MdQ==",
"shasum": "71f654dd5fddb20a9d5063171d5293424a4271c7",
"tarball": "http://abce.jfrog.io/abce/internal-npm-dev/#abce/embedded-auth/-/#abce/embedded-auth-1.0.0-dev.1.tgz"
}
}
},
"readme": "ERROR: No README data found!",
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"_attachments": {
"#abce/embedded-auth-1.0.0-dev.1.tgz": {
"content_type": "application/octet-stream",
"data": "correctly populated tarball base64 data here. I checked it and it is correct",
"length": 12092
}
}
}
Expect:
I would expect the package to be parsed from the request and the package published correctly
Actual:
The put request data from the npm publish command is published as a file
npm version: 6.9.0
node version: v12.3.1(has also been run with 10.15.3)
Any ideas?
Please check the registry URL that you are using from npm, if it doesn't include /api/npm - it is invalid.
Wrong URL: https://domain/artifactory/some-directory/.
Valid URL: https://domain/artifactory/api/npm/some-directory/.

Unable to resolve 'react-navigation'

Am trying out react-native and get below error, when I install and try to use react-navigation (import {StackNavigator} from 'react-navigation';).
Error
I use the following command to install "react-navigation" : npm install --save react-navigation
On running above command I get 'react-navigation' folder under node_modules folder, with just a single file (package.json). Below is the content of the file:
{
"_args": [
[
{
"raw": "react-navigation#0.0.0",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"/Users/rakesh-1812/Documents/REACT_JS/SimpleApp"
]
],
"_from": "react-navigation#0.0.0",
"_id": "react-navigation#0.0.0",
"_inCache": true,
"_location": "/react-navigation",
"_nodeVersion": "4.2.1",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/react-navigation-0.0.0.tgz_1459892254509_0.1584461957681924"
},
"_npmUser": {
"name": "ericvicenti",
"email": "ericvicenti#gmail.com"
},
"_npmVersion": "2.14.7",
"_phantomChildren": {},
"_requested": {
"raw": "react-navigation#0.0.0",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz",
"_shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"_shrinkwrap": null,
"_spec": "react-navigation#0.0.0",
"_where": "/Users/rakesh-1812/Documents/REACT_JS/SimpleApp",
"dependencies": {},
"description": "Coming Soon",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"tarball": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz"
},
"maintainers": [
{
"name": "ericvicenti",
"email": "ericvicenti#gmail.com"
}
],
"name": "react-navigation",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"scripts": {},
"version": "0.0.0"
}
Can someone please help me resolve the issue. Thanks in advance.
React navigation is still in beta. It works for me when I use the command:
npm install --save react-navigation#1.0.0-beta.7
This is the latest release. https://github.com/react-community/react-navigation/releases
You must stop your node server and start it again.
Do it:
sudo lsof -n -i4TCP:8081 | grep LISTEN
It will listen of the services that are running on port 8081. By default, react native server runs on it. Then, execute the command below to kill the server process.
kill -9 <cma process id>
Finally, run your project again with
react-native run-ios
on the project folder
I was unable to install react-native, tried everything from the internet. Using Yarn instead of npm resolved the problem.
Try installing react-navigation stack, npm i react-navigation-stack. Then import {createStackNavigator} from 'react-navigation-stack'
Stop the server and run your project again.

composer / satis svn repository http basic authentication

I am trying to create a composer package repository for my company using satis.
My svn repositories are acessed via http (apache svn).
I am trying to add this to my config.json of satis
{
"name": "packages",
"homepage": "http://packages.example.org",
"repositories": [
{ "type": "svn",
"url": "myrepourl"
}
],
"require-all": true
}
THe problem is that I cant authenticate in the repository:
Repository could not be processed, svn: OPTIONS of authorization failed. basic authentication rejected.
How can I pass the username/password to satis?.
Thank you
According to composer documentation, you have to put your user key files or your certificate in your project, not in the satis configuration :
Using SSH :
{
"repositories": [
{
"type": "composer",
"url": "ssh2.sftp://example.org",
"options": {
"ssh2": {
"username": "composer",
"pubkey_file": "/home/composer/.ssh/id_rsa.pub",
"privkey_file": "/home/composer/.ssh/id_rsa"
}
}
}
]
}
Using Certificate :
{
"repositories": [
{
"type": "composer",
"url": "https://example.org",
"options": {
"ssl": {
"cert_file": "/home/composer/.ssl/composer.pem",
}
}
}
]
}