@netlify/framework-info
Advanced tools
Comparing version 0.3.2 to 1.0.0
@@ -10,2 +10,13 @@ # Changelog | ||
## [1.0.0](https://www.github.com/netlify/framework-info/compare/v0.3.2...v1.0.0) (2020-12-15) | ||
### ⚠ BREAKING CHANGES | ||
* remove ignoredWatchCommand option (#59) | ||
### Code Refactoring | ||
* remove ignoredWatchCommand option ([#59](https://www.github.com/netlify/framework-info/issues/59)) ([defd809](https://www.github.com/netlify/framework-info/commit/defd80956006a0b3ff65e265115d662c4bd8b679)) | ||
## [v0.3.2](https://github.com/netlify/framework-info/compare/v0.3.1...v0.3.2) | ||
@@ -12,0 +23,0 @@ |
{ | ||
"name": "@netlify/framework-info", | ||
"version": "0.3.2", | ||
"version": "1.0.0", | ||
"description": "Framework detection utility", | ||
@@ -15,3 +15,2 @@ "main": "./src/main.js", | ||
"scripts": { | ||
"prepublishOnly": "git push && git push --tags && gh-release", | ||
"test": "npm run format && npm run test:dev", | ||
@@ -27,6 +26,3 @@ "format": "run-s format:check-fix:*", | ||
"test:dev": "ava", | ||
"test:ci": "nyc -r lcovonly -r text -r json ava", | ||
"changelog:create": "auto-changelog -p --template keepachangelog --breaking-pattern breaking", | ||
"changelog:add": "git add CHANGELOG.md", | ||
"version": "run-s changelog:create format:fix:* changelog:add" | ||
"test:ci": "nyc -r lcovonly -r text -r json ava" | ||
}, | ||
@@ -70,3 +66,3 @@ "husky": { | ||
"eslint": "--ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"src/**/*.js\" \"test/*.js\" \"test/helpers/**/*.js\"", | ||
"prettier": "--ignore-path .gitignore --loglevel warn \"{src,test}/**/*.js\" \"*.{js,md,yml,json}\" \"!package-lock.json\"" | ||
"prettier": "--ignore-path .gitignore --loglevel warn \"{src,test}/**/*.js\" \"*.{js,md,yml,json}\" \"!package-lock.json\" \"!CHANGELOG.md\"" | ||
}, | ||
@@ -73,0 +69,0 @@ "dependencies": { |
@@ -112,8 +112,2 @@ [![npm version](https://img.shields.io/npm/v/@netlify/framework-info.svg)](https://npmjs.org/package/@netlify/framework-info) | ||
#### ignoredWatchCommand | ||
_Type_: `string` | ||
When detecting the watch command, ignore `package.json` `scripts` whose value includes this string. | ||
### Return value | ||
@@ -196,3 +190,2 @@ | ||
- `--long`: Show more information about each framework. The output will be a JSON array. | ||
- `--ignoredWatchCommand string` | ||
@@ -199,0 +192,0 @@ # Add or update a framework |
@@ -10,6 +10,6 @@ #!/usr/bin/env node | ||
const runCli = async function () { | ||
const { projectDir, long, ignoredWatchCommand } = parseArgs() | ||
const { projectDir, long } = parseArgs() | ||
try { | ||
const frameworks = await listFrameworks({ projectDir, ignoredWatchCommand }) | ||
const frameworks = await listFrameworks({ projectDir }) | ||
const frameworksStr = serializeFrameworks(frameworks, long) | ||
@@ -34,6 +34,2 @@ console.log(frameworksStr) | ||
}, | ||
ignoredWatchCommand: { | ||
string: true, | ||
describe: 'When detecting the watch command, ignore `package.json` `scripts` whose value includes this string.', | ||
}, | ||
} | ||
@@ -40,0 +36,0 @@ |
@@ -13,3 +13,2 @@ const pFilter = require('p-filter') | ||
* @property {string} [projectDir=process.cwd()] - Project's directory | ||
* @property {string} [ignoredWatchCommand] - When guessing the watch command, ignore `package.json` `scripts` whose value includes this string | ||
*/ | ||
@@ -40,4 +39,4 @@ | ||
const listFrameworks = async function (opts) { | ||
const { projectDir, ignoredWatchCommand } = getOptions(opts) | ||
const { npmDependencies, scripts, runScriptCommand } = await getProjectInfo({ projectDir, ignoredWatchCommand }) | ||
const { projectDir } = getOptions(opts) | ||
const { npmDependencies, scripts, runScriptCommand } = await getProjectInfo({ projectDir }) | ||
const frameworks = await pFilter(FRAMEWORKS, (framework) => usesFramework(framework, { projectDir, npmDependencies })) | ||
@@ -58,4 +57,4 @@ const frameworkInfos = frameworks.map((framework) => getFrameworkInfo(framework, { scripts, runScriptCommand })) | ||
const framework = getFrameworkByName(frameworkName) | ||
const { projectDir, ignoredWatchCommand } = getOptions(opts) | ||
const { npmDependencies } = await getProjectInfo({ projectDir, ignoredWatchCommand }) | ||
const { projectDir } = getOptions(opts) | ||
const { npmDependencies } = await getProjectInfo({ projectDir }) | ||
const result = await usesFramework(framework, { projectDir, npmDependencies }) | ||
@@ -75,4 +74,4 @@ return result | ||
const framework = getFrameworkByName(frameworkName) | ||
const { projectDir, ignoredWatchCommand } = getOptions(opts) | ||
const { scripts, runScriptCommand } = await getProjectInfo({ projectDir, ignoredWatchCommand }) | ||
const { projectDir } = getOptions(opts) | ||
const { scripts, runScriptCommand } = await getProjectInfo({ projectDir }) | ||
const frameworkInfo = getFrameworkInfo(framework, { scripts, runScriptCommand }) | ||
@@ -95,4 +94,4 @@ return frameworkInfo | ||
const getProjectInfo = async function ({ projectDir, ignoredWatchCommand }) { | ||
const { packageJsonPath, npmDependencies, scripts } = await getPackageJsonContent({ projectDir, ignoredWatchCommand }) | ||
const getProjectInfo = async function ({ projectDir }) { | ||
const { packageJsonPath, npmDependencies, scripts } = await getPackageJsonContent({ projectDir }) | ||
const runScriptCommand = await getRunScriptCommand({ projectDir, packageJsonPath }) | ||
@@ -99,0 +98,0 @@ return { npmDependencies, scripts, runScriptCommand } |
const process = require('process') | ||
// Retrieve main options | ||
const getOptions = function ({ projectDir = process.cwd(), ignoredWatchCommand } = {}) { | ||
return { projectDir, ignoredWatchCommand } | ||
const getOptions = function ({ projectDir = process.cwd() } = {}) { | ||
return { projectDir } | ||
} | ||
module.exports = { getOptions } |
@@ -7,3 +7,3 @@ const filterObj = require('filter-obj') | ||
// `dependencies|devDependencies` and `scripts` fields | ||
const getPackageJsonContent = async function ({ projectDir, ignoredWatchCommand }) { | ||
const getPackageJsonContent = async function ({ projectDir }) { | ||
const { packageJson, packageJsonPath } = await getPackageJson(projectDir) | ||
@@ -15,3 +15,3 @@ if (packageJson === undefined) { | ||
const npmDependencies = getNpmDependencies(packageJson) | ||
const scripts = getScripts(packageJson, ignoredWatchCommand) | ||
const scripts = getScripts(packageJson) | ||
return { packageJsonPath, npmDependencies, scripts } | ||
@@ -53,3 +53,3 @@ } | ||
// Retrieve `package.json` `scripts` | ||
const getScripts = function ({ scripts }, ignoredWatchCommand) { | ||
const getScripts = function ({ scripts }) { | ||
if (!isPlainObj(scripts)) { | ||
@@ -60,4 +60,3 @@ return {} | ||
const scriptsA = filterObj(scripts, isValidScript) | ||
const scriptsB = removeIgnoredWatchCommand(scriptsA, ignoredWatchCommand) | ||
return scriptsB | ||
return scriptsA | ||
} | ||
@@ -69,11 +68,2 @@ | ||
// Exclude any script that includes `ignoredWatchCommand` | ||
const removeIgnoredWatchCommand = function (scripts, ignoredWatchCommand) { | ||
if (ignoredWatchCommand === undefined) { | ||
return scripts | ||
} | ||
return filterObj(scripts, (key, value) => !value.includes(ignoredWatchCommand)) | ||
} | ||
module.exports = { getPackageJsonContent } |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
36823
708
288