{"name":"gh-pages","version":"6.3.0","keywords":["git","gh-pages","github"],"author":{"url":"http://tschaub.net/","name":"Tim Schaub"},"license":"MIT","_id":"gh-pages@6.3.0","maintainers":[{"name":"markdalgleish","email":"mark.john.dalgleish@gmail.com"},{"name":"tschaub","email":"tim.schaub@gmail.com"}],"homepage":"https://github.com/tschaub/gh-pages","bugs":{"url":"https://github.com/tschaub/gh-pages/issues"},"bin":{"gh-pages":"bin/gh-pages.js","gh-pages-clean":"bin/gh-pages-clean.js"},"dist":{"shasum":"a5b9476dd4385ceaf85c6467b2e05397093e7613","tarball":"http://registry-npm.ywwl.com/gh-pages/download/gh-pages-6.3.0.tgz","fileCount":8,"integrity":"sha512-Ot5lU6jK0Eb+sszG8pciXdjMXdBJ5wODvgjR+imihTqsUWF2K6dJ9HST55lgqcs8wWcw6o6wAsUzfcYRhJPXbA==","signatures":[{"sig":"MEQCIF3R9zqBvtmx9TQXjXQTQlXBUx9WFqVXoLTtFhcyOU1qAiBPV4HFFYsVFwobVCMlPM7iB2MK0FtoFkWgXqGJCXX2Yg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39793,"size":12137,"noattachment":false,"key":"/gh-pages/-/gh-pages-6.3.0.tgz"},"main":"lib/index.js","engines":{"node":">=10"},"gitHead":"ed6cd8e2a43833b479262bb7237078b03a6bb7d2","scripts":{"lint":"eslint lib test bin plugin.js","test":"mocha --recursive test","pretest":"npm run lint"},"_npmUser":{"name":"tschaub","email":"tim.schaub@gmail.com"},"repository":{"url":"git://github.com/tschaub/gh-pages.git","type":"git"},"_npmVersion":"10.9.0","description":"Publish to a gh-pages branch on GitHub (or any other branch on any other remote)","directories":{},"_nodeVersion":"23.2.0","dependencies":{"async":"^3.2.4","globby":"^11.1.0","fs-extra":"^11.1.1","commander":"^13.0.0","filenamify":"^4.3.0","find-cache-dir":"^3.3.1","email-addresses":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tmp":"^0.2.1","chai":"^4.3.7","mocha":"^11.0.1","sinon":"^19.0.2","eslint":"^9.16.0","dir-compare":"^5.0.0","eslint-config-tschaub":"^15.2.0"},"_npmOperationalInternal":{"tmp":"tmp/gh-pages_6.3.0_1735838069866_0.6008643357138632","host":"s3://npm-registry-packages-npm-production"},"readme":"\n# gh-pages\n\nPublish files to a `gh-pages` branch on GitHub (or any other branch anywhere else).\n\n## Getting Started\n\n```shell\nnpm install gh-pages --save-dev\n```\n\nThis module requires Git >= 1.9 and Node > 14.\n\n## Basic Usage\n\n```js\nvar ghpages = require('gh-pages');\n\nghpages.publish('dist', function(err) {});\n```\n\n\n## `publish`\n\n```js\nghpages.publish(dir, callback);\n// or...\nghpages.publish(dir, options, callback);\n```\n\nCalling this function will create a temporary clone of the current repository, create a `gh-pages` branch if one doesn't already exist, copy over all files from the base path, or only those that match patterns from the optional `src` configuration, commit all changes, and push to the `origin` remote.\n\nIf a `gh-pages` branch already exists, it will be updated with all commits from the remote before adding any commits from the provided `src` files.\n\n**Note** that any files in the `gh-pages` branch that are *not* in the `src` files **will be removed**.  See the [`add` option](#optionsadd) if you don't want any of the existing files removed.\n\n\n### <a id=\"dir\">`dir`</a>\n* type: `string`\n\nThe base directory for all source files (those listed in the `src` config property).\n\nExample use:\n\n```js\n/**\n * Given the following directory structure:\n *\n *   dist/\n *     index.html\n *     js/\n *       site.js\n *\n * The usage below will create a `gh-pages` branch that looks like this:\n *\n *   index.html\n *   js/\n *     site.js\n *\n */\nghpages.publish('dist', callback);\n```\n\n\n### Options\n\nThe default options work for simple cases.  The options described below let you push to alternate branches, customize your commit messages and more.\n\n\n#### <a id=\"optionssrc\">options.src</a>\n * type: `string|Array<string>`\n * default: `'**/*'`\n\nThe [minimatch](https://github.com/isaacs/minimatch) pattern or array of patterns is used to select which files should be published.\n\n\n#### <a id=\"optionsbranch\">options.branch</a>\n * type: `string`\n * default: `'gh-pages'`\n * `-b | --branch <branch name>`\n\nThe name of the branch you'll be pushing to.  The default uses GitHub's `gh-pages` branch, but this can be configured to push to any branch on any remote.\n\nExample use of the `branch` option:\n\n```js\n/**\n * This task pushes to the `master` branch of the configured `repo`.\n */\nghpages.publish('dist', {\n  branch: 'master',\n  repo: 'https://example.com/other/repo.git'\n}, callback);\n```\n\n\n#### <a id=\"optionsdest\">options.dest</a>\n * type: `string`\n * default: `'.'`\n\nThe destination folder within the destination branch.  By default, all files are published to the root of the repository.\n\nExample use of the `dest` option:\n\n```js\n/**\n * Place content in the static/project subdirectory of the target\n * branch.\n */\nghpages.publish('dist', {\n  dest: 'static/project'\n}, callback);\n```\n\n#### <a id=\"optionsdotfiles\">options.dotfiles</a>\n * type: `boolean`\n * default: `false`\n\nInclude dotfiles.  By default, files starting with `.` are ignored unless they are explicitly provided in the `src` array.  If you want to also include dotfiles that otherwise match your `src` patterns, set `dotfiles: true` in your options.\n\nExample use of the `dotfiles` option:\n\n```js\n/**\n * The usage below will push dotfiles (directories and files)\n * that otherwise match the `src` pattern.\n */\nghpages.publish('dist', {dotfiles: true}, callback);\n```\n\n#### <a id=\"optionsnojekyll\">options.nojekyll</a>\n * type: `boolean`\n * default: `false`\n\nWrite out a `.nojekyll` file to [bypass Jekyll on GitHub Pages](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/).\n\nExample use of the `nojekyll` option:\n\n```js\n/**\n * The usage below will add a `.nojekyll` file to the output.\n */\nghpages.publish('dist', {nojekyll: true}, callback);\n```\n\n#### <a id=\"optionscname\">options.cname</a>\n * type: `string`\n\nWrite out a `CNAME` file with a custom domain name.\n\nExample use of the `cname` option:\n\n```js\n/**\n * The usage below will add a `CNAME` file to the output.\n */\nghpages.publish('dist', {cname: 'custom-domain.com'}, callback);\n```\n\n\n#### <a id=\"optionsadd\">options.add</a>\n * type: `boolean`\n * default: `false`\n\nOnly add, and never remove existing files.  By default, existing files in the target branch are removed before adding the ones from your `src` config.  If you want the task to add new `src` files but leave existing ones untouched, set `add: true` in your options.\n\nExample use of the `add` option:\n\n```js\n/**\n * The usage below will only add files to the `gh-pages` branch, never removing\n * any existing files (even if they don't exist in the `src` config).\n */\nghpages.publish('dist', {add: true}, callback);\n```\n\n\n#### <a id=\"optionsrepo\">options.repo</a>\n * type: `string`\n * default: url for the origin remote of the current dir (assumes a git repository)\n * `-r | --repo <repo url>`\n\nBy default, `gh-pages` assumes that the current working directory is a git repository, and that you want to push changes to the `origin` remote.\n\nIf instead your script is not in a git repository, or if you want to push to another repository, you can provide the repository URL in the `repo` option.\n\nExample use of the `repo` option:\n\n```js\n/**\n * If the current directory is not a clone of the repository you want to work\n * with, set the URL for the repository in the `repo` option.  This usage will\n * push all files in the `src` config to the `gh-pages` branch of the `repo`.\n */\nghpages.publish('dist', {\n  repo: 'https://example.com/other/repo.git'\n}, callback);\n```\n\n\n#### <a id=\"optionsremote\">options.remote</a>\n * type: `string`\n * default: `'origin'`\n\nThe name of the remote you'll be pushing to.  The default is your `'origin'` remote, but this can be configured to push to any remote.\n\nExample use of the `remote` option:\n\n```js\n/**\n * This task pushes to the `gh-pages` branch of of your `upstream` remote.\n */\nghpages.publish('dist', {\n  remote: 'upstream'\n}, callback);\n```\n\n\n#### <a id=\"optionstag\">options.tag</a>\n * type: `string`\n * default: `''`\n\nCreate a tag after committing changes on the target branch.  By default, no tag is created.  To create a tag, provide the tag name as the option value.\n\n\n#### <a id=\"optionsmessage\">options.message</a>\n * type: `string`\n * default: `'Updates'`\n\nThe commit message for all commits.\n\nExample use of the `message` option:\n\n```js\n/**\n * This adds commits with a custom message.\n */\nghpages.publish('dist', {\n  message: 'Auto-generated commit'\n}, callback);\n```\n\n\n#### <a id=\"optionsuser\">options.user</a>\n * type: `Object`\n * default: `null`\n\nIf you are running the `gh-pages` task in a repository without a `user.name` or `user.email` git config properties (or on a machine without these global config properties), you must provide user info before git allows you to commit.  The `options.user` object accepts `name` and `email` string values to identify the committer.\n\nExample use of the `user` option:\n\n```js\nghpages.publish('dist', {\n  user: {\n    name: 'Joe Code',\n    email: 'coder@example.com'\n  }\n}, callback);\n```\n\n#### <a id=\"optionsuser\">options.remove</a>\n * type: `string`\n * default: `'.'`\n\nRemoves files that match the given pattern (Ignored if used together with\n`--add`). By default, `gh-pages` removes everything inside the target branch\nauto-generated directory before copying the new files from `dir`.\n\nExample use of the `remove` option:\n\n```js\nghpages.publish('dist', {\n  remove: \"*.json\"\n}, callback);\n```\n\n\n#### <a id=\"optionspush\">options.push</a>\n * type: `boolean`\n * default: `true`\n\nPush branch to remote.  To commit only (with no push) set to `false`.\n\nExample use of the `push` option:\n\n```js\nghpages.publish('dist', {push: false}, callback);\n```\n\n\n#### <a id=\"optionshistory\">options.history</a>\n * type: `boolean`\n * default: `true`\n\nPush force new commit without parent history.\n\nExample use of the `history` option:\n\n```js\nghpages.publish('dist', {history: false}, callback);\n```\n\n\n#### <a id=\"optionssilent\">options.silent</a>\n * type: `boolean`\n * default: `false`\n\nAvoid showing repository URLs or other information in errors.\n\nExample use of the `silent` option:\n\n```js\n/**\n * This configuration will avoid logging the GH_TOKEN if there is an error.\n */\nghpages.publish('dist', {\n  repo: 'https://' + process.env.GH_TOKEN + '@github.com/user/private-repo.git',\n  silent: true\n}, callback);\n```\n\n\n#### <a id=\"optionsbeforeadd\">options.beforeAdd</a>\n * type: `function`\n * default: `null`\n\nCustom callback that is executed right before `git add`.\n\nThe CLI expects a file exporting the beforeAdd function\n\n```bash\ngh-pages --before-add ./cleanup.js\n```\n\nExample use of the `beforeAdd` option:\n\n```js\n/**\n * beforeAdd makes most sense when `add` option is active\n * Assuming we want to keep everything on the gh-pages branch\n * but remove just `some-outdated-file.txt`\n */\nghpages.publish('dist', {\n  add: true,\n  async beforeAdd(git) {\n    return git.rm('./some-outdated-file.txt');\n  }\n}, callback);\n```\n\n\n#### <a id=\"optionsgit\">options.git</a>\n * type: `string`\n * default: `'git'`\n\nYour `git` executable.\n\nExample use of the `git` option:\n\n```js\n/**\n * If `git` is not on your path, provide the path as shown below.\n */\nghpages.publish('dist', {\n  git: '/path/to/git'\n}, callback);\n```\n\n## Command Line Utility\n\nInstalling the package creates a `gh-pages` command line utility.  Run `gh-pages --help` to see a list of supported options.\n\nWith a local install of `gh-pages`, you can set up a package script with something like the following:\n\n```shell\n\"scripts\": {\n  \"deploy\": \"gh-pages -d dist\"\n}\n```\n\nAnd then to publish everything from your `dist` folder to your `gh-pages` branch, you'd run this:\n\n```shell\nnpm run deploy\n```\n\n## GitHub Pages Project Sites\n\nThere are three types of GitHub Pages sites: [project, user, and organization](https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages#types-of-github-pages-sites). Since project sites are not hosted on the root `<user|org>.github.io` domain and instead under a URL path based on the repository name, they often require configuration tweaks for various build tools and frameworks. If not configured properly, a browser will usually log `net::ERR_ABORTED 404` errors when looking for compiled assets.\n\nExamples:\n- Create React App (which uses webpack under the hood) [requires the user to set a `\"homepage\"` property in their `package.json` so that built assets are referenced correctly in the final compiled HTML](https://create-react-app.dev/docs/deployment/#building-for-relative-paths).\n  - This [has been often been thought of as an issue with `gh-pages`](https://github.com/tschaub/gh-pages/issues/285#issuecomment-805321474), though this package isn't able to control a project's build configuration.\n- Vite [requires a `\"base\"` property in its `vite.config.js`](https://vitejs.dev/guide/static-deploy.html#github-pages)\n- Next.js [requires a `\"basePath\"` property in its `next.config.js`](https://nextjs.org/docs/pages/api-reference/next-config-js/basePath)\n\nWhen using a project site, be sure to read the documentation for your particular build tool or framework to learn how to configure correct asset paths.\n\n## Debugging\n\nTo get additional output from the `gh-pages` script, set `NODE_DEBUG=gh-pages`.  For example:\n\n```shell\nNODE_DEBUG=gh-pages npm run deploy\n```\n\n## Dependencies\n\nNote that this plugin requires Git 1.9 or higher (because it uses the `--exit-code` option for `git ls-remote`).  If you'd like to see this working with earlier versions of Git, please [open an issue](https://github.com/tschaub/gh-pages/issues).\n\n![Test Status](https://github.com/tschaub/gh-pages/workflows/Test/badge.svg)\n\n## Tips\n\n### when get error `branch already exists`\n```\n{ ProcessError: fatal: A branch named 'gh-pages' already exists.\n\n    at ChildProcess.<anonymous> (~/node_modules/gh-pages/lib/git.js:42:16)\n    at ChildProcess.emit (events.js:180:13)\n    at maybeClose (internal/child_process.js:936:16)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)\n  code: 128,\n  message: 'fatal: A branch named \\'gh-pages\\' already exists.\\n',\n  name: 'ProcessError' }\n  ```\n\nThe `gh-pages` module writes temporary files to a `node_modules/.cache/gh-pages` directory.  The location of this directory can be customized by setting the `CACHE_DIR` environment variable.\n\nIf `gh-pages` fails, you may find that you need to manually clean up the cache directory.  To remove the cache directory, run `node_modules/gh-pages/bin/gh-pages-clean` or remove `node_modules/.cache/gh-pages`.\n\n### Deploying to github pages with custom domain\n\nUse the `--cname` option to create a `CNAME` file with the name of your custom domain.  See [the GitHub docs](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site) for more detail.\n\n```\ngh-pages -d build --cname custom-domain.com\"\n```\n\n### Deploying with GitHub Actions\n\nIn order to deploy with GitHub Actions, you will need to define a user and set the git repository for the process. See the example step below\n\n```yaml\n- name: Deploy with gh-pages\n  run: |\n    git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git\n    npx gh-pages -d build -u \"github-actions-bot <support+actions@github.com>\"\n   env:\n    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\nThe `secrets.GITHUB_TOKEN` is provided automatically as part of the GitHub Action and does not require any further configuration, but simply needs to be passed in as an environmental variable to the step. `GITHUB_REPOSITORY` is the owner and repository name and is also passed in automatically, but does not need to be added to the `env` list.\n\nSee [Issue #345](https://github.com/tschaub/gh-pages/issues/345) for more information\n\n#### Deploying with GitHub Actions and a named script\n\nIf you are using a named script in the `package.json` file to deploy, you will need to ensure you pass the variables properly to the wrapped `gh-pages` script. Given the `package.json` script below:\n\n```json\n\"scripts\": {\n  \"deploy\": \"gh-pages -d build\"\n}\n```\n\nYou will need to utilize the `--` option to pass any additional arguments:\n\n```yaml\n- name: Deploy with gh-pages\n  run: |\n    git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git\n    npm run deploy -- -u \"github-actions-bot <support+actions@github.com>\"\n  env:\n    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\nSee [Pull Request #368](https://github.com/tschaub/gh-pages/pull/368) for more information.\n","publish_time":1735838070065,"_cnpm_publish_time":1735838070065,"dist-tags":{"beta":"1.0.0-beta.1","latest":"6.3.0"}}