diff --git a/.gitignore b/.gitignore index 885dafa..448207b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ *~ *.retry node_modules/ -build/ \ No newline at end of file +dist/ +/.vagrant +lib/ +testlib/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6096fea --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +all: + npm run build + +clean: + rm -rf dist/ + rm -rf _install + +install: all + mkdir -p /usr/share/cockpit + cp -r dist/ /usr/share/cockpit/subscription-manager + +srpm: clean all + mkdir -p _install/usr/share/cockpit + cp -r dist/ _install/usr/share/cockpit/subscription-manager + mkdir -p _install/usr/share/metainfo/ + cp *.metainfo.xml _install/usr/share/metainfo/ + tar -C _install/ -czf subscription-manager-cockpit.tar.gz . + rpmbuild -bs \ + --define "_sourcedir `pwd`" \ + --define "_srcrpmdir `pwd`" \ + subscription-manager-cockpit.spec diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..c736b9a --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,30 @@ +Vagrant.configure(2) do |config| + config.vm.box = "fedora/25-cloud-base" + config.vm.network "forwarded_port", guest: 9090, host: 9090 + + if Dir.glob("dist/*").length == 0 + config.vm.post_up_message = "NOTE: Distribution directory is empty. Run `make` to see your module show up in cockpit" + end + + config.vm.synced_folder ".", "/vagrant", disabled: true + config.vm.synced_folder "dist/", "/usr/local/share/cockpit/" + File.basename(Dir.pwd), create: true + + config.vm.provider "libvirt" do |libvirt| + libvirt.memory = 1024 + end + + config.vm.provider "virtualbox" do |virtualbox| + virtualbox.memory = 1024 + end + + config.vm.provision "shell", inline: <<-EOF + set -eu + + sudo dnf install -y cockpit + + printf "[WebService]\nAllowUnencrypted=true\n" > /etc/cockpit/cockpit.conf + + systemctl enable cockpit.socket + systemctl start cockpit.socket + EOF +end diff --git a/org.cockpit-project.subscription-manager.metainfo.xml b/org.cockpit-project.subscription-manager.metainfo.xml new file mode 100644 index 0000000..bee58e1 --- /dev/null +++ b/org.cockpit-project.subscription-manager.metainfo.xml @@ -0,0 +1,15 @@ + + org.cockpit-project.subscription-manager + CC0-1.0 + Subscription Manager + + Subscription Manager in Cockpit + + +

+ Manage subscriptions to a Candlepin backend, such as for Red Hat products. +

