fastlane-plugin-npm 0.2.0 → 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 +55 -6
- data/lib/fastlane/plugin/npm/actions/npm_install_action.rb +13 -13
- data/lib/fastlane/plugin/npm/actions/npm_lint_action.rb +12 -2
- data/lib/fastlane/plugin/npm/actions/npm_run_action.rb +3 -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
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/fastlane-plugin-npm)
|
4
4
|
|
5
|
+
|
6
|
+
|
5
7
|
## Getting Started
|
6
8
|
|
7
9
|
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-npm`, add it to your project by running:
|
@@ -10,43 +12,90 @@ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To
|
|
10
12
|
fastlane add_plugin npm
|
11
13
|
```
|
12
14
|
|
15
|
+
|
16
|
+
|
13
17
|
## About npm
|
14
18
|
|
15
19
|
A very simple plugin to run npm scripts
|
16
20
|
|
17
21
|
**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
|
18
22
|
|
19
|
-
## Example
|
20
|
-
|
21
|
-
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
22
23
|
|
23
|
-
**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
|
24
24
|
|
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
|
+
```
|
25
66
|
## Run tests for this plugin
|
26
67
|
|
27
68
|
To run both the tests, and code style validation, run
|
28
69
|
|
29
|
-
```
|
70
|
+
```bash
|
30
71
|
rake
|
31
72
|
```
|
32
73
|
|
33
74
|
To automatically fix many of the styling issues, use
|
34
|
-
```
|
75
|
+
```bash
|
35
76
|
rubocop -a
|
36
77
|
```
|
37
78
|
|
79
|
+
|
80
|
+
|
38
81
|
## Issues and Feedback
|
39
82
|
|
40
83
|
For any other issues and feedback about this plugin, please submit it to this repository.
|
41
84
|
|
85
|
+
|
86
|
+
|
42
87
|
## Troubleshooting
|
43
88
|
|
44
89
|
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
45
90
|
|
91
|
+
|
92
|
+
|
46
93
|
## Using _fastlane_ Plugins
|
47
94
|
|
48
95
|
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
49
96
|
|
97
|
+
|
98
|
+
|
50
99
|
## About _fastlane_
|
51
100
|
|
52
101
|
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -6,17 +6,23 @@ module Fastlane
|
|
6
6
|
class NpmInstallAction < Action
|
7
7
|
def self.run(params)
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if params[:fresh]
|
10
|
+
UI.important('Deleting node modules and installing packages')
|
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",
|
16
|
+
print_command: FastlaneCore::Globals.verbose?,
|
17
|
+
print_all: FastlaneCore::Globals.verbose?)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
13
21
|
other_action.npm_run(
|
14
22
|
script: 'install',
|
15
23
|
step_name: params[:step_name],
|
16
24
|
arguments: params[:arguments]
|
17
25
|
)
|
18
|
-
|
19
|
-
other_action.npm_post_install if params[:post_install_after]
|
20
26
|
end
|
21
27
|
|
22
28
|
def self.description
|
@@ -44,7 +50,7 @@ module Fastlane
|
|
44
50
|
optional: true,
|
45
51
|
type: String),
|
46
52
|
|
47
|
-
FastlaneCore::ConfigItem.new(key: :
|
53
|
+
FastlaneCore::ConfigItem.new(key: :fresh,
|
48
54
|
default_value: false,
|
49
55
|
description: "Deletes node_modules folder",
|
50
56
|
optional: true,
|
@@ -55,12 +61,6 @@ module Fastlane
|
|
55
61
|
description: "Script arguments",
|
56
62
|
optional: true,
|
57
63
|
type: Array),
|
58
|
-
|
59
|
-
FastlaneCore::ConfigItem.new(key: :post_install_after,
|
60
|
-
default_value: false,
|
61
|
-
description: "Run postinstall script right after",
|
62
|
-
optional: true,
|
63
|
-
type: Boolean),
|
64
64
|
]
|
65
65
|
end
|
66
66
|
|
@@ -5,15 +5,19 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class NpmLintAction < Action
|
7
7
|
def self.run(params)
|
8
|
+
arguments = []
|
9
|
+
arguments = ['--fix'] if params[:fix]
|
10
|
+
arguments.concat params[:arguments]
|
11
|
+
|
8
12
|
other_action.npm_run(
|
9
13
|
script: 'lint',
|
10
14
|
step_name: params[:step_name],
|
11
|
-
arguments:
|
15
|
+
arguments: arguments
|
12
16
|
)
|
13
17
|
end
|
14
18
|
|
15
19
|
def self.description
|
16
|
-
"
|
20
|
+
"Runs lint script"
|
17
21
|
end
|
18
22
|
|
19
23
|
def self.authors
|
@@ -37,6 +41,12 @@ module Fastlane
|
|
37
41
|
optional: true,
|
38
42
|
type: String),
|
39
43
|
|
44
|
+
FastlaneCore::ConfigItem.new(key: :fix,
|
45
|
+
default_value: false,
|
46
|
+
description: "Run postinstall script right after",
|
47
|
+
optional: true,
|
48
|
+
type: Boolean),
|
49
|
+
|
40
50
|
FastlaneCore::ConfigItem.new(key: :arguments,
|
41
51
|
default_value: [],
|
42
52
|
description: "Script arguments",
|
@@ -5,8 +5,10 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class NpmRunAction < Action
|
7
7
|
def self.run(params)
|
8
|
+
UI.message(params[:step_name])
|
9
|
+
|
8
10
|
command = ['npm', 'run', params[:script]]
|
9
|
-
command = ['npm', params[:script]] if ['install', 'test'].include? params[:script]
|
11
|
+
command = ['npm', params[:script]] if ['install', 'test', 'start'].include? params[:script]
|
10
12
|
|
11
13
|
command.concat params[:arguments]
|
12
14
|
|
@@ -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
|