class Zap::Package
- Zap::Package
- Reference
- Object
Overview
A class that represents a package. It is used to store the information about a package and to resolve dependencies.
Serializable to:
- JSON (package.json like)
- YAML (lockfile entry)
Included Modules
- JSON::Serializable
- MessagePack::Serializable
- YAML::Serializable
- Zap::Package::Helpers::Dependencies
- Zap::Utils::Macros
Defined in:
package/dist.crpackage/kind.cr
package/lifecycle_scripts.cr
package/overrides.cr
package/package.cr
package/package_extensions.cr
Constant Summary
-
DEFAULT_ROOT =
"@root"
Constructors
- .init(path : Path, *, append_filename : Bool = true, name_if_nil : String | Nil = nil) : self
- .init_root_package(path : Path, *, append_filename : Bool = true) : self
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(pull : JSON::PullParser)
- .new(pull : MessagePack::Unpacker)
- .new(name : Nil | String = DEFAULT_ROOT, version : String = "0.0.0")
- .read_package(config : Config) : Package
- .read_package?(config : Config) : Package
Class Method Summary
- .get_pkg_version_from_json(json_path : Path | String) : String | Nil
- .hash_dependencies(peers : Iterable(Package))
- .init?(path : Path, *, append_filename : Bool = true) : self | Nil
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. - #add_dependency(name : String, version : String, type : DependencyType)
- #after_initialize
- #bin : String | Hash(String, String) | Nil
- #bundle_dependencies : Hash(String, String) | Bool | Nil
- #cpu : Array(String) | Nil
- #dependencies : Hash(String, String | Zap::Package::Alias) | Nil
- #dependencies=(dependencies : Hash(String, String | Zap::Package::Alias) | Nil)
- #dependents : Set(Package)
- #deprecated : String | Nil
- #dev_dependencies : Hash(String, String | Zap::Package::Alias) | Nil
- #dev_dependencies=(dev_dependencies : Hash(String, String | Zap::Package::Alias) | Nil)
- #dist : Dist::Registry | Dist::Link | Dist::Tarball | Dist::Git | Dist::Workspace | Nil
- #dist=(dist : Dist::Registry | Dist::Link | Dist::Tarball | Dist::Git | Dist::Workspace | Nil)
- #get_root_dependents? : Set(String) | Nil
- #has_install_script : Bool | Nil
- #has_install_script=(has_install_script : Bool | Nil)
- #has_prepare_script : Bool | Nil
- #has_prepare_script=(has_prepare_script : Bool | Nil)
-
#hash(hasher)
See
Object#hash(hasher)
- #hashed_key : String
- #key : String
- #kind : Kind
-
#local_install?
Attempt to replicate the "npm" definition of a local install Which seems to be packages pulled from git or linked locally
- #lock : Mutex
-
#match_os_and_cpu! : Nil
Will raise if the package is not meant to be run on the current architecture and operating system.
-
#match_os_and_cpu? : Bool
Returns false if the package is not meant to be run on the current architecture and operating system.
- #name : String
- #name? : String | Nil
- #optional : Bool | Nil
- #optional=(optional : Bool | Nil)
- #optional_dependencies : Hash(String, String | Zap::Package::Alias) | Nil
- #optional_dependencies=(optional_dependencies : Hash(String, String | Zap::Package::Alias) | Nil)
- #os : Array(String) | Nil
- #override_dependencies!(other : Package)
- #overrides : Overrides | Nil
- #overrides=(overrides : Overrides | Nil)
- #package_extension_shasum : String | Nil
- #package_extension_shasum=(package_extension_shasum : String | Nil)
- #package_extensions_updated : Bool
- #package_extensions_updated=(package_extensions_updated : Bool)
- #peer_dependencies : Hash(String, String) | Nil
- #peer_dependencies=(peer_dependencies : Hash(String, String) | Nil)
- #peer_dependencies_meta : Hash(String, NamedTuple(optional: Bool | Nil)) | Nil
- #peer_dependencies_meta=(peer_dependencies_meta : Hash(String, NamedTuple(optional: Bool | Nil)) | Nil)
- #prepare
- #prevent_pruning : Bool
- #prevent_pruning=(prevent_pruning : Bool)
- #propagate_meta_peer_dependencies!
- #resolved : Atomic(Int8)
- #roots : Set(String)
- #roots=(roots : Set(String))
- #scripts : LifecycleScripts | Nil
- #scripts=(scripts : LifecycleScripts | Nil)
- #specifier : String
- #transitive_overrides : SafeSet(Package::Overrides::Override) | Nil
- #transitive_overrides=(transitive_overrides : SafeSet(Package::Overrides::Override) | Nil)
- #transitive_overrides_init(&block : Proc(SafeSet(Package::Overrides::Override) | Nil))
- #transitive_peer_dependencies : Hash(String, Set(Utils::Semver::Range)) | Nil
- #transitive_peer_dependencies=(transitive_peer_dependencies : Hash(String, Set(Utils::Semver::Range)) | Nil)
- #version : String
- #workspaces : Array(String) | Nil | NamedTuple(packages: Array(String) | Nil, nohoist: Array(String) | Nil)
- #zap_config : ZapConfig | Nil
- #zap_config=(zap_config : ZapConfig | Nil)
Macro Summary
Instance methods inherited from module Zap::Package::Helpers::Dependencies
add_dependency_ref(package : Package, type : DependencyType | Nil = nil)
add_dependency_ref,
dependencies_refs
dependencies_refs,
dependencies_size(*, include_dev : Bool = true, include_optional : Bool = true) : Int
dependencies_size,
dependency_specifier(name : String, specifier : String | Zap::Package::Alias, type : DependencyType | Nil = nil) : Nil
dependency_specifier,
dependency_specifier?(name : String, *, include_dev : Bool = true, include_optional : Bool = true) : String | Zap::Package::Alias | Nil
dependency_specifier?,
dev_dependencies_refs
dev_dependencies_refs,
each_dependency(*, include_dev : Bool = true, include_optional : Bool = true, &block : String, String | Alias, DependencyType -> Nil)
each_dependency,
each_dependency_hash(*, include_dev : Bool = true, include_optional : Bool = true, &block : Hash(String, String | Alias) | Nil, DependencyType -> T) forall T
each_dependency_hash,
each_dependency_ref(*, include_dev : Bool = true, include_optional : Bool = true, &block : Package, DependencyType -> Nil)
each_dependency_ref,
has_dependency?(name : String, *, include_dev : Bool = true, include_optional : Bool = true) : Bool | Nil
has_dependency?,
map_dependencies(*, include_dev : Bool = true, include_optional : Bool = true, &block : String, String | Alias, DependencyType -> T) : Array(T) forall T
map_dependencies,
optional_dependencies_refs
optional_dependencies_refs,
trim_dependencies_fields
trim_dependencies_fields
Instance methods inherited from class Object
or(other : T) : T | self forall T
or,
pipe(&)
pipe
Constructor Detail
Class Method Detail
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Attempt to replicate the "npm" definition of a local install Which seems to be packages pulled from git or linked locally
Will raise if the package is not meant to be run on the current architecture and operating system.
Returns false if the package is not meant to be run on the current architecture and operating system.