+
+ cockpit.desktop + subscription-manager-cockpit +
diff --git a/package.json b/package.json index b2467f5..55571a7 100644 --- a/package.json +++ b/package.json @@ -7,17 +7,31 @@ "author": "", "license": "LGPL-2.1", "scripts": { - "build": "webpack" + "build": "webpack", + "flow-tests": "babel tests/ -d testlib/", + "flow-src": "babel src/ -d lib/" }, "devDependencies": { + "babel-cli": "^6.24.1", "babel-core": "^6.25.0", "babel-loader": "^7.0.0", "babel-plugin-transform-react-jsx": "^6.24.1", "babel-preset-env": "^1.5.2", + "babel-preset-flow": "^6.23.0", + "copy-webpack-plugin": "~3.0.1", + "enzyme": "^2.9.1", + "eslint": "^3.0.0", + "eslint-loader": "~1.6.1", + "eslint-plugin-react": "~6.9.0", + "flow-bin": "^0.49.1", + "jshint": "~2.9.1", + "jshint-loader": "~0.8.3", + "react-test-renderer": "^15.6.1", + "tape": "^4.7.0", "webpack": "^2.6.1" }, "dependencies": { - "react": "^15.6.0", - "react-dom": "^15.6.0" + "react": "^15.6.1", + "react-dom": "^15.6.1" } } diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..dda2c18 --- /dev/null +++ b/src/index.html @@ -0,0 +1,38 @@ + + + + + Subscriptions + + + + + + + + + + + + + +
+ + diff --git a/src/index.js b/src/index.js index e69de29..7bdd5b0 100644 --- a/src/index.js +++ b/src/index.js @@ -0,0 +1,24 @@ +/* + * This file is part of Cockpit. + * + * Copyright (C) 2017 Red Hat, Inc. + * + * Cockpit is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * Cockpit is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with subscription-manager; If not, see . + */ + +var cockpit = require("cockpit"); + +document.addEventListener("DOMContentLoaded", function() { + console.log("subscription-manager loaded"); +}); diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..82c04d9 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,12 @@ +{ + "version": "0.1", + "requires": { + "cockpit": "137" + }, + + "tools": { + "index": { + "label": "subscription-manager" + } + } +} diff --git a/subscription-manager-cockpit.spec b/subscription-manager-cockpit.spec new file mode 100644 index 0000000..0fb6b78 --- /dev/null +++ b/subscription-manager-cockpit.spec @@ -0,0 +1,27 @@ +Name: subscription-manager-cockpit +Version: 1 +Release: 0 +Summary: Subscription Manager Cockpit UI +License: LGPLv2.1+ + +Source: subscription-manager-cockpit.tar.gz +BuildArch: noarch + +Requires: subscription-manager + +%define debug_package %{nil} + +%description +Subscription Manager Cockpit UI + +%prep + +%build + +%install +mkdir -p %{buildroot} +tar --strip-components=1 -xzf %{sources} -C %{buildroot} +find %{buildroot} -type f >> files.list +sed -i "s|%{buildroot}||" *.list + +%files -f files.list diff --git a/webpack.config.js b/webpack.config.js index d862669..0365de9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,18 +1,119 @@ const path = require("path"); +const copy = require("copy-webpack-plugin"); +const fs = require("fs"); + +var externals = { + "cockpit": "cockpit", +}; + +/* These can be overridden, typically from the Makefile.am */ +const srcdir = (process.env.SRCDIR || __dirname) + path.sep + "src"; +const builddir = (process.env.SRCDIR || __dirname); +const distdir = builddir + path.sep + "dist"; +const section = process.env.ONLYDIR || null; + +var info = { + entries: { + "index": [ + "./index.js" + ] + }, + files: [ + "index.html", + "manifest.json", + ], +}; + +var output = { + path: distdir, + filename: "[name].js", + sourceMapFilename: "[file].map", +}; + +/* + * Note that we're avoiding the use of path.join as webpack and nodejs + * want relative paths that start with ./ explicitly. + * + * In addition we mimic the VPATH style functionality of GNU Makefile + * where we first check builddir, and then srcdir. + */ + +function vpath(/* ... */) { + var filename = Array.prototype.join.call(arguments, path.sep); + var expanded = builddir + path.sep + filename; + if (fs.existsSync(expanded)) + return expanded; + expanded = srcdir + path.sep + filename; + return expanded; +} + +/* Qualify all the paths in entries */ +Object.keys(info.entries).forEach(function(key) { + if (section && key.indexOf(section) !== 0) { + delete info.entries[key]; + return; + } + + info.entries[key] = info.entries[key].map(function(value) { + if (value.indexOf("/") === -1) + return value; + else + return vpath(value); + }); +}); + +/* Qualify all the paths in files listed */ +var files = []; +info.files.forEach(function(value) { + if (!section || value.indexOf(section) === 0) + files.push({ from: vpath("src", value), to: value }); +}); +info.files = files; + +var plugins = [ + new copy(info.files) +]; module.exports = { - entry: ["./src/index.js"], - output: { - filename: "bundle.js", - path: path.resolve(__dirname, "build") - }, + entry: info.entries, + externals: externals, + output: output, module: { rules: [ { - exclude: /node_modules/, - loader: 'babel-loader', - test: /\.js$/ + enforce: 'pre', + exclude: /node_modules/, + loader: 'jshint-loader', + test: /\.js$/ + }, + { + enforce: 'pre', + exclude: /node_modules/, + loader: 'eslint-loader', + test: /\.jsx$/ + }, + { + enforce: 'pre', + exclude: /node_modules/, + loader: 'jshint-loader?esversion=6', + test: /\.es6$/ + }, + { + exclude: /node_modules/, + loader: 'babel-loader', + test: /\.js$/ + }, + { + exclude: /node_modules/, + loader: 'babel-loader', + test: /\.jsx$/ + }, + { + exclude: /node_modules/, + loader: 'babel-loader', + test: /\.es6$/ } ] - } + }, + plugins: plugins }