|
|
69a90f |
From e720c04efdce3ec8dd8e726db22d5eebb47cb016 Mon Sep 17 00:00:00 2001
|
|
|
69a90f |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
69a90f |
Date: Fri, 2 Sep 2016 11:57:16 +0200
|
|
|
69a90f |
Subject: [PATCH 1/2] [nodejs] new plugin: get runtime info
|
|
|
69a90f |
|
|
|
69a90f |
Resolves: #847.
|
|
|
69a90f |
|
|
|
69a90f |
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
|
|
|
69a90f |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
69a90f |
---
|
|
|
69a90f |
sos/plugins/nodejs.py | 43 +++++++++++++++++++++++++++++++++++++++++++
|
|
|
69a90f |
1 file changed, 43 insertions(+)
|
|
|
69a90f |
create mode 100644 sos/plugins/nodejs.py
|
|
|
69a90f |
|
|
|
69a90f |
diff --git a/sos/plugins/nodejs.py b/sos/plugins/nodejs.py
|
|
|
69a90f |
new file mode 100644
|
|
|
69a90f |
index 0000000..3585ec9
|
|
|
69a90f |
--- /dev/null
|
|
|
69a90f |
+++ b/sos/plugins/nodejs.py
|
|
|
69a90f |
@@ -0,0 +1,43 @@
|
|
|
69a90f |
+# Copyright (C) 2016 Red Hat, Inc., Tomas Tomecek <ttomecek@redhat.com>
|
|
|
69a90f |
+
|
|
|
69a90f |
+# This program is free software; you can redistribute it and/or modify
|
|
|
69a90f |
+# it under the terms of the GNU General Public License as published by
|
|
|
69a90f |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
69a90f |
+# (at your option) any later version.
|
|
|
69a90f |
+
|
|
|
69a90f |
+# This program is distributed in the hope that it will be useful,
|
|
|
69a90f |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
69a90f |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
69a90f |
+# GNU General Public License for more details.
|
|
|
69a90f |
+
|
|
|
69a90f |
+# You should have received a copy of the GNU General Public License
|
|
|
69a90f |
+# along with this program; if not, write to the Free Software
|
|
|
69a90f |
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
69a90f |
+
|
|
|
69a90f |
+from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, \
|
|
|
69a90f |
+ SuSEPlugin
|
|
|
69a90f |
+
|
|
|
69a90f |
+
|
|
|
69a90f |
+class NodeJS(Plugin, RedHatPlugin, SuSEPlugin):
|
|
|
69a90f |
+ """ Get runtime version of NodeJS """
|
|
|
69a90f |
+
|
|
|
69a90f |
+ plugin_name = 'nodejs'
|
|
|
69a90f |
+ profiles = ('system',)
|
|
|
69a90f |
+
|
|
|
69a90f |
+ packages = ('nodejs',)
|
|
|
69a90f |
+
|
|
|
69a90f |
+ def setup(self):
|
|
|
69a90f |
+ # we could get much more info with:
|
|
|
69a90f |
+ # p = require("process"); console.log(p)
|
|
|
69a90f |
+ # unfortunately 'process' module is not available on 0.10
|
|
|
69a90f |
+ self.add_cmd_output("node -v", suggest_filename="nodejs-version")
|
|
|
69a90f |
+
|
|
|
69a90f |
+
|
|
|
69a90f |
+class NodeJSUbuntu(NodeJS, UbuntuPlugin, DebianPlugin):
|
|
|
69a90f |
+ """
|
|
|
69a90f |
+ Ubuntu/Debian require nodejs-legacy package in order to
|
|
|
69a90f |
+ have a node executable
|
|
|
69a90f |
+ """
|
|
|
69a90f |
+ packages = ('nodejs', 'nodejs-legacy')
|
|
|
69a90f |
+
|
|
|
69a90f |
+# vim: set et ts=4 sw=4 :
|
|
|
69a90f |
--
|
|
|
69a90f |
2.4.11
|
|
|
69a90f |
|
|
|
69a90f |
From 470f62c658b37e1691cb87472a15880e9e4596a2 Mon Sep 17 00:00:00 2001
|
|
|
69a90f |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
69a90f |
Date: Fri, 2 Sep 2016 11:59:04 +0200
|
|
|
69a90f |
Subject: [PATCH 2/2] [npm] new plugin: get project modules and globally
|
|
|
69a90f |
installed modules
|
|
|
69a90f |
|
|
|
69a90f |
New module for package manager npm for Node.js.
|
|
|
69a90f |
|
|
|
69a90f |
The plugin collects list of globally installed modules and project modules.
|
|
|
69a90f |
|
|
|
69a90f |
Resolves: #846.
|
|
|
69a90f |
|
|
|
69a90f |
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
|
|
|
69a90f |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
69a90f |
---
|
|
|
69a90f |
sos/plugins/npm.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
69a90f |
1 file changed, 68 insertions(+)
|
|
|
69a90f |
create mode 100644 sos/plugins/npm.py
|
|
|
69a90f |
|
|
|
69a90f |
diff --git a/sos/plugins/npm.py b/sos/plugins/npm.py
|
|
|
69a90f |
new file mode 100644
|
|
|
69a90f |
index 0000000..77464c2
|
|
|
69a90f |
--- /dev/null
|
|
|
69a90f |
+++ b/sos/plugins/npm.py
|
|
|
69a90f |
@@ -0,0 +1,68 @@
|
|
|
69a90f |
+# Copyright (C) 2016 Red Hat, Inc., Tomas Tomecek <ttomecek@redhat>
|
|
|
69a90f |
+
|
|
|
69a90f |
+# This program is free software; you can redistribute it and/or modify
|
|
|
69a90f |
+# it under the terms of the GNU General Public License as published by
|
|
|
69a90f |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
69a90f |
+# (at your option) any later version.
|
|
|
69a90f |
+
|
|
|
69a90f |
+# This program is distributed in the hope that it will be useful,
|
|
|
69a90f |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
69a90f |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
69a90f |
+# GNU General Public License for more details.
|
|
|
69a90f |
+
|
|
|
69a90f |
+# You should have received a copy of the GNU General Public License
|
|
|
69a90f |
+# along with this program; if not, write to the Free Software
|
|
|
69a90f |
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
69a90f |
+import os
|
|
|
69a90f |
+
|
|
|
69a90f |
+from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, \
|
|
|
69a90f |
+ SuSEPlugin
|
|
|
69a90f |
+
|
|
|
69a90f |
+
|
|
|
69a90f |
+class Npm(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, SuSEPlugin):
|
|
|
69a90f |
+ """
|
|
|
69a90f |
+ Get info about available npm modules
|
|
|
69a90f |
+ """
|
|
|
69a90f |
+
|
|
|
69a90f |
+ requires_root = False
|
|
|
69a90f |
+ plugin_name = 'npm'
|
|
|
69a90f |
+ profiles = ('system',)
|
|
|
69a90f |
+ option_list = [("project_path",
|
|
|
69a90f |
+ 'List npm modules of a project specified by path',
|
|
|
69a90f |
+ 'fast',
|
|
|
69a90f |
+ 0)]
|
|
|
69a90f |
+
|
|
|
69a90f |
+ # in Fedora, Debian, Ubuntu and Suse the package is called npm
|
|
|
69a90f |
+ packages = ('npm',)
|
|
|
69a90f |
+
|
|
|
69a90f |
+ def _get_npm_output(self, cmd, filename, working_directory=None):
|
|
|
69a90f |
+ # stderr output is already part of the json, key "problems"
|
|
|
69a90f |
+ self.add_cmd_output(
|
|
|
69a90f |
+ cmd,
|
|
|
69a90f |
+ suggest_filename=filename,
|
|
|
69a90f |
+ stderr=False,
|
|
|
69a90f |
+ runat=working_directory
|
|
|
69a90f |
+ )
|
|
|
69a90f |
+
|
|
|
69a90f |
+ def setup(self):
|
|
|
69a90f |
+ if self.get_option("project_path") != 0:
|
|
|
69a90f |
+ project_path = os.path.abspath(os.path.expanduser(
|
|
|
69a90f |
+ self.get_option("project_path")))
|
|
|
69a90f |
+ self._get_npm_output("npm ls --json", "npm-ls-project",
|
|
|
69a90f |
+ working_directory=project_path)
|
|
|
69a90f |
+ self._get_npm_output("npm ls -g --json", "npm-ls-global")
|
|
|
69a90f |
+
|
|
|
69a90f |
+
|
|
|
69a90f |
+class NpmViaNodeJS(Npm):
|
|
|
69a90f |
+ """
|
|
|
69a90f |
+ some distribution methods don't provide 'npm' via npm package
|
|
|
69a90f |
+ """
|
|
|
69a90f |
+
|
|
|
69a90f |
+ # upstream doesn't have an npm package, it's just nodejs
|
|
|
69a90f |
+ # also in Fedora 24+ it is just nodejs, no npm package
|
|
|
69a90f |
+ packages = ('nodejs', )
|
|
|
69a90f |
+
|
|
|
69a90f |
+# TODO: in RHEL npm and nodejs is available via software collections
|
|
|
69a90f |
+# this should be handled separately
|
|
|
69a90f |
+
|
|
|
69a90f |
+# vim: set et ts=4 sw=4 :
|
|
|
69a90f |
--
|
|
|
69a90f |
2.4.11
|
|
|
69a90f |
|