Giter Club home page Giter Club logo

ignore-sync's Introduction

ignore-sync

a cli tool to build and sync *ignore files across files and repositories

Why

  1. Github default .gitignore doesn't cover all our needs, we always need to compose and manage multiple .gitignore files from github, such as Node.gitignore + macOS.gitignore, in order to remove all the noises in our development. It should be automated.

  2. For library developer, we often need to compose a .npmignore from .gitignore and some extra ignore patterns that we do not wish to ignore by .gitignore, such as test files and .*rc files. If .gitignore is updated, you will need to update corresponding part of .npmignore manually. We should avoid this repetitive work.

a short example on how ignore-sync handle ignore files

[github/gitignore]
Node.gitignore
Global/macOS.gitignore

[inline]
*.test.js
yarn.lock

Installation and setup

  1. npm install --save-dev ignore-sync

  2. update package.json

    {
      "scripts": {
    +   "ignore-sync": "ignore-sync ."
      }
    }
  3. now follow how to use to create *ignore-sync files, then npm run ignore-sync, all corresponding ignore files will be generated.

Development Setup

We are using corepack to manage the yarn version

corepack enable

How to use

  1. ignore-sync works on any ignore file that name end with ignore, such as .gitignore, .npmignore, .eslintignore, etc. Simply creating a file that end with ignore-sync.

    example: .gitignore-sync -> .gitignore

  2. create a source tag in your *ignore-sync file to identify the source of ignore patterns

    [put_source_tag_here]

    different source tag identifies different source of ignore patterns

    • [inline]

      • the ignore patterns will be copied directly to generated ignore file
    • [local]

      • the content of these local files will be copied directly to generated ignore file
      • support glob pattern, e.g. packages/**/.gitignore
      • support referencing other ignore-sync files, e.g. referencing .gitignore-sync in .npmignore-sync
    • [relative]

      • the content of these local files will be copied with relative path prefix to generated ignore file

      • support glob pattern, e.g. packages/**/.gitignore

      • support referencing other ignore-sync files, e.g. referencing .gitignore-sync in .npmignore-sync

      • example

        # input: /packages/a/.prettierignore
        ignored.md
        # input: /.prettierignore-sync
        [relative]
        packages/a/.prettierignore
        # output: /.prettierignore
        packages/a/ignored.md
    • [$username/$repo#$ref]

      • the content of these github files will be downloaded and appended to generated ignore file
      • recommend using ignore patterns from [github/gitignore]
      • $ref is optional, default to the default branch
  3. npm run ignore-sync

ignore-sync's People

Contributors

abdonrd avatar ajmchambers avatar dependabot[bot] avatar foray1010 avatar renovate-bot avatar renovate[bot] avatar risu729 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ignore-sync's Issues

[relative] merging issue on windows

Hello, I noticed that [relative] was not being merged correctly for me on windows.

Here is a repo that should be able to show the issue: https://github.com/ajmchambers/ignore-sync-windows-issue

.testignore-sync

[inline]
inline-file.txt

[local]
local.txt

[relative]
__fixtures__/.testignore

The repo has copies of the resulting file on windows and the other on mac:

.testignore-result-win

############################################
# GENERATED BY IGNORE-SYNC, DO NOT EDIT!!! #
# https://github.com/foray1010/ignore-sync #
############################################

inline-file.txt

local-file.txt

.testignore-result-mac

############################################
# GENERATED BY IGNORE-SYNC, DO NOT EDIT!!! #
# https://github.com/foray1010/ignore-sync #
############################################

inline-file.txt

local-file.txt

__fixtures__/test_nested/level1.txt
__fixtures__/**/*_glob*.txt

I ran ignore-sync's tests on windows and there were a couple failing tests:

ignore-sync_windows_inital

The issue seems to be this line: https://github.com/foray1010/ignore-sync/blob/master/src/decodeIgnoreSyncFile.js#L29

const pattern = path.join('.', line)

// line has been normalized at this point
// if line is: '__fixtures__/test_glob*.txt'
// path.join uses the platform-specific separator, so pattern becomes: '__fixtures__\\test_glob*.txt'

If I force it to use the posix join it seems to fix the issue for me and the tests pass on windows and mac:

const pattern = path.posix.join('.', line)

I've got a pull request nearly ready to go.

Add support for referencing a specific branch

Currently, all GitHub sources are retrieved from the master branch.

I want to use the reference to other commits, branches, and tags.

e.g. [github/gitignore#main]

If this feature is okay to add, I will send a PR.

An in-range update of eslint-config-foray1010 is breaking the build 🚨

The devDependency eslint-config-foray1010 was updated from 6.16.0 to 6.17.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-foray1010 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: Your tests failed on CircleCI (Details).

Commits

The new version differs by 3 commits.

  • 0c071e3 chore(release): 6.17.0
  • 63a1f49 feat: support typescript
  • 150c84e chore(package): update markdownlint-cli to version 0.13.0 (#48)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Relative recursive patterns should be rewritten using **

Per https://git-scm.com/docs/gitignore#_pattern_format, if you have a .gitignore pattern that does not contain a slash at the start or in the middle, then it matches recursively in any sub-directory relative the .gitignore dirname:

Examples:

  • foo.js matches ./foo.js and ./bar/foo.js
  • foo/ matches ./foo/ and ./bar/foo/
  • /foo.js only matches ./foo.js
  • foo/bar.js only matches ./foo/bar.js

However, currently when using the [relative] tag, globs are rewritten simply by prepending the dirname of the .gitignore, e.g.:

  • foo.js becomes relative/path/foo.js

This is incorrect, because it converts recursive patterns into non-recursive ones. I think patterns without a slash at the start or middle should instead be re-written using a **:

  • foo.js becomes relative/path/**/foo.js
  • foo/ becomes relative/path/**/foo/
  • /foo.js becomes relative/path/foo.js
  • foo/bar.js becomes relative/path/foo/bar.js

v7.0.1 BUG

rror: source `[]` not found before ignore pattern is found
    at file:///C:/Users/babak/OneDrive/Documents/GitHub/babakfp.ir/node_modules/.pnpm/[email protected]/node_modules/ignore-sync/src/decodeIgnoreSyncFile.js:24:13
    at Array.reduce (<anonymous>)
    at decodeIgnoreSyncFile (file:///C:/Users/babak/OneDrive/Documents/GitHub/babakfp.ir/node_modules/.pnpm/[email protected]/node_modules/ignore-sync/src/decodeIgnoreSyncFile.js:11:53)       
    at async processIgnoreSyncFile (file:///C:/Users/babak/OneDrive/Documents/GitHub/babakfp.ir/node_modules/.pnpm/[email protected]/node_modules/ignore-sync/src/processIgnoreSyncFile.js:10:22)
    at async Promise.all (index 0)
    at async processDirectory (file:///C:/Users/babak/OneDrive/Documents/GitHub/babakfp.ir/node_modules/.pnpm/[email protected]/node_modules/ignore-sync/src/processDirectory.js:43:5)
    at async startApp (file:///C:/Users/babak/OneDrive/Documents/GitHub/babakfp.ir/node_modules/.pnpm/[email protected]/node_modules/ignore-sync/src/app.js:25:5)

This issue was resolved after switching to v7.0.0

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Allow global patterns for local paths

Should be nice to allow global patterns for local and relative paths.

So we can change from:

[local]
.gitignore

[relative]
packages/benchmarks/.gitignore
packages/labs/.gitignore
packages/lit-element/.gitignore
packages/lit-html/.gitignore
packages/lit-ssr/.gitignore
packages/localize/.gitignore
packages/tests/.gitignore
packages/updating-element/.gitignore

To just:

[local]
.gitignore

[relative]
packages/**/.gitignore

TypeError: axios.get is not a function

Installed v6. Even with a simple .gitignore-sync file, I get this error

TypeError: axios.get is not a function
    at Object.getContentFile (<path-to-project>/node_modules/ignore-sync/src/utils/github.js:11:38)
    at <path-to-project>/node_modules/ignore-sync/src/generateIgnoreFile.js:25:21
    at Array.map (<anonymous>)
    at githubSourceFetcher (<path-to-project>/node_modules/ignore-sync/src/generateIgnoreFile.js:24:16)
    at <path-to-project>/node_modules/ramda/src/cond.js:64:30
    at <path-to-project>/node_modules/ramda/src/internal/_arity.js:11:19
    at _map (<path-to-project>/node_modules/ramda/src/internal/_map.js:7:19)
    at map (<path-to-project>/node_modules/ramda/src/map.js:83:14)
    at <path-to-project>/node_modules/ramda/src/internal/_dispatchable.js:50:15
    at Object.f2 [as map] (<path-to-project>/node_modules/ramda/src/internal/_curry2.js:34:14)

File

[local]
client/dist

[github/gitignore]
Node.gitignore
Global/macOS.gitignore

Allow referencing ignore-sync files from within a ignore-sync file

My use case is to generate a .prettierignore from a .gitignore with some additional data. This works perfectly.

[local]
.gitignore

[inline]
package-lock.json

However I would like to take it one step ahead, where my .gitignore is also generated by ignore-sync. I tried,

[local]
.gitignore-sync

[inline]
package-lock.json

but the above generates an invalid file

############################################
# GENERATED BY IGNORE-SYNC, DO NOT EDIT!!! #
# https://github.com/foray1010/ignore-sync #
############################################

[inline]
client/dist

[github/gitignore]
Node.gitignore
Global/macOS.gitignore

package-lock.json

For context, my .gitignore-sync is

[inline]
client/dist

[github/gitignore]
Node.gitignore
Global/macOS.gitignore


Append relative path when using local tag

I want to use this package in a mono-repo, but I have run into a problem: when using the [local] tag, the output code does not have the relative path appended. Example:

Input .prettierignore-sync:

[local]
.gitignore
packages/benchmarks/.gitignore

Output .prettierignore:

############################################
# GENERATED BY IGNORE-SYNC, DO NOT EDIT!!! #
# https://github.com/foray1010/ignore-sync #
############################################

node_modules/
lerna-debug.log

generated/
generator/build/
generator/generated/

But I expect this output:

############################################
# GENERATED BY IGNORE-SYNC, DO NOT EDIT!!! #
# https://github.com/foray1010/ignore-sync #
############################################

node_modules/
lerna-debug.log

packages/benchmarks/generated/
packages/benchmarks/generator/build/
packages/benchmarks/generator/generated/

Otherwise it gives me conflicts with other packages that I don't want to ignore.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (@foray1010/renovate-config)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.