Allow to use ES6 in the code base itself, require node>=4.0.0

Given the purpose of this fork, I think it is quite safe to assume users
have at least this version.

Allows to remove some old-school transpilation and the need for any
build step.
This commit is contained in:
Ran Benita
2017-09-12 19:48:08 +03:00
parent 62545ca23e
commit d1888e7546
16 changed files with 11 additions and 293 deletions
+5
View File
@@ -0,0 +1,5 @@
/tests/
/examples/
/run-tests.js
/.travis.yml
/.npmignore
-2
View File
@@ -7,5 +7,3 @@ node_js:
- "4.2"
- "4.1"
- "4.0"
- "0.10"
- "iojs"
-36
View File
@@ -1,36 +0,0 @@
# Build instructions
ng-annotate is written in ES6 constlet style and uses defs.js to transpile
to ES5, via an optional build step, so that it can execute without the
`--harmony` flag passed to node.
The git repository contains the original constlet style source code as well
as the build scripts. It does not contain build artefacts (transpiled or
bundled source).
The build scripts populates the `build/es5` directory.
The NPM package contains a snapshot of the git repository at the time as
well as `build/es5`. `package.json` refers to the transpiled version in
`build/es5`, so there's no need to execute node with `--harmony` when
running a `npm -g` installed `ng-annotate` from the command line or when
doing a `require("ng-annotate")` of the same.
If you clone the git repository then don't forget to also `npm install` the
dependencies (see `package.json`).
If you want to run ng-annotate in its original form (rather than
transpiled), for instance if you're hacking on it, then just run the tool
via `ng-annotate-harmony` (not a NPM exported binary but check the package
root) or include it as a library via
`require("ng-annotate/ng-annotate-main")`. This applies to a git clone just
as well as the NPM package.
`run-tests.js` is the test runner. Run it on the original source via
`node --harmony run-tests.js` or `npm test`. The tests are run automatically
in the build scripts.
To build, `cd build` then run `./build.sh` for defs transpilation.
`./clean.sh` removes the build artefacts.
I use `prepare.sh` to prepare a release tarball for NPM publishing.
Happy hacking!
+3
View File
@@ -1,3 +1,6 @@
## UNRELEASED
* Require node>=4.0.0.
## v1.6.0 2017-05-28
* Switch from tilde ~ dependencies to ^ caret dependencies.
-28
View File
@@ -1,28 +0,0 @@
#!/bin/bash
echo "beginning ng-annotate defs-build"
rm -rf es5
mkdir es5
declare -a files=(generate-sourcemap.js lut.js ng-annotate.js ng-annotate-main.js nginject.js run-tests.js scope.js scopetools.js traverse.js optionals/angular-dashboard-framework.js)
DEFS="../node_modules/.bin/defs"
if [[ ! -f "$DEFS" ]]; then DEFS="../../../../node_modules/.bin/defs" ; fi
if [[ ! -f "$DEFS" ]]; then DEFS="defs" ; fi
for i in ${files[@]}
do
echo "building $i with defs"
mkdir -p es5/$(dirname $i)
$DEFS ../$i > es5/$i
done
cp ng-annotate es5/
echo "hard-coding version"
node --harmony inline-version.js
cd es5
echo "running tests (in es5 mode i.e. without --harmony)"
cp -r ../../tests .
/usr/bin/env node run-tests.js
echo "done self-build"
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
echo "cleaning build files"
rm -rf es5 browser npm
echo "done cleaning"
-1
View File
@@ -1 +0,0 @@
../defs-config.json
-3
View File
@@ -1,3 +0,0 @@
#!/bin/sh
echo "Error: ng-annotate has not been built.\nRetry after doing this: cd <ng-annotate-path>; npm install; cd build; ./build.sh"
exit 1
-2
View File
@@ -1,2 +0,0 @@
console.error("Error: ng-annotate has not been built.\nRetry after doing this: cd <ng-annotate-path>; npm install; cd build; ./build.sh");
process.exit(1)
-6
View File
@@ -1,6 +0,0 @@
const version = require("../package.json").version
const fs = require("fs");
const src = String(fs.readFileSync("es5/ng-annotate.js"));
const dst = src.replace('require("./package.json").version', JSON.stringify(version));
fs.writeFileSync("es5/ng-annotate.js", dst);
-17
View File
@@ -1,17 +0,0 @@
#!/bin/sh
cd ..
rm -rf build/npm
mkdir build/npm
git archive fork -o build/npm/ng-annotate-patched.tar --prefix=ng-annotate-patched/
cd build/npm
tar xf ng-annotate-patched.tar && rm ng-annotate-patched.tar
cd ng-annotate-patched/build
./build.sh
# delete build scripts
rm *.sh *.js defs-config.json ng-annotate
# delete .gitignore
rm ../.gitignore
# delete large test artifacts
rm ../tests/angular.js ../build/es5/tests/angular.js
cd ../..
tar czf ng-annotate-patched.tgz ng-annotate-patched && rm -rf ng-annotate-patched
-6
View File
@@ -1,6 +0,0 @@
{
"environments": ["node"],
"disallowVars": true,
"disallowDuplicated": true,
"disallowUnknownReferences": true
}
View File
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
rdlkf() { [ -L "$1" ] && (local lk="$(readlink "$1")"; local d="$(dirname "$1")"; cd "$d"; local l="$(rdlkf "$lk")"; ([[ "$l" = /* ]] && echo "$l" || echo "$d/$l")) || echo "$1"; }
DIR="$(dirname "$(rdlkf "$0")")"
/usr/bin/env node --harmony "$DIR/ng-annotate.js" "$@"
-180
View File
@@ -9,17 +9,6 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz",
"integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA=="
},
"align-text": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
"integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=",
"dev": true,
"requires": {
"kind-of": "3.2.2",
"longest": "1.0.1",
"repeat-string": "1.6.1"
}
},
"alter": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/alter/-/alter-0.2.0.tgz",
@@ -28,53 +17,6 @@
"stable": "0.1.6"
}
},
"ast-traverse": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ast-traverse/-/ast-traverse-0.1.1.tgz",
"integrity": "sha1-ac8rg4bxnc2hux4F1o/jWdiJfeY=",
"dev": true
},
"breakable": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/breakable/-/breakable-1.0.0.tgz",
"integrity": "sha1-eEp5eRWjjq0nutRWtVcstLuqeME=",
"dev": true
},
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
"dev": true
},
"center-align": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
"integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=",
"dev": true,
"requires": {
"align-text": "0.1.4",
"lazy-cache": "1.0.4"
}
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
"integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
"dev": true,
"requires": {
"center-align": "0.1.3",
"right-align": "0.1.3",
"wordwrap": "0.0.2"
},
"dependencies": {
"wordwrap": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=",
"dev": true
}
}
},
"coffee-script": {
"version": "1.12.7",
"resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.12.7.tgz",
@@ -86,90 +28,18 @@
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.0.tgz",
"integrity": "sha1-ms1whRxtXf3ZPZKC5e35SgP/RrU="
},
"decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
"dev": true
},
"defs": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/defs/-/defs-1.1.1.tgz",
"integrity": "sha1-siYJ8sehG6ej2xFoBcE5scr/qdI=",
"dev": true,
"requires": {
"alter": "0.2.0",
"ast-traverse": "0.1.1",
"breakable": "1.0.0",
"esprima-fb": "15001.1001.0-dev-harmony-fb",
"simple-fmt": "0.1.0",
"simple-is": "0.2.0",
"stringmap": "0.2.2",
"stringset": "0.2.1",
"tryor": "0.1.2",
"yargs": "3.27.0"
}
},
"diff": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz",
"integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=",
"dev": true
},
"esprima-fb": {
"version": "15001.1001.0-dev-harmony-fb",
"resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz",
"integrity": "sha1-Q761fsJujPI3092LM+QlM1d/Jlk=",
"dev": true
},
"find-line-column": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/find-line-column/-/find-line-column-0.5.2.tgz",
"integrity": "sha1-2wAjj/hoVRoYLnShA0FtKVqYyMo=",
"dev": true
},
"invert-kv": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
"integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=",
"dev": true
},
"is-buffer": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz",
"integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=",
"dev": true
},
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"requires": {
"is-buffer": "1.1.5"
}
},
"lazy-cache": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz",
"integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=",
"dev": true
},
"lcid": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
"integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
"dev": true,
"requires": {
"invert-kv": "1.0.0"
}
},
"longest": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
"integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=",
"dev": true
},
"minimist": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
@@ -184,30 +54,6 @@
"wordwrap": "0.0.3"
}
},
"os-locale": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
"integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
"dev": true,
"requires": {
"lcid": "1.0.0"
}
},
"repeat-string": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=",
"dev": true
},
"right-align": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
"integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=",
"dev": true,
"requires": {
"align-text": "0.1.4"
}
},
"simple-fmt": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/simple-fmt/-/simple-fmt-0.1.0.tgz",
@@ -243,36 +89,10 @@
"resolved": "https://registry.npmjs.org/tryor/-/tryor-0.1.2.tgz",
"integrity": "sha1-gUXkynyv9ArN48z5Rui4u3W0Fys="
},
"window-size": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz",
"integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=",
"dev": true
},
"wordwrap": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",
"integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc="
},
"y18n": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
"integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=",
"dev": true
},
"yargs": {
"version": "3.27.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.27.0.tgz",
"integrity": "sha1-ISBUaTFuk5Ex1Z8toMbX+YIh6kA=",
"dev": true,
"requires": {
"camelcase": "1.2.1",
"cliui": "2.1.0",
"decamelize": "1.2.0",
"os-locale": "1.4.0",
"window-size": "0.1.4",
"y18n": "3.2.1"
}
}
}
}
+3 -4
View File
@@ -2,7 +2,7 @@
"name": "ng-annotate-patched",
"version": "1.6.0",
"description": "add, remove and rebuild angularjs dependency injection annotations",
"main": "build/es5/ng-annotate-main.js",
"main": "ng-annotate-main.js",
"repository": {
"type": "git",
"url": "https://github.com/bluetech/ng-annotate-patched.git"
@@ -22,7 +22,6 @@
},
"devDependencies": {
"coffee-script": "^1.10.0",
"defs": "^1.1.1",
"diff": "^2.2.1",
"find-line-column": "^0.5.2"
},
@@ -38,9 +37,9 @@
"transformation"
],
"scripts": {
"test": "node --harmony run-tests"
"test": "node run-tests"
},
"bin": "./build/es5/ng-annotate",
"bin": "./ng-annotate",
"author": "Olov Lassus <olov.lassus@gmail.com>",
"license": "MIT"
}