Socket
Socket
Sign inDemoInstall

grunt-ng-annotate

Package Overview
Dependencies
116
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 4.0.0

46

package.json
{
"name": "grunt-ng-annotate",
"version": "3.0.0",
"version": "4.0.0",
"description": "Add, remove and rebuild AngularJS dependency injection annotations.",
"homepage": "https://github.com/mgol/grunt-ng-annotate",
"author": {
"name": "Michał Gołębiowski",
"name": "Michał Gołębiowski-Owczarek",
"email": "m.goleb@gmail.com"

@@ -36,22 +36,26 @@ },

"dependencies": {
"lodash.clonedeep": "^4.5.0",
"ng-annotate": "^1.2.1"
"ng-annotate": "^1.2.2"
},
"devDependencies": {
"babel-preset-es2015": "6.18.0",
"convert-source-map": "1.3.0",
"cross-spawn": "4.0.2",
"eslint-config-mgol": "0.0.33",
"babel-core": "6.26.3",
"babel-preset-es2015": "6.24.1",
"convert-source-map": "1.7.0",
"cross-spawn": "7.0.2",
"eslint": "6.8.0",
"eslint-config-mgol": "0.0.47",
"expect.js": "0.3.1",
"grunt": "1.0.1",
"grunt-babel": "6.0.0",
"grunt-cli": "1.2.0",
"grunt-contrib-clean": "1.0.0",
"grunt": "1.1.0",
"grunt-babel": "7.0.0",
"grunt-cli": "1.3.2",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-eslint": "19.0.0",
"grunt-mocha-test": "0.13.2",
"load-grunt-tasks": "3.5.2",
"mocha": "3.1.2",
"source-map": "0.5.6",
"time-grunt": "1.4.0"
"grunt-eslint": "22.0.0",
"grunt-mocha-test": "0.13.3",
"husky": "4.2.3",
"lint-staged": "10.1.2",
"load-grunt-tasks": "5.1.0",
"mocha": "7.1.1",
"prettier": "2.0.3",
"source-map": "0.7.3",
"time-grunt": "2.0.0"
},

@@ -62,7 +66,9 @@ "peerDependencies": {

"scripts": {
"test": "grunt"
"prettier-check": "prettier --check \"**/*.{json,js,yml,yaml,md}\"",
"prettier-format": "prettier --write \"**/*.{json,js,yml,yaml,md}\"",
"test": "npm run prettier-check && grunt --stack"
},
"engines": {
"node": ">=4.4 <5 || >=6.9"
"node": ">=10"
}
}
# grunt-ng-annotate
> Add, remove and rebuild AngularJS dependency injection annotations. Based on [ng-annotate](https://www.npmjs.org/package/ng-annotate).
**NOTE: `grunt-ng-annotate` is no longer developed similarly to the underlying [ng-annotate](https://www.npmjs.com/package/ng-annotate) package. Switch to [babel-plugin-angularjs-annotate](https://www.npmjs.com/package/babel-plugin-angularjs-annotate) or provide annotations by yourself.**
[![Build Status](https://travis-ci.org/mgol/grunt-ng-annotate.svg?branch=master)](https://travis-ci.org/mgol/grunt-ng-annotate)

@@ -9,2 +12,3 @@ [![Build status](https://ci.appveyor.com/api/projects/status/rr3i854ic8rb47i5/branch/master?svg=true)](https://ci.appveyor.com/project/mgol/grunt-ng-annotate/branch/master)

## Getting Started
This plugin requires Grunt.

@@ -38,3 +42,3 @@

},
})
});
```

@@ -83,3 +87,3 @@

Concatenated files will be joined on this string.
Concatenated files will be joined on this string.

@@ -110,3 +114,2 @@ Type: `string`

## Usage Examples

@@ -133,3 +136,3 @@

ext: '.annotated.js', // Dest filepaths will have this extension.
extDot: 'last', // Extensions in filenames begin after the last dot
extDot: 'last', // Extensions in filenames begin after the last dot
},

@@ -143,3 +146,5 @@ ],

src: ['g.js'],
rename: function (dest, src) { return src + '-annotated'; },
rename: function (dest, src) {
return src + '-annotated';
},
},

@@ -156,11 +161,14 @@ ],

An annotated version of the `f.js` file will be saved as `f.annotated.js` and an annotated version of the `g.js` file will be saved as `g.js-annotated`.
An annotated version of the `f.js` file will be saved as `f.annotated.js` and an annotated version of the `g.js` file will be saved as `g.js-annotated`.
## Supported Node.js versions
This project aims to support all Node.js LTS versions in the "active" phase (see [LTS README](https://github.com/nodejs/LTS/blob/master/README.md) for more details) as well as the latest stable Node.js.
This project aims to support all Node.js versions supported upstream (see [Release README](https://github.com/nodejs/Release/blob/master/README.md) for more details).
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
## License
Copyright (c) 2014 Michał Gołębiowski. Licensed under the MIT license.
Copyright (c) 2014 Michał Gołębiowski-Owczarek. Licensed under the MIT license.

@@ -5,3 +5,3 @@ /**

*
* Author Michał Gołębiowski <m.goleb@gmail.com>
* Author Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
* Licensed under the MIT license.

@@ -13,19 +13,22 @@ */

const path = require('path');
const cloneDeep = require('lodash.clonedeep');
const ngAnnotate = require('ng-annotate');
module.exports = function (grunt) {
const getPathFromTo = (fromFile, toFile) =>
path.relative(path.resolve(path.dirname(fromFile)), path.resolve(toFile))
path
.relative(
path.resolve(path.dirname(fromFile)),
path.resolve(toFile),
)
// URLs should have UNIX-y paths.
.replace(/\\+/g, '/');
const handleOptions = options => {
const finalOptions = cloneDeep(options);
const handleOptions = (options) => {
const finalOptions = {
...options,
ngAnnotateOptions: {
...options.ngAnnotateOptions,
},
};
if (!finalOptions.ngAnnotateOptions) {
finalOptions.ngAnnotateOptions = {};
}
if (finalOptions.add == null) {

@@ -51,3 +54,4 @@ finalOptions.ngAnnotateOptions.add = true;

if (finalOptions.singleQuotes != null) {
finalOptions.ngAnnotateOptions.single_quotes = finalOptions.singleQuotes;
finalOptions.ngAnnotateOptions.single_quotes =
finalOptions.singleQuotes;
delete finalOptions.singleQuotes;

@@ -68,57 +72,61 @@ }

if (options.transformDest != null) {
grunt.fail.fatal([
'The `transformDest` option is no longer supported.',
'The following configuration:',
'',
' app: {',
' options: {',
' transformDest: function (srcPath) {',
' return doSomethingWithSrcPath(srcPath);',
' },',
' },',
' src: [\'app/*.js\'],',
' },',
'',
'should be replaced by:',
'',
' app: {',
' files: [',
' {',
' expand: true,',
' src: [\'app/*.js\'],',
' rename: function (destPath, srcPath) {',
' return doSomethingWithSrcPath(srcPath);',
' },',
' },',
' ],',
' },',
].join('\n'));
grunt.fail.fatal(
[
'The `transformDest` option is no longer supported.',
'The following configuration:',
'',
' app: {',
' options: {',
' transformDest: function (srcPath) {',
' return doSomethingWithSrcPath(srcPath);',
' },',
' },',
" src: ['app/*.js'],",
' },',
'',
'should be replaced by:',
'',
' app: {',
' files: [',
' {',
' expand: true,',
" src: ['app/*.js'],",
' rename: function (destPath, srcPath) {',
' return doSomethingWithSrcPath(srcPath);',
' },',
' },',
' ],',
' },',
].join('\n'),
);
}
if (options.outputFileSuffix != null) {
grunt.fail.fatal([
'The `outputFileSuffix` option is no longer supported.',
'The following configuration:',
'',
' app: {',
' options: {',
' outputFileSuffix: \'-annotated\',',
' },',
' src: [\'app/*.js\'],',
' },',
'',
'should be replaced by:',
'',
' app: {',
' files: [',
' {',
' expand: true,',
' src: [\'app/*.js\'],',
' rename: function (destPath, srcPath) {',
' return srcPath + \'-annotated\';',
' },',
' },',
' ],',
' },',
].join('\n'));
grunt.fail.fatal(
[
'The `outputFileSuffix` option is no longer supported.',
'The following configuration:',
'',
' app: {',
' options: {',
" outputFileSuffix: '-annotated',",
' },',
" src: ['app/*.js'],",
' },',
'',
'should be replaced by:',
'',
' app: {',
' files: [',
' {',
' expand: true,',
" src: ['app/*.js'],",
' rename: function (destPath, srcPath) {',
" return srcPath + '-annotated';",
' },',
' },',
' ],',
' },',
].join('\n'),
);
}

@@ -129,3 +137,4 @@

grunt.registerMultiTask('ngAnnotate',
grunt.registerMultiTask(
'ngAnnotate',
'Add, remove and rebuild AngularJS dependency injection annotations',

@@ -139,34 +148,54 @@

const runNgAnnotate = (mapping, options) => {
filesNum++;
const ngAnnotateOptions = cloneDeep(options.ngAnnotateOptions);
const ngAnnotateOptions = {
...options.ngAnnotateOptions,
...(options.ngAnnotateOptions.map
? {
map: {
...options.ngAnnotateOptions.map,
},
}
: {}),
};
if (ngAnnotateOptions.map) {
if (mapping.src.length > 1) {
grunt.fail.fatal('The ngAnnotate task doesn\'t support ' +
'source maps with many-to-one mappings.');
grunt.fail.fatal(
"The ngAnnotate task doesn't support " +
'source maps with many-to-one mappings.',
);
}
ngAnnotateOptions.map.inFile = getPathFromTo(mapping.dest, mapping.src[0]);
ngAnnotateOptions.map.inFile = getPathFromTo(
mapping.dest,
mapping.src[0],
);
}
// seperator for file concatenation; defaults to linefeed
const separator = typeof ngAnnotateOptions.separator === 'string' ?
ngAnnotateOptions.separator :
grunt.util.linefeed;
const separator =
typeof ngAnnotateOptions.separator === 'string'
? ngAnnotateOptions.separator
: grunt.util.linefeed;
const concatenatedSource = mapping.src
.map(file => grunt.file.read(file))
.map((file) => grunt.file.read(file))
.join(separator);
const ngAnnotateOutput = ngAnnotate(concatenatedSource, ngAnnotateOptions);
const ngAnnotateOutput = ngAnnotate(
concatenatedSource,
ngAnnotateOptions,
);
// Write the destination file.
if (ngAnnotateOutput.errors) {
grunt.log.write(`Generating "${ mapping.dest }" from: "${
mapping.src.join('", "') }"...`);
grunt.log.write(
`Generating "${mapping.dest}" from: "${mapping.src.join(
'", "',
)}"...`,
);
grunt.log.error();
ngAnnotateOutput.errors.forEach(error => {
ngAnnotateOutput.errors.forEach((error) => {
grunt.log.error(error);

@@ -180,5 +209,6 @@ });

if (ngAnnotateOptions.map && !ngAnnotateOptions.map.inline) {
ngAnnotateOutput.src +=
`\n//# sourceMappingURL=${
getPathFromTo(mapping.dest, options.sourceMap) }`;
ngAnnotateOutput.src += `\n//# sourceMappingURL=${getPathFromTo(
mapping.dest,
options.sourceMap,
)}`;
grunt.file.write(options.sourceMap, ngAnnotateOutput.map);

@@ -193,3 +223,3 @@ }

// Iterate over all specified file groups.
this.files.forEach(mapping => {
this.files.forEach((mapping) => {
if (!runNgAnnotate(mapping, options)) {

@@ -204,9 +234,12 @@ validRun = false;

} else {
grunt.log.ok(`${ filesNum + (filesNum === 1 ? ' file' : ' files')
} successfully annotated.`);
grunt.log.ok(
`${
filesNum + (filesNum === 1 ? ' file' : ' files')
} successfully annotated.`,
);
}
}
return validRun;
});
},
);
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc