npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ffc-code-refs-core

v1.0.25

Published

Scan folders and find stale feature flags

Downloads

4

Readme

ffc-code-refs-core

This is a command line util for generating flag code references when using the feature-flags.co SaaS or Standalone project.

Install

Use npm to install the package into your project

npm install ffc-code-refs-core --save-dev

In your package.json file, add the following command:

{
  "scripts": {
    "ffc-code-refs": "code-refs"
  }
}

Add to the root directory of your project, a file ffcconfig.json with following content:

{
    "envSecret": "",
    "apiUrl": "",
    "excluded": [],
    "fileExtensions": [],
    "numberOfContextLines": 0,
    "exitWithErrorWhenStaleFeatureFlagFound": false,
    "logErrorOnly": true
}
  • envSecret: the secret of your environment, can be found in your SaaS account, mandatory
  • apiUrl: the server url, can be empty if you are using our SaaS platform, not mandatory
  • entry: then entry point, can be a list of relative or absolute paths, current path would be used if not provided not mandatory
  • excluded: list of excluded file or directory, put the file or directory name only, path is not expected, not mandatory
  • fileExtensions: the file extensions that you want to be scanned, if empty, all files will be scanned, not mandatory
  • numberOfContextLines: the number of lines before and after that will be included into the report, the default value is 0, not mandatory
  • exitWithErrorWhenStaleFeatureFlagFound: if true, will exit with error when any stale feature flag is found, the default value is true, not mandatory
  • logErrorOnly: will print error logs only if true, the default value is false, not mandatory

If you want to specify a config file with different name or in a different position, you can add a parameter when running the command

{
  "scripts": {
    "ffc-code-refs": "code-refs --config path/to/your/config/file"
  }
}

Run

npm run ffc-code-refs

or directly without adding scripts in your package.json file

npx code-refs

Deal with false positive cases

Sometimes the same method name of the SDK may be used in the project, this would result to false positive cases, to avoid this, we can add ffcscan comment to ingore one line or disable a block of code, for example

// ffcscan ignore
const myvar = abc.variation("abc");

the above comment would ignore the line directly below the comment.

// ffcscan disable
const myvar = abc.variation("abc");
if (myvar) {
  continue;
}
// ffcscan enable

The above comments will ignore all the code between them.

Note

Currently, in your project, when getting the feature flag value, the method and parameters must be on the same line in order to be recognized by the util, for example

FFCJsClient.variation('featureFlagKey', 'defaultResult');

will work, but

FFCJsClient.variation(
  'featureFlagKey', 
  'defaultResult'
);

won't work