From 46ad9834b3d51d18966bd1caac837ef87aa52580 Mon Sep 17 00:00:00 2001 From: Benjamin Graham Date: Thu, 23 Jul 2020 22:06:42 -0400 Subject: [PATCH] Updated dependencies to match latest starterkit * removed unused dependencies * updated dependencies to match starterkit * updated build pipeline --- .eslintrc.json | 109 +++++++++++++++++------------- .tasks | 13 ++++ Makefile | 58 ++++++++++------ cockpit-session-recording.spec.in | 2 +- cockpituous-release | 4 +- package.json | 73 ++++++++++---------- test/run | 8 ++- 7 files changed, 155 insertions(+), 112 deletions(-) create mode 100755 .tasks diff --git a/.eslintrc.json b/.eslintrc.json index 3b7538e..efdbe59 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,52 +1,67 @@ { - "env": { - "browser": true, - "es6": true + "root": true, + "env": { + "browser": true, + "es6": true + }, + "extends": ["eslint:recommended", "standard", "standard-react"], + "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": "7", + "ecmaFeatures": { + "jsx": true }, - "extends": ["eslint:recommended", "standard", "standard-react"], - "parser": "babel-eslint", - "parserOptions": { - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true - }, - "sourceType": "module" - }, - "plugins": ["flowtype", "react"], - "rules": { - "indent": ["error", 4, - { - "ObjectExpression": "first", - "CallExpression": {"arguments": "first"}, - "MemberExpression": 2, - "ignoredNodes": [ "JSXAttribute" ] - }], - "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }], - "lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }], - "prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }], - "react/jsx-indent": ["error", 4], - "semi": ["error", "always", { "omitLastInOneLineBlock": true }], + "sourceType": "module" + }, + "plugins": ["flowtype", "react", "react-hooks"], + "rules": { + "indent": [ + "error", + 4, + { + "ObjectExpression": "first", + "CallExpression": { "arguments": "first" }, + "MemberExpression": 2, + "ignoredNodes": ["JSXAttribute"] + } + ], + "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }], + "lines-between-class-members": [ + "error", + "always", + { "exceptAfterSingleLine": true } + ], + "prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }], + "react/jsx-indent": ["error", 4], + "semi": ["error", "always", { "omitLastInOneLineBlock": true }], - "camelcase": "off", - "comma-dangle": "off", - "curly": "off", - "jsx-quotes": "off", - "key-spacing": "off", - "no-console": "off", - "quotes": "off", - "react/jsx-curly-spacing": "off", - "react/jsx-indent-props": "off", - "react/prop-types": "off", - "space-before-function-paren": "off", - "standard/no-callback-literal": "off", + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "error", - "eqeqeq": "off", - "import/no-webpack-loader-syntax": "off", - "object-property-newline": "off", - "react/jsx-no-bind": "off" - }, - "globals": { - "require": false, - "module": false - } + "camelcase": "off", + "comma-dangle": "off", + "curly": "off", + "jsx-quotes": "off", + "key-spacing": "off", + "new-cap": "off", + "no-console": "off", + "prefer-const": "off", + "quotes": "off", + "react/jsx-closing-bracket-location": "off", + "react/jsx-curly-spacing": "off", + "react/jsx-indent-props": "off", + "react/jsx-handler-names": "off", + "react/prop-types": "off", + "space-before-function-paren": "off", + "standard/no-callback-literal": "off", + + "eqeqeq": "off", + "import/no-webpack-loader-syntax": "off", + "object-property-newline": "off", + "react/jsx-no-bind": "off" + }, + "globals": { + "require": false, + "module": false + } } diff --git a/.tasks b/.tasks new file mode 100755 index 0000000..2026460 --- /dev/null +++ b/.tasks @@ -0,0 +1,13 @@ +#!/bin/sh + +# When run automated, randomize to minimize stampeding herd +if [ -t 0 ]; then + chance=10 +else + chance=$(shuf -i 0-10 -n 1) +fi + +if [ $chance -gt 9 ]; then + # Open issues for things that need doing on a regular basis + bots/npm-trigger +fi diff --git a/Makefile b/Makefile index 61b2302..b39e69c 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,11 @@ ifeq ($(TEST_OS),) TEST_OS = rhel-x endif export TEST_OS +TARFILE=cockpit-$(PACKAGE_NAME)-$(VERSION).tar.gz +RPMFILE=$(shell rpmspec -D"VERSION $(VERSION)" -q cockpit-session-recording.spec.in).rpm VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS) -# one example directory from `npm install` to check if that already ran -NODE_MODULES_TEST=node_modules/po2json +# stamp file to check if/when npm install ran +NODE_MODULES_TEST=package-lock.json # one example file in dist/ from webpack to check if that already ran WEBPACK_TEST=dist/index.html @@ -21,7 +23,7 @@ LINGUAS=$(basename $(notdir $(wildcard po/*.po))) po/POTFILES.js.in: mkdir -p $(dir $@) - find src/ -name '*.js' -o -name '*.jsx' -o -name '*.es6' > $@ + find src/ -name '*.js' -o -name '*.jsx' > $@ po/$(PACKAGE_NAME).js.pot: po/POTFILES.js.in xgettext --default-domain=cockpit --output=$@ --language=C --keyword= \ @@ -61,11 +63,14 @@ dist/po.%.js: po/%.po $(NODE_MODULES_TEST) # %.spec: %.spec.in - sed -e 's/@VERSION@/$(VERSION)/g' $< > $@ + sed -e 's/%{VERSION}/$(VERSION)/g' $< > $@ $(WEBPACK_TEST): $(NODE_MODULES_TEST) $(shell find src/ -type f) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS)) NODE_ENV=$(NODE_ENV) npm run build +watch: + NODE_ENV=$(NODE_ENV) npm run watch + clean: rm -rf dist/ [ ! -e cockpit-$(PACKAGE_NAME).spec.in ] || rm -f cockpit-$(PACKAGE_NAME).spec @@ -81,29 +86,32 @@ devel-install: $(WEBPACK_TEST) mkdir -p ~/.local/share/cockpit ln -s `pwd`/dist ~/.local/share/cockpit/$(PACKAGE_NAME) +dist-gzip: $(TARFILE) + # when building a distribution tarball, call webpack with a 'production' environment -# ship a stub node_modules/ so that `make` works without re-running `npm install` -dist-gzip: NODE_ENV=production -dist-gzip: all cockpit-$(PACKAGE_NAME).spec +# we don't ship node_modules for license and compactness reasons; we ship a +# pre-built dist/ (so it's not necessary) and ship packge-lock.json (so that +# node_modules/ can be reconstructed if necessary) +$(TARFILE): NODE_ENV=production +$(TARFILE): $(WEBPACK_TEST) cockpit-$(PACKAGE_NAME).spec + if type appstream-util >/dev/null 2>&1; then appstream-util validate-relax --nonet *.metainfo.xml; fi mv node_modules node_modules.release - mkdir -p $(NODE_MODULES_TEST) touch -r package.json $(NODE_MODULES_TEST) touch dist/* tar czf cockpit-$(PACKAGE_NAME)-$(VERSION).tar.gz --transform 's,^,cockpit-$(PACKAGE_NAME)/,' \ --exclude cockpit-$(PACKAGE_NAME).spec.in \ - $$(git ls-files) cockpit-$(PACKAGE_NAME).spec dist/ node_modules - rm -rf node_modules + $$(git ls-files) package-lock.json cockpit-$(PACKAGE_NAME).spec dist/ mv node_modules.release node_modules -srpm: dist-gzip cockpit-$(PACKAGE_NAME).spec - appstream-util validate-relax --nonet *.metainfo.xml +srpm: $(TARFILE) cockpit-$(PACKAGE_NAME).spec rpmbuild -bs \ --define "_sourcedir `pwd`" \ --define "_srcrpmdir `pwd`" \ cockpit-$(PACKAGE_NAME).spec -rpm: dist-gzip cockpit-$(PACKAGE_NAME).spec - appstream-util validate-relax --nonet ./*.metainfo.xml +rpm: $(RPMFILE) + +$(RPMFILE): $(TARFILE) cockpit-$(PACKAGE_NAME).spec mkdir -p "`pwd`/output" mkdir -p "`pwd`/rpmbuild" rpmbuild -bb \ @@ -117,11 +125,13 @@ rpm: dist-gzip cockpit-$(PACKAGE_NAME).spec find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \; rm -r "`pwd`/rpmbuild" rm -r "`pwd`/output" "`pwd`/build" + # sanity check + test -e "$(RPMFILE)" # build a VM with locally built rpm installed -$(VM_IMAGE): rpm bots +$(VM_IMAGE): $(RPMFILE) bots rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2 - bots/image-customize -v -i cockpit-ws -i `pwd`/cockpit-$(PACKAGE_NAME)-*.noarch.rpm -s $(CURDIR)/test/vm.install $(TEST_OS) + bots/image-customize -v -i cockpit-ws -i `pwd`/$(RPMFILE) -s $(CURDIR)/test/vm.install $(TEST_OS) bots/image-customize -v -r "usermod -u 981 tlog || true" $(TEST_OS) bots/image-customize -v -u ./test/files/1.journal:/var/log/journal/1.journal $(TEST_OS) @@ -130,11 +140,13 @@ vm: $(VM_IMAGE) echo $(VM_IMAGE) # run the browser integration tests; skip check for SELinux denials +# this will run all tests/check-* and format them as TAP check: $(NODE_MODULES_TEST) $(VM_IMAGE) test/common - TEST_AUDIT_NO_SELINUX=1 test/check-application -s + TEST_AUDIT_NO_SELINUX=1 test/common/run-tests # checkout Cockpit's bots for standard test VM images and API to launch them # must be from master, as only that has current and existing images; but testvm.py API is stable +# support CI testing against a bots change bots: sudo rm -rf bots git clone --quiet --reference-if-able $${XDG_CACHE_HOME:-$$HOME/.cache}/cockpit-project/bots https://github.com/cockpit-project/bots.git @@ -142,13 +154,17 @@ bots: @echo "checked out bots/ ref $$(git -C bots rev-parse HEAD)" # checkout Cockpit's test API; this has no API stability guarantee, so check out a stable tag -# when you start a new project, use the latest relese, and update it from time to time +# when you start a new project, use the latest release, and update it from time to time test/common: - git fetch --depth=1 https://github.com/cockpit-project/cockpit.git 219 + git fetch --depth=1 https://github.com/cockpit-project/cockpit.git 220 git checkout --force FETCH_HEAD -- test/common git reset test/common $(NODE_MODULES_TEST): package.json - npm install + # if it exists already, npm install won't update it; force that so that we always get up-to-date packages + rm -f package-lock.json + # unset NODE_ENV, skips devDependencies otherwise + env -u NODE_ENV npm install + env -u NODE_ENV npm prune -.PHONY: all bots clean install devel-install dist-gzip srpm rpm check vm update-po +.PHONY: all clean install devel-install dist-gzip srpm rpm check vm update-po diff --git a/cockpit-session-recording.spec.in b/cockpit-session-recording.spec.in index 3496df9..7b7e25e 100644 --- a/cockpit-session-recording.spec.in +++ b/cockpit-session-recording.spec.in @@ -1,5 +1,5 @@ Name: cockpit-session-recording -Version: @VERSION@ +Version: %{VERSION} Release: 1%{?dist} Summary: Cockpit Session Recording License: LGPLv2+ diff --git a/cockpituous-release b/cockpituous-release index b876779..b638fd7 100644 --- a/cockpituous-release +++ b/cockpituous-release @@ -8,11 +8,11 @@ # Check cockpituous documentation for available release targets. RELEASE_SOURCE="_release/source" -RELEASE_SPEC="cockpit-starter-kit.spec" +RELEASE_SPEC="cockpit-session-recording.spec" RELEASE_SRPM="_release/srpm" job release-source -job release-srpm +job release-srpm -V # Once you have a Fedora package and add the https://pagure.io/user/cockpit # user to your project's maintainers, you can also upload to Fedora automatically: diff --git a/package.json b/package.json index a096788..b99265d 100644 --- a/package.json +++ b/package.json @@ -1,68 +1,63 @@ { "name": "session-recording", "version": "0.1.0", - "description": "Scaffolding for a cockpit module", + "description": "Module for Cockpit which provides session recording configuration and playback", "main": "index.js", - "repository": "git@github.com:cockpit/starter-kit.git", + "repository": "git@github.com:Scribery/cockpit-session-recording.git", "author": "", "license": "LGPL-2.1", "scripts": { + "watch": "webpack --watch", "build": "webpack", - "eslint": "eslint --ext .jsx --ext .es6 src/", - "eslint:fix": "eslint --fix --ext .jsx --ext .es6 src/" + "eslint": "eslint --ext .js --ext .jsx src/", + "eslint:fix": "eslint --fix --ext .js --ext .jsx src/" }, "devDependencies": { - "@babel/core": "^7.0.0", - "@babel/preset-env": "^7.0.0", + "@babel/core": "^7.5.4", + "@babel/preset-env": "^7.5.4", "@babel/preset-react": "^7.0.0", - "babel-eslint": "^9.0.0", + "babel-eslint": "^10.0.3", "babel-loader": "^8.0.0", - "chrome-remote-interface": "^0.25.5", + "chrome-remote-interface": "^0.28.0", "compression-webpack-plugin": "^1.1.11", "copy-webpack-plugin": "^4.5.2", - "css-loader": "^0.28.11", - "eslint": "^5.4.0", - "eslint-config-standard": "^11.0.0", - "eslint-config-standard-react": "^6.0.0", - "eslint-loader": "^2.1.0", - "eslint-plugin-flowtype": "^2.50.0", - "eslint-plugin-import": "^2.14.0", - "eslint-plugin-node": "^7.0.1", - "eslint-plugin-promise": "^4.0.0", - "eslint-plugin-react": "^6.9.0", - "eslint-plugin-standard": "^3.1.0", - "extract-text-webpack-plugin": "^4.0.0-beta.0", + "css-loader": "^3.0.0", + "eslint": "^6.3.0", + "eslint-config-standard": "^14.1.0", + "eslint-config-standard-react": "^9.2.0", + "eslint-loader": "^3.0.0", + "eslint-plugin-flowtype": "^4.3.0", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-node": "^10.0.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-react": "^7.14.3", + "eslint-plugin-react-hooks": "^2.1.2", + "eslint-plugin-standard": "^4.0.1", "htmlparser": "^1.7.7", "jed": "^1.1.1", - "jshint": "~2.9.1", - "jshint-loader": "~0.8.3", - "less": "~3.0.1", - "less-loader": "~4.0.6", - "po2json": "^0.4.5", + "mini-css-extract-plugin": "^0.9.0", + "node-sass": "^4.14.1", + "po2json": "^1.0.0-alpha", "sass-loader": "^7.0.3", "sizzle": "^2.3.3", "stdio": "^0.2.7", - "webpack": "^4.19.0", + "string-replace-loader": "^2.3.0", + "webpack": "^4.17.1", "webpack-cli": "^3.1.0" }, "dependencies": { - "@babel/polyfill": "^7.0.0", - "bootstrap": "3.3.7", - "bootstrap-datetime-picker": "2.4.4", - "bootstrap-slider": "^10.2.1", + "@patternfly/patternfly": "^4.16.7", + "@patternfly/react-core": "^4.23.1", + "@patternfly/react-table": "^4.8.6", "comment-json": "^1.1.3", - "fs.extra": "^1.3.2", - "fs.realpath": "^1.0.0", + "core-js": "3.6.5", "ini": "^1.3.5", - "jquery": "3.3.1", - "moment": "2.22.2", + "jquery": "3.5.1", + "moment": "2.27.0", "mustache": "2.3.0", - "node-sass": "^4.9.0", - "patternfly": "3.35.1", - "prop-types": "^15.6.2", "raw-loader": "^0.5.1", - "react": "^16.4.2", - "react-dom": "^16.4.2", + "react": "16.13.1", + "react-dom": "16.13.1", "xterm": "^3.14.5" } } diff --git a/test/run b/test/run index 46a2d01..ed43e3a 100755 --- a/test/run +++ b/test/run @@ -1,4 +1,8 @@ -#! /bin/bash +#! /bin/sh +set -eu + # This is the expected entry point for Cockpit CI; will be called without -# arguments but with an appropriate $TEST_OS +# arguments but with an appropriate $TEST_OS, and optionally $TEST_SCENARIO + +[ -z "${TEST_SCENARIO:-}" ] || export TEST_BROWSER="$TEST_SCENARIO" make check