Package Exports
- npm-pkgbuild
Readme
npm-pkgbuild
Create ArchLinux, RPM, Debian and Docker packages from npm packages.
usage
In a package directory execute
npm-pkgbuild --rpm --debian --arch --content /destination:build --publish /some/directoryThis will create a arch, rpm and a debian package of the build dir.
upload package
npm-pkgbuild --arch --content build --publish 'https://my.package-service.com/binaries/linux/{{type}}/{{access}}/{{arch}}'You can specify the package content in package.json.
{
"pkgbuild": {
"content": {
"/some/location/" : { "base": "build" },
"/etc/myconfig.json" : "sample-config.json",
"/erc/secret" : { "name": "secret", "mode": "600" },
"/opt/myapp": [
{
"type": "npm-pack"
},
{
"type": "node-modules",
"withoutDevelpmentDependencies": true
}
]
},
"hooks" : "pkg/hooks",
"output": {
"debian" : {},
"rpm" : {},
"arch" : {}
},
"dependencies": { "nginx" : ">=1.12" }
}
}content providers
Defining where the package content should come from.
files (default)
content from the file system
npm-pack
content as provided by npm pack
node-modules
content of all (production) dependencies
options: - withoutDevelpmentDependencies when to stip away dev dependencies (defaults to true)
shared configuration
You can import common configuration from other packages. See mf-hosting or mf-hosting-frontend modules.
API
Table of Contents
- allInputs
- allOutputs
- npmArchMapping
- content2Sources
- PackageDefinition
- extractFromPackage
- NPMPackContentProvider
- NodeModulesContentProvider
- FileContentProvider
- NFTContentProvider
- ContentProvider
- DEBIAN
- fields
- fields
- fields
- fields
- pkgKeyValuePairOptions
- quoteFile
- RPM
- OCI
- DOCKER
- BUILDAH
- Packager
- Packager
- Field
- copyNodeModules
- PublishingDetail
- createPublishingDetails
- publish
- utf8StreamOptions
- decodePassword
- FunctionDecl
- extractFunctions
- fieldProvider
- Expander
- copyEntries
allInputs
All content providers (input)
allOutputs
All output formats
npmArchMapping
Node architecture name to os native arch name mapping {@see https://nodejs.org/dist/latest-v18.x/docs/api/process.html#processargv}
content2Sources
Delivers ContentProviders from pkgbuild.content definition.
Parameters
contentObject from pkgbuild.contentdir
Returns Iterable<ContentProvider>
PackageDefinition
Type: Object
Properties
propertiesObject values describing the package attributesproperties.dependenciesObject
sourcesArray<ContentProvider> content providersoutputObject package typevariantObject identifier of the variant
extractFromPackage
Extract package definition from package.json.
- for each architecture deliver a new result
- if no architecture is given one result set is provided nethertheless
- architectures are taken from cpu (node arch ids) and from pkgbuild.arch (raw arch ids)
- architecture given in a variant definition are used to restrict the set of avaliable architectures
Parameters
Returns AsyncIterable<PackageDefinition>
NPMPackContentProvider
Extends ContentProvider
Content from npm pack.
Parameters
Properties
dirstring
name
Returns string name of the content provider
NodeModulesContentProvider
Extends ContentProvider
Content from node_modules. Requires .npmrc or NPM_TOKEN environment
Parameters
definitionsentryPropertiesdirectoryProperties
Properties
withoutDevelpmentDependenciesboolean
name
Returns string name of the content provider
FileContentProvider
Extends ContentProvider
Content provided form the file system.
Parameters
entryPropertiesdirectoryProperties
asyncIterator
Returns AsyncIterable<ContentEntry> all entries
name
Returns string name of the content provider
NFTContentProvider
Extends ContentProvider
Content provided form the file system.
Parameters
entryPropertiesdirectoryProperties
asyncIterator
Returns AsyncIterable<ContentEntry> all entries
name
Returns string name of the content provider
ContentProvider
Source of package content.
Parameters
definitionsentryPropertiesdirectoryProperties
Properties
asyncIterator
List all entries.
Returns AsyncIterable<ContentEntry> all entries
DEBIAN
Extends Packager
Create .deb packages
hookMapping
Map install hook named from default (arch) to deb.
prepare
Parameters
fields
- See: https://www.debian.org/doc/debian-policy/ch-controlfields.html
- See: https://linux.die.net/man/5/deb-control
fields
well known package properties https://www.archlinux.org/pacman/PKGBUILD.5.html
fields
fields
pkgKeyValuePairOptions
Type: Object
quoteFile
Parameters
name
RPM
Extends Packager
Produce rpm packages.
hookMapping
Map install hook named from default (arch) to rpm.
prepare
Check for rpmbuild presence.
Parameters
Returns Promise<boolean> true when rpmbuild executable is present
OCI
Extends Packager
Low level OCI compatible packager
DOCKER
Extends Packager
docker image build
prepare
Check for docker presence.
Parameters
Returns Promise<boolean> true when docker executable is present
BUILDAH
Extends DOCKER
Use buildah @see https://buildah.io
Packager
Parameters
properties
packageName
What is the package name in the package eco-system.
Parameters
namestring
Returns string package name in the target eco-system
tmpdir
Create tmp directory.
Returns Promise<string> directory path
prepare
Prepares artifact generation.
Parameters
Returns Promise<{properties: Object, destination: string, tmpdir: string, staging: string}>
create
Execute package generation.
Parameters
sourcesObjecttransformerArray<Object>publishingDetailsArray<PublishingDetail>optionsObjectexpanderfunction (string): string?
Returns Promise<string> identifier of the resulting package
workspaceLayout
Returns {named: object, others: Array<string>}
prepare
Parameters
Packager
Base Packager
Parameters
propertiesObject
packageName
What is the package name in the package eco-system.
Parameters
namestring
Returns string package name in the target eco-system
tmpdir
Create tmp directory.
Returns Promise<string> directory path
prepare
Prepares artifact generation.
Parameters
Returns Promise<{properties: Object, destination: string, tmpdir: string, staging: string}>
create
Execute package generation.
Parameters
sourcesObjecttransformerArray<Object>publishingDetailsArray<PublishingDetail>optionsObjectexpanderfunction (string): string?
Returns Promise<string> identifier of the resulting package
workspaceLayout
Returns {named: object, others: Array<string>}
prepare
Parameters
Field
Type: Object
Properties
copyNodeModules
Parameters
PublishingDetail
Type: Object
Properties
createPublishingDetails
Parameters
propertiesObject?
Returns Array<PublishingDetail>
publish
Parameters
artifactIdentifierstringpublishingDetailPublishingDetail?propertiesObject?loggerfunction (any): void (optional, defaultconsole.log)
utf8StreamOptions
Type: BufferEncoding
decodePassword
Decode a password
Parameters
passwordstring
Returns string plaintext password
FunctionDecl
Type: Object
Properties
extractFunctions
Extract shell functions from a given text.
Parameters
sourceAsyncIterable<string>
Returns AsyncIterable<FunctionDecl>
fieldProvider
Parameters
Returns Function
Expander
Type: Function
Parameters
pathstring
Returns string
copyEntries
Copy content from source into destinationDirectory. Destination paths a generated without leading '/' (as for entry names too).
Parameters
sourceAsyncIterable<ContentEntry>destinationDirectorystringexpanderExpander (optional, defaultv=>v)
install
With npm do:
npm install npm-pkgbuildlicense
BSD-2-Clause