[Pkg-javascript-commits] [acorn] 01/03: Use rollup -- like upstream

Julien Puydt julien.puydt at laposte.net
Tue Feb 27 19:11:51 UTC 2018


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository acorn.

commit e3b22b1cf2663659a009dc2beed38a14592f0af3
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Sun Feb 25 19:20:08 2018 +0100

    Use rollup -- like upstream
---
 debian/changelog                             |   6 ++
 debian/control                               |   4 +-
 debian/node-acorn.install                    |   4 +-
 debian/node-acorn.links                      |   1 +
 debian/node-acorn.lintian-overrides          |   2 +
 debian/patches/modernize_rollup_config.patch | 108 +++++++++++++++++++++++++++
 debian/patches/series                        |   2 +-
 debian/patches/unbreak_build                 |  15 ----
 debian/rules                                 |  49 +++---------
 debian/tests/runtestsuite                    |   6 +-
 debian/tests/smoketest                       |   2 +-
 11 files changed, 135 insertions(+), 64 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e3ae421..ace9ea5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+acorn (5.4.1+ds1-2) UNRELEASED; urgency=medium
+
+  * Use rollup -- like upstream.
+
+ -- Julien Puydt <julien.puydt at laposte.net>  Sun, 25 Feb 2018 19:19:51 +0100
+
 acorn (5.4.1+ds1-1) unstable; urgency=medium
 
   * New upstream release.
diff --git a/debian/control b/debian/control
index 4adffe0..e230518 100644
--- a/debian/control
+++ b/debian/control
@@ -6,9 +6,9 @@ Priority: optional
 Build-Depends: debhelper (>= 10),
                docbook2x <!nodoc>,
                node-ast-types,
-               node-es6-module-transpiler,
                node-graceful-fs,
-               nodejs (>= 6)
+               nodejs (>= 6),
+               rollup
 Standards-Version: 4.1.3
 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-javascript/acorn.git
 Vcs-Git: https://anonscm.debian.org/git/pkg-javascript/acorn.git
