{"id":15690948,"url":"https://github.com/sanusart/grunt-dev-prod-switch","last_synced_at":"2025-10-06T13:40:49.596Z","repository":{"id":9513236,"uuid":"11409545","full_name":"sanusart/grunt-dev-prod-switch","owner":"sanusart","description":"Use to switch between previously defined comment blocks in project files to change environment from development to production and back.","archived":false,"fork":false,"pushed_at":"2015-09-24T04:22:31.000Z","size":196,"stargazers_count":8,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-22T20:15:11.574Z","etag":null,"topics":["grunt","grunt-plugins","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sanusart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-14T21:20:57.000Z","updated_at":"2017-02-27T09:56:07.000Z","dependencies_parsed_at":"2022-09-12T15:02:05.550Z","dependency_job_id":null,"html_url":"https://github.com/sanusart/grunt-dev-prod-switch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sanusart/grunt-dev-prod-switch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanusart%2Fgrunt-dev-prod-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanusart%2Fgrunt-dev-prod-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanusart%2Fgrunt-dev-prod-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanusart%2Fgrunt-dev-prod-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanusart","download_url":"https://codeload.github.com/sanusart/grunt-dev-prod-switch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanusart%2Fgrunt-dev-prod-switch/sbom","scorecard":{"id":800144,"data":{"date":"2025-08-11","repo":{"name":"github.com/sanusart/grunt-dev-prod-switch","commit":"26b4e3c459f820a189da05b990f629ef5c80212e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"Code-Review","score":0,"reason":"Found 2/21 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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE-MIT:0","Info: FSF or OSI recognized license: MIT License: LICENSE-MIT:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T10:12:56.151Z","repository_id":9513236,"created_at":"2025-08-23T10:12:56.151Z","updated_at":"2025-08-23T10:12:56.151Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621847,"owners_count":26017253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["grunt","grunt-plugins","javascript"],"created_at":"2024-10-03T18:17:58.963Z","updated_at":"2025-10-06T13:40:49.578Z","avatar_url":"https://github.com/sanusart.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-dev-prod-switch\n\n[![NPM](https://nodei.co/npm/grunt-dev-prod-switch.png)](https://nodei.co/npm/grunt-dev-prod-switch/)\n\n\u003e Use to switch between previously defined comment blocks in project files to change environment from development to production and back.\n\n## Getting Started\nThis plugin requires Grunt `~0.4.1`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-dev-prod-switch --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-dev-prod-switch');\n```\n\n## The \"dev_prod_switch\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `dev_prod_switch` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n    \n...\n    \n    dev_prod_switch: {\n        options: {\n            environment: 'dev',\n            env_char: '#',\n            env_block_dev: 'env:dev',\n            env_block_prod: 'env:prod'\n        },\n        all: {\n            files: {\n                'app/index.html': 'app/index.html',\n                'app/js/main.js': 'app/js/main.js'\n            }\n        }\n    }\n    \n...\n    \n});\n```\n\nOr \n\n```js\ngrunt.initConfig({\n    \n...\n    \n    dev_prod_switch: {\n        options: {\n            // Can be ran as `grunt --env=dev` or ``grunt --env=prod``\n            environment: grunt.option('env') || 'dev', // 'prod' or 'dev'\n            env_char: '#',\n            env_block_dev: 'env:dev',\n            env_block_prod: 'env:prod'\n        },\n        dynamic_mappings: {\n            files: [{\n                expand: true,\n                cwd: './',\n                src: ['*.html'],\n                dest: './'\n            }]\n        }\n    }\n\n...\n    \n});\n```\n\nIn _html_ or _ColdFusion_ type of files place the code depending on environment as follows:\n\n```\n...\n\n\u003c!-- env:dev --\u003e\n    \u003ch1\u003eFor devs eyes only\u003c/h1\u003e\n    \u003cp\u003eThis will be visable in 'dev' environment\u003c/p\u003e\n\u003c!-- env:dev:end --\u003e\n\n\n\u003c!-- env:prod --\u003e\n    \u003ch1\u003eFor everyone\u003c/h1\u003e\n    \u003cp\u003eThis will be visable in 'prod' environment\u003c/p\u003e\n\u003c!-- env:prod:end --\u003e\n\n...\n\n```\n\nIn _C_, _Java_, _JavaScript_ type of files place the code depending on environment as follows:\n\n```\n...\n\n/* env:dev */\n    function add(a,b) { \n        console.log('ADD: ' + a + ' + ' + b + ' = ' + (a + b));\n        return a+b;\n    }\n/* env:dev:end */\n\n\n/* env:prod */\n    function add(a,b) { \n        return a+b;\n    }\n/* env:prod:end */\n\n...\n\n```\n\n### Using in Gulp without plug-in\n\n```js\n\n// Options to switch environment (dev/prod)\nvar env_option = {\n    env_dev: 'env:dev',\n    env_prod: 'env:prod',\n    blocking_char: '#'\n};\n\n/**\n * dev\n *\n * Change environment to \"development\"\n * Use: gulp dev\n */\ngulp.task('dev', function() {\n    var files = [\n        './app/index.html'\n    ];\n    files.forEach(function(file) {\n        var content = fs.readFileSync(file, \"utf8\")\n            .replace(new RegExp(\"\u003c\\!-- \" + env_option.env_dev + \" --\" + env_option.blocking_char + \"\u003e\",\"gi\"), '\u003c!-- ' + env_option.env_dev + ' --\u003e')\n            .replace(new RegExp(\"\u003c\\!-- \" + env_option.env_prod + \" --\u003e\",\"gi\"), '\u003c!-- ' + env_option.env_prod + ' --' + env_option.blocking_char + '\u003e')\n            .replace(new RegExp(\"\\/\\* \" + env_option.env_dev + \" \\*\" + env_option.blocking_char + '/',\"gi\"), '/* ' + env_option.env_dev + ' */')\n            .replace(new RegExp(\"\\/\\* \" + env_option.env_prod + \" \\*\\/\",\"gi\"), '/* ' + env_option.env_prod + ' *' + env_option.blocking_char + '/');\n        fs.writeFileSync(file, content);\n    });\n});\n\n/**\n * prod\n *\n * Change environment to \"production\"\n * Use: gulp prod\n */\ngulp.task('prod', [], function() {\n    var files = [\n        './app/index.html'\n    ];\n    files.forEach(function(file) {\n        var content = fs.readFileSync(file, \"utf8\")\n            .replace(new RegExp(\"\u003c\\!-- \" + env_option.env_prod + \" --\" + env_option.blocking_char + \"\u003e\",\"gi\"), '\u003c!-- ' + env_option.env_prod + ' --\u003e')\n            .replace(new RegExp(\"\u003c\\!-- \" + env_option.env_dev + \" --\u003e\",\"gi\"), '\u003c!-- ' + env_option.env_dev + ' --' + env_option.blocking_char + '\u003e')\n            .replace(new RegExp(\"\\/\\* \" + env_option.env_prod + \" \\*\" + env_option.blocking_char + '/',\"gi\"), '/* ' + env_option.env_prod + ' */')\n            .replace(new RegExp(\"\\/\\* \" + env_option.env_dev + \" \\*\\/\",\"gi\"), '/* ' + env_option.env_dev + ' *' + env_option.blocking_char + '/');\n        fs.writeFileSync(file, content);\n    });\n});\n```\n\n### Options\n\n#### options.environment _(requered)_\nType: `String`\nDefault value: NONE\n\nA string value that is used to do define the environment.\n\n#### options.env_char _(optional)_\nType: `String`\nDefault value: '#'\n\nDefault character to block the comment.\n\n#### options.env_block_dev _(optional)_\nType: `String`\nDefault value: 'env:dev'\n\nOverride the default string of the comment. \nSo the task will be searching for `\u003c!-- env:dev --\u003e` comment blocks\n\n#### options.env_block_prod _(optional)_\nType: `String`\nDefault value: 'env:prod'\n\nOverride the default string of the comment. \nSo the task will be searching for `\u003c!-- env:prod --\u003e` comment blocks","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanusart%2Fgrunt-dev-prod-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanusart%2Fgrunt-dev-prod-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanusart%2Fgrunt-dev-prod-switch/lists"}