npm

package
v0.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <[email protected]>

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultVersionResolutionStrategy added in v0.3.0

func DefaultVersionResolutionStrategy(versions semver.Collection) *semver.Version

DefaultVersionResolutionStrategy returns the highest semantic version in a collection of versions.

func GetFromRegistry

func GetFromRegistry(ctx context.Context, name, version string) (io.ReadCloser, string, error)

GetFromRegistry asks to the npm registry for the details of a package by name, and optionally, by version.

func GetVersionsFromRegistry added in v0.3.0

func GetVersionsFromRegistry(ctx context.Context, name string, constraints *semver.Constraints) (semver.Collection, error)

func GetVersionsFromRegistryResponse added in v0.3.0

func GetVersionsFromRegistryResponse(body io.ReadCloser, constraints *semver.Constraints) (semver.Collection, error)

func Version

func Version(ctx context.Context) (string, error)

Version returns the npm version.

Or it errors out if unable to find the npm executable.

Types

type LockfileVersion

type LockfileVersion struct {
	Value int `json:"lockfileVersion" name:"lockfile version" validate:"gte=1,lte=3"`
}

type Package

type Package struct {
	Version string `json:"version" name:"version" validate:"semver"`
	Shasum  string `json:"shasum" name:"shasum" validate:"shasum"`
}

func (*Package) Ok

func (p *Package) Ok() bool

type PackageJSON added in v0.3.0

type PackageJSON interface {
	FilterOutByTypes(...npmdeptype.Enum)
	FilterOutByNames(...string)
	Deps(context.Context, VersionResolutionStrategy) map[npmdeptype.Enum]map[string]*semver.Version
}

func GetPackageJSONFromDir added in v0.3.0

func GetPackageJSONFromDir(dir string) (PackageJSON, error)

GetPackageJSONFromDir creates a PackageJSON instance from the existing package.json in dir, if any.

func NewPackageJSONFromReader added in v0.3.0

func NewPackageJSONFromReader(reader io.Reader) (PackageJSON, error)

type PackageLockDependency

type PackageLockDependency struct {
	Version  string `json:"version"`
	Resolved string `json:"resolved"`
}

type PackageLockJSON

type PackageLockJSON interface {
	listentype.AnalysisRequester
	Deps() map[string]PackageLockDependency
	Version() int
}

func GetPackageLockJSONFromDir added in v0.11.0

func GetPackageLockJSONFromDir(dir string) (PackageLockJSON, error)

GetPackageLockJSONFromDir creates a PackageLockJSON instance from the existing package-lock.json in dir, if any.

func NewPackageLockJSON

func NewPackageLockJSON() PackageLockJSON

NewPackageLockJSON is a factory to create an empty (and invalid) PackageLockJSON.

func NewPackageLockJSONFromBytes

func NewPackageLockJSONFromBytes(b []byte) (PackageLockJSON, error)

func NewPackageLockJSONFromDir

func NewPackageLockJSONFromDir(ctx context.Context, dir string) (PackageLockJSON, error)

NewPackageLockJSONFromDir creates a PackageLockJSON instance from the package.json in the dir directory (if any).

func NewPackageLockJSONFromReader

func NewPackageLockJSONFromReader(reader io.Reader) (PackageLockJSON, error)

NewPackageLockJSONFromReader creates a PackageLockJSON instance from by reading the contents of a package-lock.json file.

type Packages

type Packages map[string]Package

func (Packages) Ok

func (p Packages) Ok() bool

type VersionResolutionStrategy added in v0.3.0

type VersionResolutionStrategy func(semver.Collection) *semver.Version

The VersionResolutionStrategy is a function that, given a version constraints, returns back an exact version.

Directories

Path Synopsis
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL