{"id":17965363,"url":"https://github.com/t2ym/target-configurator","last_synced_at":"2026-02-26T21:03:49.127Z","repository":{"id":65514575,"uuid":"294023854","full_name":"t2ym/target-configurator","owner":"t2ym","description":"Configurator base class as a custom registry for gulp","archived":false,"fork":false,"pushed_at":"2025-04-01T08:13:40.000Z","size":49,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-05T20:46:12.502Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t2ym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-09-09T06:31:53.000Z","updated_at":"2025-04-01T08:13:44.000Z","dependencies_parsed_at":"2025-06-06T19:32:16.381Z","dependency_job_id":null,"html_url":"https://github.com/t2ym/target-configurator","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/t2ym/target-configurator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Ftarget-configurator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Ftarget-configurator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Ftarget-configurator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Ftarget-configurator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t2ym","download_url":"https://codeload.github.com/t2ym/target-configurator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Ftarget-configurator/sbom","scorecard":{"id":864749,"data":{"date":"2025-08-11","repo":{"name":"github.com/t2ym/target-configurator","commit":"667aeff464992667eeda42554b28d39d27944f7b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T02:22:23.772Z","repository_id":65514575,"created_at":"2025-08-24T02:22:23.772Z","updated_at":"2025-08-24T02:22:23.772Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29872674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T21:01:59.805Z","status":"ssl_error","status_checked_at":"2026-02-26T21:00:42.555Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T12:41:54.646Z","updated_at":"2026-02-26T21:03:49.078Z","avatar_url":"https://github.com/t2ym.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/target-configurator.svg)](https://badge.fury.io/js/target-configurator)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/t2ym/target-configurator/master/docs/Transistor.svg?sanitize=true\" width=\"400px\"\u003e\n\u003c/p\u003e\n\n# target-configurator\n\n## [Example Usage in `thin-hook`](https://github.com/t2ym/thin-hook/blob/module/gulpfile.js)\n- [thin-hook Issue #386 Portable configurators for plugins to improve developer experience](https://github.com/t2ym/thin-hook/issues/386)\n\n## `gulpfile.js` - register gulp tasks\n```js\n// In package-directory/gulpfile.js\nconst gulp = require('gulp');\n\nconst targetConfig = require('./config-directory/config.js');\ngulp.registry(targetConfig); // targetConfig as custom gulp registry\n\ngulp.task('plugin-name'); // register a task configurable via source-package/plugins/plugin-name/configurator.js\n\ngulp.task('@scoped/plugin-name'); // regiter a task configurable via @scoped/plugin-name/configurator.js\n\n```\n\n## Directory Structure\n\n```\npackage-directory/\n  package.json - dev dependent on target-configurator\n  config-directory/\n    config.js - export targetConfig object\n    plugin-name/\n      plugin-specific-config.js (any types)\n    @scoped/\n      plugin-name/\n        plugin-specific-config.js (any types)\n  dest/ - destination\n    configured-source-code.js (any types) - generated by configurator.js\n    ...\n  node_modules/\n    target-configurator/\n      index.js\n    source-package/ - this can be the same as package-directory\n      package.json\n      plugins/\n        plugin-name/\n          configurator.js\n          config-source1.js (any types)\n          ...\n        plugin-name2/\n        ...\n    @scoped/\n      plugin-name/\n        package.json\n        configurator.js\n        config-source.js (any types)\n        ...\n  \n```\n\n## `config-directory/config.js` - targetConfig object for configurators\n```js\n// In package-directory/config-directory/config.js\nconst { Configurable, GulpDefaultRegistry } = require('target-configurator');\n\nclass TargetConfig extends Configurable(GulpDefaultRegistry, 'source-package') {\n  static basePath = module.parent.path; // module.parent is gulpfile.js in the base directory\n  static configPath = module.path; // Overriding configPath is safe and robust\n  pre(plugin) { // optionally confirm process.cwd() matches with the base path\n    super.pre(plugin);\n    if (this.constructor.basePath !== process.cwd()) {\n      throw new Error(`${TargetConfig1.name}: cwd ${process.cwd()} is expected to match with basePath ${this.constructor.basePath}`);\n    }\n  }\n  _configure() {\n    super._configure();\n    Object.assign(this.path, {\n      // common paths for the project\n      root: 'webroot', // this is just an example; any name with any value for the project\n      ...\n    });\n    Object.assign(this, {\n      \"plugin-name\": {\n        \"config\": \"value\",\n        ...\n      },\n      \"@scoped/plugin-name\": {\n        \"config\": \"value\",\n        ...\n      },\n    });\n  }\n}\n\nlet targetConfig = new TargetConfig();\n\nmodule.exports = targetConfig;\n```\n\n## `source-package/plugins/plugin-name/configurator.js` - configurator\n- Full-featured plugin\n```js\n// example configurator with configurable 2-pass source file generation\nconst path = require('path');\nconst { preprocess } = require('preprocess');\nconst through = require('through2');\n\nconst pluginName = 'policy';\n\nconst init = function (targetConfig) {\n  // init for the plugin\n}\n\nconst configurator = function (targetConfig) {\n  const configPath = path.resolve(this.path.base, this.path.config, pluginName);\n  const destPath = path.resolve(this.path.base, this.path.root);\n  const enableDebugging = this.mode.enableDebugging;\n  const pluginDirname = __dirname;\n  const sourceFile = this[pluginName] \u0026\u0026 this[pluginName].sourceFile\n    ? this[pluginName].sourceFile\n    : 'hook-callback.js';\n  return () =\u003e this.gulp.src([ path.resolve(pluginDirname, sourceFile) ])\n    // 1st pass\n    .pipe(through.obj((file, enc, callback) =\u003e {\n      let script = String(file.contents);\n      script = preprocess(script,\n        {\n          SPACE: ' ',\n          EQUAL: '=',\n          SEMICOLON: ';',\n          enableDebugging: typeof enableDebugging === 'undefined' ? 'false' : enableDebugging,\n        },\n        {\n          type: 'js',\n          srcDir: pluginDirname, // in plugins/policy/\n        }\n      );\n      script = script.replace(/\\/\\* #include /g, '/* @include ');\n      file.contents = Buffer.from(script);\n      callback(null, file);\n    }))\n    // 2nd pass\n    .pipe(through.obj((file, enc, callback) =\u003e {\n      let script = String(file.contents);\n      script = preprocess(script,\n        {\n          SPACE: ' ',\n          EQUAL: '=',\n          SEMICOLON: ';',\n        },\n        {\n          type: 'js',\n          srcDir: configPath, // in demo-config/policy/\n        }\n      );\n      file.contents = Buffer.from(script);\n      callback(null, file);\n    }))\n    .pipe(this.gulp.dest(destPath));\n}\n\nmodule.exports = {\n  init,\n  configurator,\n  name: pluginName,\n  dependencies: [],\n};\n```\n\n- Shortcut plugin exporting a task function directly\n```js\nconst fs = require('fs');\nmodule.exports = function cwd_plugin (done) { // Arrow functions are not supported\n  // cwd is gurranteed to be this.path.base in overridden this.pre()\n  console.log(cwd_plugin.name, this.path, JSON.parse(fs.readFileSync(`${this.path.config}/${cwd_plugin.name}/cwd_plugin-config.json`))['cwd_plugin-config']);\n  done();\n}\n```\n\n- Shortcut plugin exporting a task function with options\n```js\nconst path = require('path');\n\nconst pluginName = 'shortcut-plugin-2';\n\nmodule.exports = Object.assign(function shortcut_plugin2 (done) {\n  console.log(pluginName, this.path, require(path.resolve(this.path.base, this.path.config, pluginName, 'shortcut-plugin-2-config.js'))['shortcut-plugin-2-config']);\n  done();\n}, {\n  displayName: pluginName,\n  dependencies: [ 'shortcut_plugin1' ],\n});\n```\n\n# License\n\n[BSD-2-Clause](https://github.com/t2ym/target-configurator/blob/master/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft2ym%2Ftarget-configurator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft2ym%2Ftarget-configurator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft2ym%2Ftarget-configurator/lists"}