package_json 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/CLAUDE.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -3
- data/lib/package_json/managers/base.rb +3 -3
- data/lib/package_json/managers/bun_like.rb +9 -2
- data/lib/package_json/managers/npm_like.rb +9 -2
- data/lib/package_json/managers/pnpm_like.rb +9 -2
- data/lib/package_json/managers/yarn_berry_like.rb +9 -2
- data/lib/package_json/managers/yarn_classic_like.rb +9 -2
- data/lib/package_json/version.rb +1 -1
- data/sig/package_json/managers/base.rbs +2 -2
- data/sig/package_json/managers/bun_like.rbs +2 -0
- data/sig/package_json/managers/npm_like.rbs +2 -0
- data/sig/package_json/managers/pnpm_like.rbs +2 -0
- data/sig/package_json/managers/yarn_berry_like.rbs +2 -0
- data/sig/package_json/managers/yarn_classic_like.rbs +2 -0
- data/sig/package_json.rbs +8 -4
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f55805d478e11aa4c918eb7b8acd0b1dc2dfead0488cc931f50a10a1b0b4ea18
|
|
4
|
+
data.tar.gz: 727ce06575bfe624628999e5ad6ef18b07caf10c4bad32af75a8fb78837b4f6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 876cae7108678cb22b42c15e8fa68a65e301235b4420309a077410dc06fc311a531335d0d5382c581477d70e2cd96dabc5f7177b2be05c05f7b9d623ae19ef97
|
|
7
|
+
data.tar.gz: f91171d95c197651ee4257d0beb728d9b5c504cd2d3290a8bfae5a36d1d18163108ec119a17c04408c3bf9c9c7fec0da8600b909a6f44989f9b4c8b477bac8ff
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2025-11-06
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Add support for `exact` parameter in `add` method to install packages with
|
|
8
|
+
exact versions ([#29](https://github.com/shakacode/package_json/pull/29))
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Ensure RBS for `PackageJson` class is correct
|
|
13
|
+
([#39](https://github.com/shakacode/package_json/pull/39))
|
|
14
|
+
|
|
3
15
|
## [0.1.1] - 2025-11-04
|
|
4
16
|
|
|
5
17
|
### Changed
|
data/CLAUDE.md
CHANGED
|
@@ -79,6 +79,13 @@ files and JavaScript package managers.
|
|
|
79
79
|
- **Testing**: RSpec for Ruby tests
|
|
80
80
|
- **Linting**: RuboCop for Ruby
|
|
81
81
|
|
|
82
|
+
## Type Signatures & Documentation
|
|
83
|
+
|
|
84
|
+
**This project uses RBS (Ruby Signature) files for type documentation**
|
|
85
|
+
|
|
86
|
+
Everything should be captured in the type definitions, including private
|
|
87
|
+
methods.
|
|
88
|
+
|
|
82
89
|
## Important Notes
|
|
83
90
|
|
|
84
91
|
- This gem provides a "middle-level" abstraction over JavaScript package
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -177,11 +177,15 @@ package_json.manager.add(["eslint", "prettier"], type: :dev)
|
|
|
177
177
|
|
|
178
178
|
# adds dotenv-webpack v6 as a production dependency
|
|
179
179
|
package_json.manager.add(["dotenv-webpack@^6"])
|
|
180
|
+
|
|
181
|
+
# adds react-on-rails with exact version (no ^ or ~)
|
|
182
|
+
package_json.manager.add(["react-on-rails@16.0.0"], exact: true)
|
|
180
183
|
```
|
|
181
184
|
|
|
182
|
-
| Option
|
|
183
|
-
|
|
|
184
|
-
| `type`
|
|
185
|
+
| Option | Description |
|
|
186
|
+
| ------- | ------------------------------------------------------------------------------------------- |
|
|
187
|
+
| `type` | The type to add the dependencies as; either `:production` (default), `:dev`, or `:optional` |
|
|
188
|
+
| `exact` | If true, saves packages with exact versions (no `^` or `~` prefix) |
|
|
185
189
|
|
|
186
190
|
#### Removing dependencies
|
|
187
191
|
|
|
@@ -40,13 +40,13 @@ class PackageJson
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# Adds the given packages
|
|
43
|
-
def add(packages, type: :production)
|
|
43
|
+
def add(packages, type: :production, exact: false)
|
|
44
44
|
raise NotImplementedError
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Adds the given packages
|
|
48
|
-
def add!(packages, type: :production)
|
|
49
|
-
raise_exited_with_non_zero_code_error unless add(packages, type: type)
|
|
48
|
+
def add!(packages, type: :production, exact: false)
|
|
49
|
+
raise_exited_with_non_zero_code_error unless add(packages, type: type, exact: exact)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
# Removes the given packages
|
|
@@ -16,8 +16,9 @@ class PackageJson
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Adds the given packages
|
|
19
|
-
def add(packages, type: :production)
|
|
20
|
-
|
|
19
|
+
def add(packages, type: :production, exact: false)
|
|
20
|
+
flags = [package_type_install_flag(type), exact_flag(exact)].compact
|
|
21
|
+
raw("add", flags + packages)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
# Removes the given packages
|
|
@@ -62,6 +63,12 @@ class PackageJson
|
|
|
62
63
|
[]
|
|
63
64
|
end
|
|
64
65
|
|
|
66
|
+
def exact_flag(exact)
|
|
67
|
+
return "--exact" if exact
|
|
68
|
+
|
|
69
|
+
nil
|
|
70
|
+
end
|
|
71
|
+
|
|
65
72
|
def package_type_install_flag(type)
|
|
66
73
|
case type
|
|
67
74
|
when :production
|
|
@@ -22,8 +22,9 @@ class PackageJson
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
# Adds the given packages
|
|
25
|
-
def add(packages, type: :production)
|
|
26
|
-
|
|
25
|
+
def add(packages, type: :production, exact: false)
|
|
26
|
+
flags = [package_type_install_flag(type), exact_flag(exact)].compact
|
|
27
|
+
raw("install", flags + packages)
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
# Removes the given packages
|
|
@@ -66,6 +67,12 @@ class PackageJson
|
|
|
66
67
|
args
|
|
67
68
|
end
|
|
68
69
|
|
|
70
|
+
def exact_flag(exact)
|
|
71
|
+
return "--save-exact" if exact
|
|
72
|
+
|
|
73
|
+
nil
|
|
74
|
+
end
|
|
75
|
+
|
|
69
76
|
def package_type_install_flag(type)
|
|
70
77
|
case type
|
|
71
78
|
when :production
|
|
@@ -16,8 +16,9 @@ class PackageJson
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Adds the given packages
|
|
19
|
-
def add(packages, type: :production)
|
|
20
|
-
|
|
19
|
+
def add(packages, type: :production, exact: false)
|
|
20
|
+
flags = [package_type_install_flag(type), exact_flag(exact)].compact
|
|
21
|
+
raw("add", flags + packages)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
# Removes the given packages
|
|
@@ -67,6 +68,12 @@ class PackageJson
|
|
|
67
68
|
["--no-frozen-lockfile"]
|
|
68
69
|
end
|
|
69
70
|
|
|
71
|
+
def exact_flag(exact)
|
|
72
|
+
return "--save-exact" if exact
|
|
73
|
+
|
|
74
|
+
nil
|
|
75
|
+
end
|
|
76
|
+
|
|
70
77
|
def package_type_install_flag(type)
|
|
71
78
|
case type
|
|
72
79
|
when :production
|
|
@@ -16,8 +16,9 @@ class PackageJson
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Adds the given packages
|
|
19
|
-
def add(packages, type: :production)
|
|
20
|
-
|
|
19
|
+
def add(packages, type: :production, exact: false)
|
|
20
|
+
flags = [package_type_install_flag(type), exact_flag(exact)].compact
|
|
21
|
+
raw("add", flags + packages)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
# Removes the given packages
|
|
@@ -64,6 +65,12 @@ class PackageJson
|
|
|
64
65
|
["--no-immutable"]
|
|
65
66
|
end
|
|
66
67
|
|
|
68
|
+
def exact_flag(exact)
|
|
69
|
+
return "--exact" if exact
|
|
70
|
+
|
|
71
|
+
nil
|
|
72
|
+
end
|
|
73
|
+
|
|
67
74
|
def package_type_install_flag(type)
|
|
68
75
|
case type
|
|
69
76
|
when :production
|
|
@@ -16,8 +16,9 @@ class PackageJson
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Adds the given packages
|
|
19
|
-
def add(packages, type: :production)
|
|
20
|
-
|
|
19
|
+
def add(packages, type: :production, exact: false)
|
|
20
|
+
flags = [package_type_install_flag(type), exact_flag(exact)].compact
|
|
21
|
+
raw("add", flags + packages)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
# Removes the given packages
|
|
@@ -79,6 +80,12 @@ class PackageJson
|
|
|
79
80
|
[]
|
|
80
81
|
end
|
|
81
82
|
|
|
83
|
+
def exact_flag(exact)
|
|
84
|
+
return "--exact" if exact
|
|
85
|
+
|
|
86
|
+
nil
|
|
87
|
+
end
|
|
88
|
+
|
|
82
89
|
def package_type_install_flag(type)
|
|
83
90
|
case type
|
|
84
91
|
when :production
|
data/lib/package_json/version.rb
CHANGED
|
@@ -13,9 +13,9 @@ class PackageJson
|
|
|
13
13
|
|
|
14
14
|
def native_install_command: (?frozen: bool) -> Array[String]
|
|
15
15
|
|
|
16
|
-
def add: (Array[String] packages, ?type: :production | :dev | :optional) -> (bool | nil)
|
|
16
|
+
def add: (Array[String] packages, ?type: :production | :dev | :optional, ?exact: bool) -> (bool | nil)
|
|
17
17
|
|
|
18
|
-
def add!: (Array[String] packages, ?type: :production | :dev | :optional) -> void
|
|
18
|
+
def add!: (Array[String] packages, ?type: :production | :dev | :optional, ?exact: bool) -> void
|
|
19
19
|
|
|
20
20
|
def remove: (Array[String] packages) -> (bool | nil)
|
|
21
21
|
|
data/sig/package_json.rbs
CHANGED
|
@@ -12,14 +12,18 @@ class PackageJson
|
|
|
12
12
|
|
|
13
13
|
def self.fetch_default_fallback_manager: () -> Symbol
|
|
14
14
|
|
|
15
|
-
def self.read: (?String path_to_directory, ?
|
|
15
|
+
def self.read: (?String path_to_directory, ?fallback_manager: (:npm | :yarn_berry | :yarn_classic | :pnpm | :bun)) -> PackageJson
|
|
16
16
|
|
|
17
|
-
def initialize: (?String path_to_directory, ?
|
|
17
|
+
def initialize: (?String path_to_directory, ?fallback_manager: (:npm | :yarn_berry | :yarn_classic | :pnpm | :bun)) -> PackageJson
|
|
18
18
|
|
|
19
19
|
def fetch: (String key, ?untyped default) -> (String | Hash[String, untyped] | Array[untyped])
|
|
20
20
|
|
|
21
21
|
def merge!: () { (Hash[String | Symbol, untyped]) -> Hash[String | Symbol, untyped] } -> void
|
|
22
22
|
|
|
23
|
+
def delete!: (String key) -> untyped
|
|
24
|
+
|
|
25
|
+
def record_package_manager!: () -> void
|
|
26
|
+
|
|
23
27
|
private
|
|
24
28
|
|
|
25
29
|
@directory: String
|
|
@@ -30,9 +34,9 @@ class PackageJson
|
|
|
30
34
|
|
|
31
35
|
def package_json_path: () -> String
|
|
32
36
|
|
|
33
|
-
def ensure_package_json_exists: (
|
|
37
|
+
def ensure_package_json_exists: () -> bool
|
|
34
38
|
|
|
35
|
-
def read_package_json: () ->
|
|
39
|
+
def read_package_json: () -> Hash[String, untyped]
|
|
36
40
|
|
|
37
41
|
def write_package_json: (_ToJson contents) -> void
|
|
38
42
|
end
|
metadata
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: package_json
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gareth Jones
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
|
-
description:
|
|
14
12
|
email:
|
|
15
13
|
- open-source@ackama.com
|
|
16
14
|
executables: []
|
|
@@ -56,7 +54,6 @@ metadata:
|
|
|
56
54
|
source_code_uri: https://github.com/shakacode/package_json
|
|
57
55
|
changelog_uri: https://github.com/shakacode/package_json/blob/main/CHANGELOG.md
|
|
58
56
|
rubygems_mfa_required: 'true'
|
|
59
|
-
post_install_message:
|
|
60
57
|
rdoc_options: []
|
|
61
58
|
require_paths:
|
|
62
59
|
- lib
|
|
@@ -71,8 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
71
68
|
- !ruby/object:Gem::Version
|
|
72
69
|
version: '0'
|
|
73
70
|
requirements: []
|
|
74
|
-
rubygems_version: 3.
|
|
75
|
-
signing_key:
|
|
71
|
+
rubygems_version: 3.6.9
|
|
76
72
|
specification_version: 4
|
|
77
73
|
summary: The missing gem for managing package.json files in Ruby
|
|
78
74
|
test_files: []
|