1.0.0 • Published 1 year ago

nv-cli-expt-strlit v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

nv-cli-expt-strlit

  • cli-tool
  • expt all strlit in js/ts/json of a dir
  • for paramiterize a project (hoist all literal)
  • the fixed string(normally irregulable AND not well-defined) of a project is boring when do automation-generate

install

  • npm install nv-cli-expt-strlit -g

usage

    Usage: nv_cli_expt_strlit [options]
    Options:
        -p, --path            path to search ,default ./
        -m, --max_size        estimated max_size of ast-nodes ,default 20000
        -u, --suffixes        default js ts json
        -h, --help            usage

example

for example, find all string in nodejs/lib source code

        nv_cli_expt_strlit -p "../node/lib"

        will generate 3 files:
                root@dev:/opt/JS/nd18/WORK# ls -l | egrep str
                -rw-r--r--   1 root root  104712 Nov 12 10:22 str.brief.json
                -rw-r--r--   1 root root 1133599 Nov 12 10:22 str.pas.json
                -rw-r--r--   1 root root 1919232 Nov 12 10:22 str.tbl.json
                root@dev:/opt/JS/nd18/WORK#       

brief is a array of string

      ......

      "timers._unrefActive() is deprecated.",
      "timers.active() is deprecated. Please use timeout.refresh() instead.",
      "timers.enroll() is deprecated. Please use setTimeout instead.",
      "timers.unenroll() is deprecated. Please use clearTimeout instead.",
      "timers/promises",
      "tis-620",
      "tls",
      "tls.TLSSocket instead.",
      "tls.createSecurePair() is deprecated. Please use ",
      "tlsClientError",
      "tls_wrap",
      "to",
      "to '",
      "to use the '.cjs' file extension.",
      "toASCII",
      "toString",
      "toUnicode",
      "traceDeprecation",
      "traceProcessWarnings",
      "trailer",
      "trailer content",
      "trailers",
      "transfer-encoding",
      "transform.readable",
      "transform.writable",
      "transformSource",
      "transformer.readableType",
      "transformer.writableType",  
      .....               

pas is a dict

   {
       【<file-path> : {
           【<ast-path> : String】 +
       }】 +
       
   }


      "/opt/JS/nd18/lib/_http_outgoing.js": {
        "body/1/declarations/0/init/arguments/0": "internal/streams/state",
        "body/2/declarations/0/init/arguments/0": "internal/assert",
        "body/3/declarations/0/init/arguments/0": "events",
        "body/4/declarations/0/init/arguments/0": "stream",
        "body/5/declarations/0/init/arguments/0": "internal/util",
        "body/6/declarations/0/init/arguments/0": "internal/http",
        "body/7/declarations/0/init/arguments/0": "buffer",
        "body/8/declarations/0/init/arguments/0": "_http_common",
        "body/9/declarations/0/init/arguments/0": "internal/async_hooks",
        "body/10/declarations/0/init/arguments/0": "internal/errors",
        "body/11/declarations/0/init/arguments/0": "internal/validators",
        "body/12/declarations/0/init/arguments/0": "internal/util/types",
        "body/13/declarations/0/init/callee/object/arguments/0": "internal/util/debuglog",
        "body/13/declarations/0/init/arguments/0": "http",
        "body/15/declarations/0/init/arguments/0": "corked",
        "body/18/body/body/0/argument/right/right": "cookie",
       ....
      }

tbl is a array of 3-tuple

      Array<[path,ast-path,String]> 
        ...
          [
            "/opt/JS/nd18/lib/internal/modules/esm/translators.js",
            "body/36/expression/arguments/1/body/body/0/expression/arguments/0",
            "Importing JSON modules"
          ],
          [
            "/opt/JS/nd18/lib/internal/modules/esm/translators.js",
            "body/36/expression/arguments/1/body/body/1/expression/arguments/2",
            "load"
          ],
          [
            "/opt/JS/nd18/lib/internal/modules/esm/translators.js",
            "body/36/expression/arguments/1/body/body/3/declarations/0/init/test/arguments/1",
            "file:"
          ],
        ...

LICENSE

  • ISC