Installing and publishing packages

How to install and publish packages

For ecosystem specific configuration see: npm and Maven

These steps assume you already have access to a Bytesafe workspace and have authenticated to a registry. If not, read Getting started.

Installing packages from your private registry

To install npm packages using npm, see the example below.

npm --registry https://{WORKSPACE}.bytesafe.dev/r/{REGISTRY}/ install {PACKAGE}

The installed package dependencies are now stored and available in Bytesafe.

To add npm packages using yarn, see the example below.

yarn --registry https://{WORKSPACE}.bytesafe.dev/r/{REGISTRY}/ add {PACKAGE}

The added package dependencies are now stored and available in Bytesafe.

To add npm packages using pnpm, see the example below.

pnpm add {PACKAGE} --registry https://e{WORKSPACE}.bytesafe.dev/r/{REGISTRY}/ 

The added package dependencies are now stored and available in Bytesafe.

Maven dependencies are specified with <dependency> in the pom.xml file. If required, copy-paste ready version specific instructions are available on any package version page in Bytesafe.

<!-- Add dependencies be specifying them in the pom.xml file -->
<dependency>
    <groupId>{GROUP_ID}</groupId>
    <artifactId>{ARTIFACT_ID}<artifactId>
    <version>{PACKAGE_VERSION}</version>
</dependency>

With project dependencies specified in the pom.xml file (using valid settings.xml), you can install dependencies using regular Maven commands like mvn install or mvn verify.

# Install Maven dependencies from Bytesafe
$ mvn clean install

With a public repository, like Maven Central as an upstream for a registry, Bytesafe will proxy public dependencies and pull any required version into Bytesafe.

NuGet dependencies are specified as package references (<PackageReference>) in the project file (.csproj). Manage project dependencies by editing the .csproj and adding any required package references.

<!-- Example package reference in .csproj file -->
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />

To restore project dependencies run the nuget restore command.

# Restore package dependencies from Bytesafe
$ nuget restore -Source {REGISTRY}

Publishing packages to your registry

Publish your npm packages to your Bytesafe registry with npm.

npm --registry https://{WORKSPACE}.bytesafe.dev/r/{REGISTRY}/ publish {PACKAGE}

Publish your npm packages to your Bytesafe registry with yarn.

yarn --registry https://{WORKSPACE}.bytesafe.dev/r/{REGISTRY}/ publish {PACKAGE}

Publish your npm packages to your Bytesafe registry with pnpm.

pnpm publish {PACKAGE} --registry https://{WORKSPACE}.bytesafe.dev/r/{REGISTRY}/

Maven artifacts can be added to Bytesafe either using mvn deploy or by uploading files manually in Bytesafe.

To deploy using mvn users need to add the necessary configuration to the project pom.xml file.

See the registry information in Bytesafe for workspace specific instructions.

<!-- Add the repository and snapshotRepository configuration to pom.xml -->
<distributionManagement>
    <repository>
        <id>{MAVEN-REGISTRY}</id>
        <url>https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/</url>
    </repository>
    <snapshotRepository>
        <id>{MAVEN-REGISTRY}</id>
        <url>https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/</url>
    </snapshotRepository>
</distributionManagement>

With your maven project sucessfully configured and a valid access token added to settings.xml you can deploy artifacts to Bytesafe.

# Deploy artifacts to Bytesafe using Maven
$ mvn clean deploy

Artifacts are available in Bytesafe as soon as the upload is finalized.

NuGet packages can be added to Bytesafe either using nuget push or by uploading files manually in Bytesafe.

To deploy using nuget users need to add the necessary configuration to the applicable NuGet.Config file.

# add access token apikey for a Bytesafe source. Replace {REGISTRY} with source name
$ nuget setapikey {TOKEN} -Source {REGISTRY}
...

With an available apikey for the source, publish the to Bytesafe package using nuget push.

# Publish package to registry using nuget. Replace {REGISTRY} with source name
$ nuget push {PACKAGE} -Source {REGISTRY}
...

Packages are available in Bytesafe as soon as the upload is finalized.