Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/**
* Copyright (C) 2022-2023 Red Hat, Inc. (https://github.com/Commonjava/indy-model)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.commonjava.indy.pkg.npm.content;

import java.util.Optional;

import static org.commonjava.indy.util.PathUtils.normalize;

public class PackagePath
{

private String tarPath;

private Boolean scoped;

private String packageName;

private String version;

private String scopedName;

public PackagePath(String tarPath )
{
this.tarPath = tarPath;
init();
}

private void init()
{
String[] pathParts = tarPath.split( "/" );
if ( tarPath.startsWith( "@" ) )
{
scoped = Boolean.TRUE;
scopedName = pathParts[0];
packageName = pathParts[1];
if ( pathParts.length == 4 && "-".equals( pathParts[2] ) )
{
String tarName = pathParts[3];
version = tarName.substring( packageName.length() + 1, tarName.length() - 4 );
}
else if ( pathParts.length == 3 )
{
version = pathParts[2];
}
}
else
{
scoped = Boolean.FALSE;
packageName = pathParts[0];
if ( pathParts.length == 3 && "-".equals( pathParts[1] ) )
{
String tarName = pathParts[2];
version = tarName.substring( packageName.length() + 1, tarName.length() - 4 );
}
else if ( pathParts.length == 2 )
{
version = pathParts[1];
}
}
}

public String getTarPath()
{
return tarPath;
}

public void setTarPath( String tarPath )
{
this.tarPath = tarPath;
}

public Boolean isScoped()
{
return scoped;
}

public void setScoped( Boolean scoped )
{
this.scoped = scoped;
}

public String getPackageName()
{
return packageName;
}

public void setPackageName( String packageName )
{
this.packageName = packageName;
}

public String getVersion()
{
return version;
}

public void setVersion( String version )
{
this.version = version;
}

public String getScopedName()
{
return scopedName;
}

public void setScopedName( String scopedName )
{
this.scopedName = scopedName;
}

public String getVersionPath()
{
return isScoped() ? normalize( scopedName, packageName, version ) : normalize( packageName, version );
}

public static Optional<PackagePath> parse( final String tarPath )
{
String path = tarPath;
if ( path.startsWith( "/" ) )
{
path = path.substring( 1 );
}
String[] parts = path.split( "/" );
if ( parts.length < 2 )
{
return Optional.empty();
}
else if ( path.startsWith( "@" ) && parts.length < 3 )
{
return Optional.empty();
}
PackagePath packagePath = new PackagePath( path );
return Optional.of( packagePath );
}

@Override
public String toString()
{
return "PackagePath{" + "tarPath='" + tarPath + '\'' + ", scoped=" + scoped + ", packageName='"
+ packageName + '\'' + ", version='" + version + '\'' + ", scopedName='" + scopedName + '\''
+ '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (C) 2022-2023 Red Hat, Inc. (https://github.com/Commonjava/indy-model)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.commonjava.indy.pkg.npm.model;

public class Bugs
{

private final String url;

private final String email;

protected Bugs()
{
this.url = null;
this.email = null;
}

public Bugs( final String url )
{
this.url = url;
this.email = null;
}

public Bugs( final String url, final String email )
{
this.url = url;
this.email = email;
}

public String getUrl()
{
return url;
}

public String getEmail()
{
return email;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright (C) 2022-2023 Red Hat, Inc. (https://github.com/Commonjava/indy-model)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.commonjava.indy.pkg.npm.model;

import java.util.List;

public class Commitplease
{

private final Boolean nohook;

private final List<String> components;

private final String markerPattern;

private final String ticketPattern;

protected Commitplease()
{
this.nohook = null;
this.components = null;
this.markerPattern = null;
this.ticketPattern = null;
}

public Commitplease( final Boolean nohook, final List<String> components, final String markerPattern,
final String ticketPattern )
{
this.nohook = nohook;
this.components = components;
this.markerPattern = markerPattern;
this.ticketPattern = ticketPattern;
}

public Boolean getNohook()
{
return nohook;
}

public List<String> getComponents()
{
return components;
}

public String getMarkerPattern()
{
return markerPattern;
}

public String getTicketPattern()
{
return ticketPattern;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* Copyright (C) 2022-2023 Red Hat, Inc. (https://github.com/Commonjava/indy-model)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.commonjava.indy.pkg.npm.model;

import java.util.HashMap;
import java.util.Map;

public class Directories
{
private static final String LIB = "lib";

private static final String BIN = "bin";

private static final String MAN = "man";

private static final String DOC = "doc";

private static final String EXAMPLE = "example";

private static final String TEST = "test";

private Map<String, String> directoriesMap = new HashMap<String, String>();

protected Directories()
{
}

public String getLib()
{
return directoriesMap.get( LIB );
}

public void setLib( String lib )
{
directoriesMap.put( LIB, lib );
}

public String getBin()
{
return directoriesMap.get( BIN );
}

public void setBin( String bin )
{
directoriesMap.put( BIN, bin );
}

public String getMan()
{
return directoriesMap.get( MAN );
}

public void setMan( String man )
{
directoriesMap.put( MAN, man );
}

public String getDoc()
{
return directoriesMap.get( DOC );
}

public void setDoc( String doc )
{
directoriesMap.put( DOC, doc );
}

public String getExample()
{
return directoriesMap.get( EXAMPLE );
}

public void setExample( String example )
{
directoriesMap.put( EXAMPLE, example );
}

public String getTest()
{
return directoriesMap.get( TEST );
}

public void setTest( String test )
{
directoriesMap.put( TEST, test );
}

public Map<String, String> fetchDirectoriesMap()
{
return directoriesMap;
}

public String getDirectory( String name )
{
return directoriesMap.get( name );
}

public void putDirectory( String name, String value )
{
directoriesMap.put( name, value );
}
}
Loading