fastlane-plugin-npm 0.3.1 → 0.4.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/README.md +43 -8
- data/lib/fastlane/plugin/npm/actions/npm_install_action.rb +5 -1
- data/lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb +66 -0
- data/lib/fastlane/plugin/npm/helper/npm_helper.rb +15 -5
- data/lib/fastlane/plugin/npm/version.rb +2 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7dfd78f976bdccb3f211411f1f2a4fd1a0a7164fa16df9d08c345827bfd8657
|
4
|
+
data.tar.gz: 2963aaa3f6614d7519bf7a87fb943b93364e889d22215ad1f9757206cad92907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 509914010d6058f61803e8f970fe85c991bdb634a9d04f5e92fc69773144df3fe87b5bb44b47457c3d4de1fa781e23eb22f6818cae9a744f6f84582aa9cb4409
|
7
|
+
data.tar.gz: 479ec44e3309fc5df03ccc27f6ccd3299f69bb089e35c7c6ae2f29cb6866e18e966cb1a0656e9a0dad087fe3b0367a6d1fb514d52db6b9fe0075d968e4a0f1f3
|
data/README.md
CHANGED
@@ -22,22 +22,57 @@ A very simple plugin to run npm scripts
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
##
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
## Actions
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
lane :test do
|
29
|
+
npm_install(
|
30
|
+
fresh: true, # [Optional] Boolean: Defines if modules should be fresh instaled. Deletes node_modules folder (Default: false)
|
31
|
+
arguments: [], # [Optional] Array: List of arguments
|
32
|
+
step_name: 'Starting with reset cache' # [Optional] String: Text that will be printed into the console
|
33
|
+
)
|
34
|
+
|
35
|
+
npm_post_install(
|
36
|
+
arguments: [], # [Optional] Array: List of arguments
|
37
|
+
step_name: 'Starting with reset cache' # [Optional] String: Text that will be printed into the console
|
38
|
+
)
|
39
|
+
|
40
|
+
npm_lint(
|
41
|
+
script: 'lint', # [Optional] String: Overrides default lint script name (Default: lint)
|
42
|
+
fix: true, # [Optional] Boolean: Adds a --fix flag (Default: false)
|
43
|
+
arguments: [], # [Optional] Array: List of arguments
|
44
|
+
step_name: 'Starting with reset cache' # [Optional] String: Text that will be printed into the console
|
45
|
+
)
|
46
|
+
|
47
|
+
npm_test(
|
48
|
+
script: 'test', # [Optional] String: Overrides default test script name (Default: test)
|
49
|
+
coverage: true, # [Optional] Boolean: Adds a --coverage flag (Default: false)
|
50
|
+
arguments: [], # [Optional] Array: List of arguments
|
51
|
+
step_name: 'Starting with reset cache' # [Optional] String: Text that will be printed into the console
|
52
|
+
)
|
53
|
+
|
54
|
+
npm_run(
|
55
|
+
script: 'start', # [Required] String: Script to run
|
56
|
+
arguments: ['--reset-cache'], # [Optional] Array: List of arguments
|
57
|
+
step_name: 'Starting with reset cache' # [Optional] String: Text that will be printed into the console
|
58
|
+
)
|
59
|
+
|
60
|
+
upgrade_package_json_version(
|
61
|
+
new_version: "1.5.0", # [Required] String: Version to set
|
62
|
+
version_match: "(\d+\.\d+\.\d+)" # [Optional] String: Regex as a string to match the version in the package.json (Default: "(\d+\.\d+\.\d+)")
|
63
|
+
)
|
64
|
+
end
|
65
|
+
```
|
31
66
|
## Run tests for this plugin
|
32
67
|
|
33
68
|
To run both the tests, and code style validation, run
|
34
69
|
|
35
|
-
```
|
70
|
+
```bash
|
36
71
|
rake
|
37
72
|
```
|
38
73
|
|
39
74
|
To automatically fix many of the styling issues, use
|
40
|
-
```
|
75
|
+
```bash
|
41
76
|
rubocop -a
|
42
77
|
```
|
43
78
|
|
@@ -8,7 +8,11 @@ module Fastlane
|
|
8
8
|
# rm may exit with non zero in the case where there is no node_modules and that's what we want anyway
|
9
9
|
if params[:fresh]
|
10
10
|
UI.important('Deleting node modules and installing packages')
|
11
|
-
|
11
|
+
|
12
|
+
root_dir = Helper::NpmHelper.find_root_dir
|
13
|
+
node_module_dir = File.join(root_dir, 'node_modules')
|
14
|
+
|
15
|
+
FastlaneCore::CommandExecutor.execute(command: "rm -rf \"#{node_module_dir}\" 2> /dev/null",
|
12
16
|
print_command: FastlaneCore::Globals.verbose?,
|
13
17
|
print_all: FastlaneCore::Globals.verbose?)
|
14
18
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/npm_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class UpgradePackageJsonVersionAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
UI.message "Changing package.json version to #{params[:new_version]}"
|
9
|
+
root_dir = Helper::NpmHelper.find_root_dir
|
10
|
+
|
11
|
+
UI.user_error! "apparently it's not running inside a node project. package.json cannot be found" unless root_dir
|
12
|
+
|
13
|
+
package_json_path = File.join(root_dir, 'package.json')
|
14
|
+
|
15
|
+
regex = Regexp.new("\"version\": \"#{params[:version_match]}\"")
|
16
|
+
|
17
|
+
Helper::NpmHelper.update_file_content(
|
18
|
+
file_name: package_json_path,
|
19
|
+
search: regex,
|
20
|
+
replace: "\"version\": \"#{params[:new_version]}\""
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.description
|
25
|
+
"A very simple plugin to run npm scripts"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.authors
|
29
|
+
["Erick Martins"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.return_value
|
33
|
+
# If your method provides a return value, you can describe here what it does
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.details
|
37
|
+
# Optional:
|
38
|
+
"A very simple plugin to run npm scripts"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.available_options
|
42
|
+
[
|
43
|
+
FastlaneCore::ConfigItem.new(key: :new_version,
|
44
|
+
default_value: "Installing dependencies",
|
45
|
+
description: "Name for this step",
|
46
|
+
optional: true,
|
47
|
+
type: String),
|
48
|
+
|
49
|
+
FastlaneCore::ConfigItem.new(key: :version_match,
|
50
|
+
default_value: '(\d+\.\d+\.\d+)',
|
51
|
+
description: "Regex to match the version",
|
52
|
+
optional: true,
|
53
|
+
type: String),
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.is_supported?(platform)
|
58
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
59
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
60
|
+
#
|
61
|
+
# [:ios, :mac, :android].include?(platform)
|
62
|
+
true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -5,12 +5,22 @@ module Fastlane
|
|
5
5
|
|
6
6
|
module Helper
|
7
7
|
class NpmHelper
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def self.find_root_dir(dir = Dir.pwd)
|
9
|
+
return dir if File.file?(File.join(dir, 'package.json'))
|
10
|
+
|
11
|
+
parent_dir = File.expand_path("..", dir)
|
12
|
+
return nil unless parent_dir != '/'
|
13
|
+
|
14
|
+
find_root_dir parent_dir
|
13
15
|
end
|
16
|
+
|
17
|
+
def self.update_file_content(file_name:, search:, replace:)
|
18
|
+
text = File.read(file_name)
|
19
|
+
new_contents = text.gsub(search, replace)
|
20
|
+
|
21
|
+
# To write changes to the file, use:
|
22
|
+
File.open(file_name, "w") {|file| file.puts new_contents }
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-npm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erick Martins
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/fastlane/plugin/npm/actions/npm_post_install_action.rb
|
151
151
|
- lib/fastlane/plugin/npm/actions/npm_run_action.rb
|
152
152
|
- lib/fastlane/plugin/npm/actions/npm_test_action.rb
|
153
|
+
- lib/fastlane/plugin/npm/actions/upgrade_package_json_version_action.rb
|
153
154
|
- lib/fastlane/plugin/npm/helper/npm_helper.rb
|
154
155
|
- lib/fastlane/plugin/npm/version.rb
|
155
156
|
homepage: https://github.com/erick-martins/fastlane-plugin-npm
|