[pve-devel] [PATCH v2 1/3] ship proper nodejs module 'pve-eslint'
Dominik Csapak
d.csapak at proxmox.com
Mon Jul 19 12:31:47 CEST 2021
instead of concatenating the eslint module into our app.js, ship
a 'pve-eslint' module that exports the built eslint module
to do this, we have to leave the module type on 'umd' instead of
changing to 'var' so that nodejs can properly import it.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
Makefile | 2 +-
debian/control | 7 +++++--
debian/dirs | 1 +
debian/links | 1 +
debian/rules | 5 ++++-
patches/0001-adapt-webpack-config.patch | 19 +++++--------------
src/Makefile | 15 ---------------
src/{ => bin}/app.js | 5 ++++-
src/index.js | 3 +++
src/package.json | 9 +++++++++
10 files changed, 33 insertions(+), 34 deletions(-)
create mode 100644 debian/dirs
create mode 100644 debian/links
delete mode 100644 src/Makefile
rename src/{ => bin}/app.js (99%)
create mode 100644 src/index.js
create mode 100644 src/package.json
diff --git a/Makefile b/Makefile
index 9dbe3d0..2a6666c 100644
--- a/Makefile
+++ b/Makefile
@@ -49,7 +49,7 @@ download:
# NOTE: needs npm installed, downloads packages from npm
.PHONY: buildupstream
buildupstream: ${BUILDSRC}
- cp ${BUILDSRC}/build/eslint.js ${SRCDIR}/eslint.js
+ cp ${BUILDSRC}/build/eslint.js ${SRCDIR}/lib/eslint.js
${BUILDSRC}: ${UPSTREAM} patches
rm -rf $@
diff --git a/debian/control b/debian/control
index 3f9b014..7ea3664 100644
--- a/debian/control
+++ b/debian/control
@@ -2,13 +2,16 @@ Source: pve-eslint
Section: devel
Priority: optional
Maintainer: Proxmox Support Team <support at proxmox.com>
-Build-Depends: debhelper (>= 12~)
+Build-Depends: debhelper (>= 12~),
+ nodejs,
+ pkg-js-tools (>= 0.8.11)
Standards-Version: 4.3.0
Homepage: http://www.proxmox.com
Package: pve-eslint
Architecture: all
-Depends: node-commander, node-colors, nodejs, ${misc:Depends},
+Depends: node-commander, node-colors, nodejs (>= ${nodejs:Version}), ${misc:Depends},
+Provides: ${nodejs:Provides}
Description: ESLint for Proxmox Virtual Environment development
This package contains a version of eslint used to develop the
Proxmox Virtual Environment, and other Proxmox projects, web GUI.
diff --git a/debian/dirs b/debian/dirs
new file mode 100644
index 0000000..e772481
--- /dev/null
+++ b/debian/dirs
@@ -0,0 +1 @@
+usr/bin
diff --git a/debian/links b/debian/links
new file mode 100644
index 0000000..99342ed
--- /dev/null
+++ b/debian/links
@@ -0,0 +1 @@
+usr/share/nodejs/pve-eslint/bin/app.js usr/bin/eslint
diff --git a/debian/rules b/debian/rules
index 2d33f6a..b4c4090 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,4 +1,7 @@
#!/usr/bin/make -f
%:
- dh $@
+ dh $@ --with nodejs
+
+execute_after_dh_fixperms:
+ chmod --recursive a+x -- debian/*/usr/share/nodejs/pve-eslint/bin/*
diff --git a/patches/0001-adapt-webpack-config.patch b/patches/0001-adapt-webpack-config.patch
index 4698e74..b0201e1 100644
--- a/patches/0001-adapt-webpack-config.patch
+++ b/patches/0001-adapt-webpack-config.patch
@@ -3,21 +3,20 @@ From: Dominik Csapak <d.csapak at proxmox.com>
Date: Thu, 2 Apr 2020 07:10:18 +0000
Subject: [PATCH] adapt webpack config
-changes to 'var' from 'umd' since we want to use it in the same file
adds 'cli-engine' to build (we use it in our wrapper)
and target 'node' since we will use it on the cli
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
- webpack.config.js | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
+ webpack.config.js | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/webpack.config.js b/webpack.config.js
-index 29d60cb4..95027075 100644
+index a22c99b..9209159 100644
--- a/webpack.config.js
+++ b/webpack.config.js
-@@ -2,14 +2,14 @@
-
+@@ -4,8 +4,9 @@ const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
+ /** @type {import("webpack").Configuration} */
module.exports = {
mode: "none",
+ target: "node",
@@ -27,13 +26,5 @@ index 29d60cb4..95027075 100644
},
output: {
filename: "[name].js",
- library: "[name]",
-- libraryTarget: "umd",
-- globalObject: "this"
-+ libraryTarget: "var"
- },
- module: {
- rules: [
--
2.20.1
-
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index bef1c57..0000000
diff --git a/src/app.js b/src/bin/app.js
similarity index 99%
rename from src/app.js
rename to src/bin/app.js
index 9226234..8a28923 100644
--- a/src/app.js
+++ b/src/bin/app.js
@@ -1,9 +1,12 @@
-(function() {
+#!/usr/bin/env node
+
+(async function(){
'use strict';
const path = require('path');
const color = require('colors');
const program = require('commander');
+const eslint = require('pve-eslint');
program
.usage('[options] [<file(s) ...>]')
diff --git a/src/index.js b/src/index.js
new file mode 100644
index 0000000..01b9a1d
--- /dev/null
+++ b/src/index.js
@@ -0,0 +1,3 @@
+const eslint = require('./lib/eslint.js');
+
+module.exports = eslint;
diff --git a/src/package.json b/src/package.json
new file mode 100644
index 0000000..b08184b
--- /dev/null
+++ b/src/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "pve-eslint",
+ "version": "7.28.0",
+ "files": [
+ "index.js",
+ "bin/app.js",
+ "lib/eslint.js"
+ ]
+}
--
2.30.2
More information about the pve-devel
mailing list