diff --git a/debian/node-acorn.install b/debian/node-acorn.install
index b207780..1720ed8 100644
--- a/debian/node-acorn.install
+++ b/debian/node-acorn.install
@@ -1,3 +1,3 @@
-src usr/lib/nodejs/acorn/
-dist/* usr/lib/nodejs/acorn/
+dist/* usr/lib/nodejs/acorn/dist/
+bin/*acorn* usr/lib/nodejs/acorn/bin/
 package.json   usr/lib/nodejs/acorn/
diff --git a/debian/node-acorn.links b/debian/node-acorn.links
index 090f0cd..645eab8 100644
--- a/debian/node-acorn.links
+++ b/debian/node-acorn.links
@@ -1 +1,2 @@
 usr/lib/nodejs/acorn/bin/acorn usr/bin/acorn
+usr/lib/nodejs/acorn/dist/acorn.js usr/lib/nodejs/acorn/index.js
diff --git a/debian/node-acorn.lintian-overrides b/debian/node-acorn.lintian-overrides
new file mode 100644
index 0000000..c658fb7
--- /dev/null
+++ b/debian/node-acorn.lintian-overrides
@@ -0,0 +1,2 @@
+# not supposed to be run directly
+node-acorn: script-not-executable usr/lib/nodejs/acorn/bin/_acorn.js
diff --git a/debian/patches/modernize_rollup_config.patch b/debian/patches/modernize_rollup_config.patch
new file mode 100644
index 0000000..90793a9
--- /dev/null
+++ b/debian/patches/modernize_rollup_config.patch
@@ -0,0 +1,108 @@
+Description: adapt rollup config files to more modern versions
+Author: Julien Puydt
+Forwarded: no
+
+--- a/rollup/config.bin.js
++++ b/rollup/config.bin.js
+@@ -1,9 +1,8 @@
+ import buble from 'rollup-plugin-buble'
+ 
+ export default {
+-  entry: 'src/bin/acorn.js',
+-  dest: 'bin/_acorn.js',
+-  format: 'cjs',
++  input: 'src/bin/acorn.js',
++  output: { file: 'bin/_acorn.js', format: 'cjs' },
+   banner: '#!/usr/bin/env node',
+   external: [ 'fs', 'path', 'acorn' ],
+   paths: {
+--- a/rollup/config.loose.js
++++ b/rollup/config.loose.js
+@@ -7,13 +7,13 @@
+ globals[acorn] = 'acorn'
+ 
+ export default {
+-  entry: 'src/loose/index.js',
+-  moduleName: 'acorn.loose',
++  input: 'src/loose/index.js',
++  name: 'acorn.loose',
+   external: [ acorn ],
+   paths: paths,
+   globals: globals,
+-  targets: [
+-    { dest: 'dist/acorn_loose.js', format: 'umd' }
++  output: [
++    { file: 'dist/acorn_loose.js', format: 'umd' }
+   ],
+   plugins: [
+     buble({
+--- a/rollup/config.loose_es.js
++++ b/rollup/config.loose_es.js
+@@ -7,13 +7,13 @@
+ globals[acorn] = 'acorn'
+ 
+ export default {
+-  entry: 'src/loose/index.js',
+-  moduleName: 'acorn.loose',
++  input: 'src/loose/index.js',
++  name: 'acorn.loose',
+   external: [ acorn ],
+   paths: paths,
+   globals: globals,
+-  targets: [
+-    { dest: 'dist/acorn_loose.es.js', format: 'es' }
++  output: [
++    { file: 'dist/acorn_loose.es.js', format: 'es' }
+   ],
+   plugins: [
+     buble({
+--- a/rollup/config.main.js
++++ b/rollup/config.main.js
+@@ -1,8 +1,8 @@
+ import buble from 'rollup-plugin-buble';
+ 
+ export default {
+-	entry: 'src/index.js',
+-	moduleName: 'acorn',
++	input: 'src/index.js',
++	name: 'acorn',
+ 	plugins: [
+ 		buble({
+ 			transforms: {
+@@ -10,8 +10,8 @@
+ 			}
+ 		})
+ 	],
+-	targets: [
+-		{ dest: 'dist/acorn.js', format: 'umd' },
+-		{ dest: 'dist/acorn.es.js', format: 'es' }
++	output: [
++		{ file: 'dist/acorn.js', format: 'umd' },
++		{ file: 'dist/acorn.es.js', format: 'es' }
+ 	]
+ };
+--- a/rollup/config.walk.js
++++ b/rollup/config.walk.js
+@@ -1,8 +1,8 @@
+ import buble from 'rollup-plugin-buble';
+ 
+ export default {
+-	entry: 'src/walk/index.js',
+-	moduleName: 'acorn.walk',
++	input: 'src/walk/index.js',
++	name: 'acorn.walk',
+ 	plugins: [
+ 		buble({
+ 			transforms: {
+@@ -10,8 +10,8 @@
+ 			}
+ 		})
+ 	],
+-	targets: [
+-		{ dest: 'dist/walk.js', format: 'umd' },
+-		{ dest: 'dist/walk.es.js', format: 'es' }
++	output: [
++		{ file: 'dist/walk.js', format: 'umd' },
++		{ file: 'dist/walk.es.js', format: 'es' }
+ 	]
+ };
diff --git a/debian/patches/series b/debian/patches/series
index c628a67..560c1dc 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1 @@
-unbreak_build
+modernize_rollup_config.patch
diff --git a/debian/patches/unbreak_build b/debian/patches/unbreak_build
deleted file mode 100644
index f76c58a..0000000
--- a/debian/patches/unbreak_build
+++ /dev/null
@@ -1,15 +0,0 @@
-Description: simplify the code so node-es6-module-transpiler works
-Author: Julien Puydt
-Forwarded: no
-
---- a/src/expression.js
-+++ b/src/expression.js
-@@ -512,7 +512,7 @@
-   return this.finishNode(elem, "TemplateElement")
- }
- 
--pp.parseTemplate = function({isTagged = false} = {}) {
-+pp.parseTemplate = function(isTagged = false) {
-   let node = this.startNode()
-   this.next()
-   node.expressions = []
diff --git a/debian/rules b/debian/rules
index ccdef69..9d28314 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,50 +4,33 @@ include /usr/share/dpkg/pkg-info.mk
 
 MANPAGES_TARGET := $(subst .1.xml,.1, $(wildcard debian/man/*.*.xml))
 
-SOURCES = $(shell find src/ -name "*.js")
-TARGETS = $(subst src, dist, $(SOURCES))
-COMPILE_MODULES = compile-modules convert -f commonjs -I/usr/lib/nodejs/graceful-fs -I/usr/lib/nodejs/ast-types/lib
-SED_EXPR =  -e 's/$$.tokTypes/$$.types/g' -e 's/$$.tokContexts/$$.types/g' -e 's/new Parser/new $$$$state$$$$.Parser/g'
-
 TESTSUITEDIR=debian/testsuite
 
 %:
 	dh $@
 
-override_dh_auto_build: dist $(TARGETS) $(MANPAGES)
-	# I guess rollup is better than node-es6-module-transpiler...
-	# but we don't have rollup (yet)
-	find dist -name index.js -exec sed -i {} $(SED_EXPR) \;
-	sed -i dist/loose/index.js -e 's/tabSize = 4/tabSize=4;var LooseParser=\$$$$state$$$$.LooseParser;var pluginsLoose=$$$$state$$$$.pluginsLoose;/g'
-	mv dist/bin/acorn.js dist/bin/acorn
-	chmod a+x dist/bin/acorn
-	sed -i dist/bin/acorn -e 's/\$$//g'
-	sed -i dist/bin/acorn -e 's|"use strict";|#!/usr/bin/node|'
-	# recreate symlink (need to go with rollup)
-	ln -s dist/index.js acorn.js
-	ln -s dist/index.js index.js
-	ln -s index.js dist/acorn.js
-	ln -s loose dist/acorn_loose
-	ln -s walk dist/acorn_walk
-	ln -s . dist/dist
-	# fix #848507 (need to go with rollup)
-	echo "walk = require('./walk/'); module.exports = walk; " > dist/walk.js
-	echo "loose = require('./loose/'); module.exports = loose;" > dist/loose.js
+override_dh_auto_build: $(MANPAGES)
+	rollup -c rollup/config.main.js \
+	&& rollup -c rollup/config.walk.js \
+	&& rollup -c rollup/config.loose.js \
+	&& rollup -c rollup/config.loose_es.js \
+	&& rollup -c rollup/config.bin.js
 
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)))
 override_dh_auto_test:
 	# create a link in order to run acorn
 	mkdir -p $(TESTSUITEDIR)
 	ln -s ../../dist $(TESTSUITEDIR)/dist
-	cp  dist/bin/acorn $(TESTSUITEDIR)/binacorn
-	sed -i 's,require[(]"acorn"[)],require("./dist/index.js"),g' $(TESTSUITEDIR)/binacorn
+	cp bin/_acorn.js $(TESTSUITEDIR)/binacorn
+	chmod +x $(TESTSUITEDIR)/binacorn
+	sed -i "s,require('../dist/acorn.js'),require('./dist/acorn.js'),g" $(TESTSUITEDIR)/binacorn
 	@echo '*********************************************************'
 	@echo 'Run test suite                                           '
 	@echo '**********************************************************'
 	# basic smoke test
 	@echo Run bin acorn on itself
 	@echo '=========================================================='
-	./$(TESTSUITEDIR)/binacorn < dist/index.js
+	./$(TESTSUITEDIR)/binacorn < dist/acorn.js
 	@echo '=========================================================='
 	# run package testsuite
 	@echo '=========================================================='
@@ -61,18 +44,6 @@ override_dh_auto_test:
 	@echo '**********************************************************'
 endif	
 
-.PHONY: dist
-dist:
-	mkdir -p dist
-	mkdir -p dist/bin
-	mkdir -p dist/loose
-	mkdir -p dist/walk
-
-dist/bin/acorn.js: dist/index.js
-
-%.js:
-	$(COMPILE_MODULES) -I$(dir $(subst dist, src, $@)) $(subst dist, src, $@) > $@
-
 %.1: %.1.xml
 	# Create man page from DocBook XML
 	cd $(dir $@) && docbook2x-man --encoding=utf-8 --string-param header-3="$(SOURCE_DATE_EPOCH)" $(notdir $@).xml
diff --git a/debian/tests/runtestsuite b/debian/tests/runtestsuite
index 534af94..cd539f5 100755
--- a/debian/tests/runtestsuite
+++ b/debian/tests/runtestsuite
@@ -2,9 +2,7 @@
 set -e
 # notice the / at end in order to load this module
 PACKAGE='acorn'
-SEDCMD1="s,require\s*[(]\s*[\"][.][.]/dist/acorn[\"'],require(\"$PACKAGE/\",g"
-SEDCMD2="s,require\s*[(]\s*[\"][.][.]/dist/acorn_loose[\"'],require(\"$PACKAGE/loose\",g"
-SEDCMD3="s,require\s*[(]\s*[\"'][.][.][\"'],require('$PACKAGE',g"
+SEDCMD="s,require\s*[(]\s*[\"][.][.],require(\"$PACKAGE/,g"
 
 tmpdir=$(mktemp -d)
 trap 'rm -rf "$tmpdir"' EXIT INT TERM HUP
@@ -12,5 +10,5 @@ trap 'rm -rf "$tmpdir"' EXIT INT TERM HUP
 cp -r test/ $tmpdir/test
 find test/ -name '*.js' -print0 | \
     xargs -0 -n1  \
-	  sh -c 'set -e; echo "Create: $5"; sed -E -e "$1" -e "$2" -e "$3" < "$5" > "$4/$5"' sedtape "$SEDCMD1" "$SEDCMD2" "$SEDCMD3" "$tmpdir"
+	  sh -c 'set -e; echo "Create: $3"; sed "$1" < "$3" > "$2/$3"' sedtape "$SEDCMD" "$tmpdir"
 node $tmpdir/test/run.js
diff --git a/debian/tests/smoketest b/debian/tests/smoketest
index 6c914c8..0fb19af 100755
--- a/debian/tests/smoketest
+++ b/debian/tests/smoketest
@@ -1,3 +1,3 @@
 #!/bin/sh
 set -e
-acorn < /usr/lib/nodejs/acorn/index.js
\ No newline at end of file
+acorn < /usr/lib/nodejs/acorn/index.js > /dev/null

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/acorn.git



More information about the Pkg-javascript-commits mailing list