babel-plugin-angular-inline-template
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"globals": { | ||
"angular": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
"no-console": "off", | ||
"indent": [ | ||
"error", | ||
"tab" | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
] | ||
} | ||
} | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"globals": { | ||
"angular": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
"no-console": "off", | ||
"linebreak-style": ["error", "unix"], | ||
"semi": ["error", "always"] | ||
} | ||
} |
@@ -1,5 +0,9 @@ | ||
# Change Log | ||
# Changelog | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
### [1.2.1](https://github.com/assisrafael/babel-plugin-angular-inline-template/compare/v1.2.0...v1.2.1) (2019-07-02) | ||
<a name="1.2.0"></a> | ||
@@ -6,0 +10,0 @@ # [1.2.0](https://github.com/assisrafael/babel-plugin-angular-inline-template/compare/v1.1.0...v1.2.0) (2018-01-26) |
{ | ||
"name": "babel-plugin-angular-inline-template", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Babel plugin for inlining templates into angular 1.X components and directives", | ||
@@ -24,13 +24,14 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"@babel/runtime": "^7.4.5", | ||
"better-log": "^1.3.3", | ||
"html-minifier": "^3.5.8" | ||
"html-minifier": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"chalk": "^2.3.0", | ||
"clear": "0.0.1", | ||
"diff": "^3.4.0", | ||
"eslint": "^4.16.0", | ||
"standard-version": "^4.3.0", | ||
"@babel/core": "^7.4.5", | ||
"chalk": "^2.4.2", | ||
"clear": "^0.1.0", | ||
"diff": "^4.0.1", | ||
"eslint": "^6.0.1", | ||
"prettier": "^1.18.2", | ||
"standard-version": "^6.0.1", | ||
"watch": "^1.0.2" | ||
@@ -43,4 +44,4 @@ }, | ||
"release": "standard-version", | ||
"lint": "eslint --fix src/ test/" | ||
"lint": "prettier --write '{src,tests}/**/*.js' && eslint --fix '{src,tests}/**/*.js'" | ||
} | ||
} |
@@ -1,49 +0,53 @@ | ||
require('better-log/install'); | ||
require("better-log/install"); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const htmlMinifier = require('html-minifier'); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const htmlMinifier = require("html-minifier"); | ||
function replaceTemplateUrlWithTemplate(node, basePath) { | ||
const propertyKey = node.key; | ||
const propertyValue = node.value; | ||
const propertyKey = node.key; | ||
const propertyValue = node.value; | ||
if (propertyKey.name !== 'templateUrl') { | ||
return; | ||
} | ||
if (propertyKey.name !== "templateUrl") { | ||
return; | ||
} | ||
const templatePath = path.join(basePath, propertyValue.value); | ||
const templatePath = path.join(basePath, propertyValue.value); | ||
let templateStr; | ||
try { | ||
templateStr = fs.readFileSync(templatePath).toString(); | ||
const minifiedHtml = htmlMinifier.minify(templateStr, { | ||
collapseWhitespace: true, | ||
conservativeCollapse: true, | ||
quoteCharacter: '"', | ||
removeComments: true, | ||
removeRedundantAttributes: true | ||
}); | ||
propertyKey.name = 'template'; | ||
propertyValue.value = minifiedHtml; | ||
} catch(e) { | ||
if (e.code === 'ENOENT') { | ||
console.warn(`File not found: ${e.path}`); | ||
} | ||
} | ||
let templateStr; | ||
try { | ||
templateStr = fs.readFileSync(templatePath).toString(); | ||
const minifiedHtml = htmlMinifier.minify(templateStr, { | ||
collapseWhitespace: true, | ||
conservativeCollapse: true, | ||
quoteCharacter: '"', | ||
removeComments: true, | ||
removeRedundantAttributes: true | ||
}); | ||
propertyKey.name = "template"; | ||
propertyValue.value = minifiedHtml; | ||
} catch (e) { | ||
if (e.code === "ENOENT") { | ||
console.warn(`File not found: ${e.path}`); | ||
} | ||
} | ||
} | ||
module.exports = function() { | ||
return { | ||
visitor: { | ||
ObjectProperty(nodePath, state) { | ||
return { | ||
visitor: { | ||
ObjectProperty(nodePath, state) { | ||
// If basePath isn't specified, use the abs. file folder as base path, | ||
// to have the ability to work with relative templateUrl's | ||
const basePath = | ||
state.opts.basePath || | ||
state.file.opts.filename | ||
.split("/") | ||
.slice(0, -1) | ||
.join("/"); | ||
// If basePath isn't specified, use the abs. file folder as base path, | ||
// to have the ability to work with relative templateUrl's | ||
const basePath = state.opts.basePath || state.file.opts.filename.split('/').slice(0, -1).join('/'); | ||
replaceTemplateUrlWithTemplate(nodePath.node, basePath); | ||
} | ||
} | ||
}; | ||
replaceTemplateUrlWithTemplate(nodePath.node, basePath); | ||
} | ||
} | ||
}; | ||
}; |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
templateUrl: 'basic/template.html' | ||
}); | ||
angular.module("x").component("app", { | ||
templateUrl: "basic/template.html" | ||
}); |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
template: '<h1>Hello World</h1>' | ||
}); | ||
angular.module("x").component("app", { | ||
template: "<h1>Hello World</h1>" | ||
}); |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
templateUrl: 'file-not-found/template.html' | ||
}); | ||
angular.module("x").component("app", { | ||
templateUrl: "file-not-found/template.html" | ||
}); |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
templateUrl: 'file-not-found/template.html' | ||
}); | ||
angular.module("x").component("app", { | ||
templateUrl: "file-not-found/template.html" | ||
}); |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
templateUrl: 'multiline/template.html' | ||
}); | ||
angular.module("x").component("app", { | ||
templateUrl: "multiline/template.html" | ||
}); |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
template: '<ul> <li>Hello World!</li> </ul>' | ||
}); | ||
angular.module("x").component("app", { | ||
template: "<ul> <li>Hello World!</li> </ul>" | ||
}); |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
templateUrl: './template.html' | ||
}); | ||
angular.module("x").component("app", { | ||
templateUrl: "./template.html" | ||
}); |
@@ -1,3 +0,3 @@ | ||
angular.module('x').component('app', { | ||
template: '<h1>Hello World</h1>' | ||
}); | ||
angular.module("x").component("app", { | ||
template: "<h1>Hello World</h1>" | ||
}); |
@@ -1,91 +0,97 @@ | ||
'use strict'; | ||
"use strict"; | ||
const babel = require('babel-core'); | ||
const chalk = require('chalk'); | ||
const clear = require('clear'); | ||
const diff = require('diff'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const babel = require("@babel/core"); | ||
const chalk = require("chalk"); | ||
const clear = require("clear"); | ||
const diff = require("diff"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const pluginPath = require.resolve('../src'); | ||
const pluginPath = require.resolve("../src"); | ||
function runTests() { | ||
var testsPath = __dirname + '/fixtures/'; | ||
var testsPath = __dirname + "/fixtures/"; | ||
var exitCode = fs.readdirSync(testsPath).map(function(item) { | ||
return { | ||
path: path.join(testsPath, item), | ||
name: item, | ||
}; | ||
}).filter(function(item) { | ||
return fs.statSync(item.path).isDirectory(); | ||
}).map(runTest).reduce((acc, cur) => acc + cur, 0); | ||
var exitCode = fs | ||
.readdirSync(testsPath) | ||
.map(function(item) { | ||
return { | ||
path: path.join(testsPath, item), | ||
name: item | ||
}; | ||
}) | ||
.filter(function(item) { | ||
return fs.statSync(item.path).isDirectory(); | ||
}) | ||
.map(runTest) | ||
.reduce((acc, cur) => acc + cur, 0); | ||
return exitCode; | ||
return exitCode; | ||
} | ||
function runTest(dir) { | ||
var exitCode = 0; | ||
var output; | ||
var exitCode = 0; | ||
var output; | ||
if (dir.path === path.join(__dirname, 'fixtures', 'relative-path')) { | ||
output = babel.transformFileSync(dir.path + '/actual.js', { | ||
plugins: [ | ||
pluginPath | ||
] | ||
}); | ||
} else { | ||
output = babel.transformFileSync(dir.path + '/actual.js', { | ||
plugins: [ | ||
[pluginPath, { | ||
basePath: 'test/fixtures' | ||
}] | ||
] | ||
}); | ||
} | ||
if (dir.path === path.join(__dirname, "fixtures", "relative-path")) { | ||
output = babel.transformFileSync(dir.path + "/actual.js", { | ||
plugins: [pluginPath] | ||
}); | ||
} else { | ||
output = babel.transformFileSync(dir.path + "/actual.js", { | ||
plugins: [ | ||
[ | ||
pluginPath, | ||
{ | ||
basePath: "test/fixtures" | ||
} | ||
] | ||
] | ||
}); | ||
} | ||
var expected = fs.readFileSync(dir.path + '/expected.js', 'utf-8'); | ||
var expected = fs.readFileSync(dir.path + "/expected.js", "utf-8"); | ||
function normalizeLines(str) { | ||
return str.trimRight().replace(/\r\n/g, '\n'); | ||
} | ||
function normalizeLines(str) { | ||
return str.trimRight().replace(/\r\n/g, "\n"); | ||
} | ||
process.stdout.write(chalk.bgWhite.black(dir.name)); | ||
process.stdout.write('\n\n'); | ||
process.stdout.write(chalk.bgWhite.black(dir.name)); | ||
process.stdout.write("\n\n"); | ||
diff.diffLines(normalizeLines(output.code), normalizeLines(expected)) | ||
.forEach(function (part) { | ||
var value = part.value; | ||
if (part.added) { | ||
value = chalk.green(part.value); | ||
exitCode = 1; | ||
} else if (part.removed) { | ||
value = chalk.red(part.value); | ||
exitCode = 1; | ||
} | ||
diff | ||
.diffLines(normalizeLines(output.code), normalizeLines(expected)) | ||
.forEach(function(part) { | ||
var value = part.value; | ||
if (part.added) { | ||
value = chalk.green(part.value); | ||
exitCode = 1; | ||
} else if (part.removed) { | ||
value = chalk.red(part.value); | ||
exitCode = 1; | ||
} | ||
process.stdout.write(value); | ||
}); | ||
process.stdout.write(value); | ||
}); | ||
process.stdout.write("\n\n\n"); | ||
process.stdout.write('\n\n\n'); | ||
return exitCode; | ||
return exitCode; | ||
} | ||
if (process.argv.indexOf('--watch') >= 0) { | ||
require('watch').watchTree(__dirname + '/..', function () { | ||
delete require.cache[pluginPath]; | ||
clear(); | ||
console.log('Press Ctrl+C to stop watching...'); | ||
console.log('================================'); | ||
try { | ||
runTests(); | ||
} catch (e) { | ||
console.error(chalk.magenta(e.stack)); | ||
} | ||
}); | ||
if (process.argv.indexOf("--watch") >= 0) { | ||
require("watch").watchTree(__dirname + "/..", function() { | ||
delete require.cache[pluginPath]; | ||
clear(); | ||
console.log("Press Ctrl+C to stop watching..."); | ||
console.log("================================"); | ||
try { | ||
runTests(); | ||
} catch (e) { | ||
console.error(chalk.magenta(e.stack)); | ||
} | ||
}); | ||
} else { | ||
var exitCode = runTests(); | ||
process.exit(exitCode); | ||
} | ||
var exitCode = runTests(); | ||
process.exit(exitCode); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
9200
20
170
8
+ Added@babel/runtime@^7.4.5
+ Added@babel/runtime@7.26.0(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedhtml-minifier@4.0.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addeduglify-js@3.19.3(transitive)
- Removedbabel-runtime@^6.26.0
- Removedbabel-runtime@6.26.0(transitive)
- Removedcommander@2.17.12.19.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedhtml-minifier@3.5.21(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removeduglify-js@3.4.10(transitive)
Updatedhtml-minifier@^4.0.0