cfpathcheck
Advanced tools
Comparing version 5.2.0 to 5.2.1
#!/usr/bin/env node | ||
import minimist from 'minimist'; | ||
import { check, formatter, writeOutput, writeFile } from '../lib/cfpathcheck.js'; | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
const cfpathcheck = require('../lib/cfpathcheck'); | ||
const argv = minimist(process.argv.slice(2)); | ||
/** | ||
@@ -26,9 +25,9 @@ * Everything in the file should be customized. | ||
*/ | ||
const violations = check(file, 'json'); | ||
const output = formatter(violations, reporter); | ||
const violations = cfpathcheck.check(file, 'json'); | ||
const output = cfpathcheck.formatter(violations, reporter); | ||
writeOutput(output); | ||
cfpathcheck.writeOutput(output); | ||
if (outFile) { | ||
writeFile(formatter(violations, 'checkstyle'), outFile); | ||
cfpathcheck.writeFile(cfpathcheck.formatter(violations, 'checkstyle'), outFile); | ||
} |
@@ -5,2 +5,16 @@ # Change Log | ||
## [5.2.1] - 2023-03-22 | ||
### Added | ||
- nodejs v12.0, v12.17 test runs | ||
- nodejs support >=12.0.0 | ||
### Updated | ||
- Minimum nodejs version now 12.0.0 | ||
- All components converted back to CommonJS to work on nodejs >=12.0.0 | ||
- chalk@4.1.2 | ||
- log-symbols@4.1.0 | ||
- eslint@7.32.0 | ||
- eslint-config-xo@0.39.0 | ||
- mocha@9.2.2 | ||
## [5.2.0] - 2023-03-11 | ||
@@ -7,0 +21,0 @@ ### Added |
@@ -1,10 +0,11 @@ | ||
import { readFileSync, existsSync, readdirSync, writeFileSync } from 'fs'; | ||
import path from 'path'; | ||
import glob from 'glob'; | ||
import checkstyleFormatter from 'checkstyle-formatter'; | ||
import chalk from 'chalk'; | ||
import logSymbols from 'log-symbols'; | ||
import { containsObject, checkIsXMLFile, matchAll } from './utils.js'; | ||
'use strict'; | ||
const { sync } = glob; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
const checkstyleFormatter = require('checkstyle-formatter'); | ||
const chalk = require('chalk'); | ||
const logSymbols = require('log-symbols'); | ||
const utils = require('./utils'); | ||
/** | ||
@@ -18,3 +19,3 @@ * Compares two arrays of cfml taglib prefixes to see if there are any mismatches. | ||
*/ | ||
export const comparePrefixArrays = (prefixArray1, prefixArray2, message, severity) => { | ||
const comparePrefixArrays = (prefixArray1, prefixArray2, message, severity) => { | ||
const prefixedViolations = {}; | ||
@@ -53,3 +54,3 @@ const prefixManifest = {}; | ||
if (!containsObject(messageObject, prefixedViolations[value.prefix])) { | ||
if (!utils.containsObject(messageObject, prefixedViolations[value.prefix])) { | ||
prefixedViolations[value.prefix].push(messageObject); | ||
@@ -67,3 +68,3 @@ } | ||
}; | ||
if (!containsObject(messageObject, prefixedViolations[value.prefix])) { | ||
if (!utils.containsObject(messageObject, prefixedViolations[value.prefix])) { | ||
prefixedViolations[value.prefix].push(messageObject); | ||
@@ -93,3 +94,3 @@ } | ||
*/ | ||
export const readFile = (filePath) => readFileSync(filePath, 'utf8').replace(/\r\n/, '\n'); | ||
const readFile = (filePath) => fs.readFileSync(filePath, 'utf8').replace(/\r\n/, '\n'); | ||
@@ -100,3 +101,3 @@ /** | ||
*/ | ||
export const checkFile = (filePath) => { | ||
const checkFile = (filePath) => { | ||
const templatePathViolations = []; | ||
@@ -115,3 +116,3 @@ const taglibPathViolations = []; | ||
for (const line of lines) { | ||
isXMLFile = checkIsXMLFile(line); | ||
isXMLFile = utils.checkIsXMLFile(line); | ||
@@ -131,3 +132,3 @@ // Exclude @usage doc lines including code snippets | ||
const namespaceSearch = matchAll(line, /<(?<namespace>[A-Za-z\d]+):/g); | ||
const namespaceSearch = utils.matchAll(line, /<(?<namespace>[A-Za-z\d]+):/g); | ||
@@ -145,3 +146,3 @@ // We're outputting an XML file - don't attempt to collate namespace prefix usages | ||
const taglibMatches = matchAll(line, /taglib=["'](?<taglib>[^"']+)["']/g); | ||
const taglibMatches = utils.matchAll(line, /taglib=["'](?<taglib>[^"']+)["']/g); | ||
@@ -154,3 +155,3 @@ for (const taglibMatch of taglibMatches) { | ||
if (!existsSync(taglibPath)) { | ||
if (!fs.existsSync(taglibPath)) { | ||
taglibPathViolations.push({ | ||
@@ -166,6 +167,6 @@ line: lineNumber, | ||
// Checks <cfinclude template="$path" /> | ||
const cfIncludeMatches = matchAll(line, /template=["'](?<path>[^"']+)["']/g); | ||
const cfIncludeMatches = utils.matchAll(line, /template=["'](?<path>[^"']+)["']/g); | ||
// Checks include '$path'; (inside <cfscript>) | ||
const includeMatches = matchAll(line, /\binclude\s['"](?<path>.*\.cfm)['"]/g); | ||
const includeMatches = utils.matchAll(line, /\binclude\s['"](?<path>.*\.cfm)['"]/g); | ||
@@ -191,3 +192,3 @@ for (const includeMatch of [...cfIncludeMatches, ...includeMatches]) { | ||
if (!existsSync(templatePath)) { | ||
if (!fs.existsSync(templatePath)) { | ||
templatePathViolations.push({ | ||
@@ -228,3 +229,3 @@ line: lineNumber, | ||
export const getFiles = (filePath) => { | ||
const getFiles = (filePath) => { | ||
let fileNames = []; | ||
@@ -238,6 +239,6 @@ | ||
// The path exists... | ||
if (existsSync(filePath)) { | ||
if (fs.existsSync(filePath)) { | ||
try { | ||
// ...try a readdirSync and... | ||
readdirSync(filePath); | ||
fs.readdirSync(filePath); | ||
@@ -249,3 +250,3 @@ // (Add a trailing slash if not present) | ||
fileNames = sync(`${filePath}**/*.cfm`, { | ||
fileNames = glob.sync(`${filePath}**/*.cfm`, { | ||
ignore: ['**/WEB-INF/**', '**/node_modules/**'], | ||
@@ -265,3 +266,3 @@ }); | ||
*/ | ||
export const check = (filePath) => { | ||
const check = (filePath) => { | ||
const violations = []; | ||
@@ -289,3 +290,3 @@ const fileNames = getFiles(filePath); | ||
*/ | ||
export const formatter = (violations, format) => format === 'checkstyle' | ||
const formatter = (violations, format) => format === 'checkstyle' | ||
? checkstyleFormatter(violations) | ||
@@ -298,3 +299,3 @@ : violations; | ||
*/ | ||
export const writeFile = (output, outFile) => { | ||
const writeFile = (output, outFile) => { | ||
// Resolve the path if it's not absolute | ||
@@ -306,4 +307,4 @@ if (!path.isAbsolute(outFile)) { | ||
// Warn that the target directory doesn't exist | ||
if (existsSync(path.dirname(outFile))) { | ||
writeFileSync(outFile, output, 'utf8'); | ||
if (fs.existsSync(path.dirname(outFile))) { | ||
fs.writeFileSync(outFile, output, 'utf8'); | ||
} else { | ||
@@ -317,3 +318,3 @@ console.warn(`Cannot write ${outFile}. Destination directory doesn’t exist`); | ||
*/ | ||
export const writeOutput = (output) => { | ||
const writeOutput = (output) => { | ||
if (Array.isArray(output)) { | ||
@@ -337,1 +338,12 @@ for (const violation of output) { | ||
}; | ||
module.exports = { | ||
comparePrefixArrays, | ||
check, | ||
checkFile, | ||
formatter, | ||
getFiles, | ||
readFile, | ||
writeFile, | ||
writeOutput, | ||
}; |
@@ -1,2 +0,2 @@ | ||
import deepEqual from 'deep-equal'; | ||
const deepEqual = require('deep-equal'); | ||
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
export const containsObject = (targetObject, list) => list.some(item => deepEqual(item, targetObject)); | ||
const containsObject = (targetObject, list) => list.some(item => deepEqual(item, targetObject)); | ||
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
export const checkIsXMLFile = (line) => { | ||
const checkIsXMLFile = (line) => { | ||
const regexp = /<\?xml|type="text\/xml/; | ||
@@ -31,3 +31,3 @@ const xmlSearch = line.match(regexp); | ||
*/ | ||
export const matchAll = (matchString, regex) => { | ||
const matchAll = (matchString, regex) => { | ||
const result = []; | ||
@@ -45,1 +45,7 @@ let m; | ||
}; | ||
module.exports = { | ||
checkIsXMLFile, | ||
containsObject, | ||
matchAll, | ||
}; |
{ | ||
"name": "cfpathcheck", | ||
"type": "module", | ||
"description": "Check CFML files for correct paths in cfinclude/cfimport tags", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"homepage": "https://github.com/timbeadle/cfpathcheck", | ||
@@ -35,3 +34,3 @@ "author": { | ||
"engines": { | ||
"node": ">= 12.17" | ||
"node": ">= 12" | ||
}, | ||
@@ -51,3 +50,3 @@ "scripts": { | ||
"@snyk/protect": "^1.1117.0", | ||
"chalk": "^5.2.0", | ||
"chalk": "^4.1.2", | ||
"checkstyle-formatter": "^1.1.0", | ||
@@ -57,3 +56,3 @@ "crlf": "^1.1.1", | ||
"glob": "^8.1.0", | ||
"log-symbols": "^5.1.0", | ||
"log-symbols": "^4.1.0", | ||
"minimist": "^1.2.8" | ||
@@ -69,7 +68,7 @@ }, | ||
"chai": "^4.3.7", | ||
"eslint": "^8.36.0", | ||
"eslint-config-xo": "^0.43.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-xo": "^0.39.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"ls-engines": "^0.8.1", | ||
"mocha": "^10.2.0", | ||
"mocha": "^9.2.2", | ||
"npm-run-all": "^4.1.5", | ||
@@ -81,5 +80,5 @@ "nyc": "^15.1.0", | ||
"volta": { | ||
"node": "12.22.12", | ||
"npm": "6.14.18" | ||
"node": "12.0.0", | ||
"npm": "7.24.2" | ||
} | ||
} |
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
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
966820
343
No
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
- Removedchalk@5.3.0(transitive)
- Removedis-unicode-supported@1.3.0(transitive)
- Removedlog-symbols@5.1.0(transitive)
Updatedchalk@^4.1.2
Updatedlog-symbols@^4.1.0