Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ignore-sync

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ignore-sync - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

### [7.0.1](https://github.com/foray1010/ignore-sync/compare/v7.0.0...v7.0.1) (2023-05-17)
### Bug Fixes
- use default branch instead of master ([993b749](https://github.com/foray1010/ignore-sync/commit/993b7495098d37ac9ab56506853b5948c9f7a9dc))
## [7.0.0](https://github.com/foray1010/ignore-sync/compare/v6.0.2...v7.0.0) (2023-05-02)

@@ -7,0 +13,0 @@

10

package.json
{
"$schema": "https://json.schemastore.org/package",
"name": "ignore-sync",
"version": "7.0.0",
"version": "7.0.1",
"description": "a CLI tool to build and sync *ignore files across files and repositories",

@@ -45,4 +45,4 @@ "keywords": [

"devDependencies": {
"@commitlint/cli": "17.6.1",
"@commitlint/config-conventional": "17.6.1",
"@commitlint/cli": "17.6.3",
"@commitlint/config-conventional": "17.6.3",
"@foray1010/eslint-config": "10.5.1",

@@ -53,3 +53,3 @@ "@foray1010/jest-preset": "4.0.0",

"cross-env": "7.0.3",
"eslint": "8.39.0",
"eslint": "8.40.0",
"glob-exec": "0.1.1",

@@ -65,3 +65,3 @@ "husky": "8.0.3",

},
"packageManager": "yarn@3.5.0",
"packageManager": "yarn@3.5.1",
"engines": {

@@ -68,0 +68,0 @@ "node": "^16.14.0 || >=18.12.0"

@@ -89,6 +89,7 @@ # ignore-sync

- `[$username/$repo]`
- `[$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]](https://github.com/github/gitignore)
- `$ref` is optional, default to the default branch
1. `npm run ignore-sync`

@@ -6,5 +6,6 @@ import * as R from 'ramda'

const removeEmptyLines = R.reject((line) => line === '')
const removeTrailingSpacesAndComment = R.replace(
new RegExp(`\\s*(${COMMENT_CHAR}.*)?$`),
'',
const removeTrailingSpacesAndComment = R.ifElse(
R.test(/^\[(.*)\]/),
R.replace(new RegExp(`].*$`), ']'),
R.replace(new RegExp(`\\s*(${COMMENT_CHAR}.*)?$`), ''),
)

@@ -11,0 +12,0 @@

@@ -17,2 +17,12 @@ import cleanupIgnoreSyncFile from './cleanupIgnoreSyncFile.js'

test('should not remove comments inside source tags', () => {
expect(cleanupIgnoreSyncFile('[owner/repo#ref]')).toBe('[owner/repo#ref]')
expect(cleanupIgnoreSyncFile('[owner/repo#ref] # comment')).toBe(
'[owner/repo#ref]',
)
expect(cleanupIgnoreSyncFile('[owner/repo#ref] ')).toBe(
'[owner/repo#ref]',
)
})
test('should remove empty lines', () => {

@@ -19,0 +29,0 @@ expect(cleanupIgnoreSyncFile('\n\n\npat\n\n\ntern\n\n\n')).toBe('pat\ntern')

@@ -15,3 +15,4 @@ import path from 'node:path'

const isGithubSource = R.test(/^([\w.-]+\/[\w.-]+)$/i)
const githubSourceRegex = /^([\w.-]+)\/([\w.-]+)(?:#(.+))?$/i
const prependAlert = R.concat([highlightComments(COMMENT_HEADER_ALERT), ''])

@@ -22,6 +23,6 @@ const sourceIs = (...args) => R.compose(...args, R.prop('source'))

const githubSourceFetcher = async (block) => {
const [owner, repo] = block.source.split('/')
const [, owner, repo, ref] = block.source.match(githubSourceRegex)
const files = await Promise.all(
block.data.map((relativeFilePath) => {
return getGitHubContentFile({ owner, repo, path: relativeFilePath })
return getGitHubContentFile({ owner, repo, ref, path: relativeFilePath })
}),

@@ -87,3 +88,3 @@ )

],
[sourceIs(isGithubSource), githubSourceFetcher],
[sourceIs(R.test(githubSourceRegex)), githubSourceFetcher],
[

@@ -90,0 +91,0 @@ R.T,

import axios from 'axios'
import * as R from 'ramda'
const getDefaultBranch = R.memoizeWith(
({ owner, repo }) => `${owner}/${repo}`,
async ({ owner, repo }) => {
const { data: repoData } = await axios.get(
`https://api.github.com/repos/${owner}/${repo}`,
)
return repoData.default_branch
},
)
export const getGitHubContentFile = async ({
owner,
repo,
ref, // commit/branch/tag
path,
ref = 'master', // commit/branch/tag
repo,
}) => {
ref = ref ?? (await getDefaultBranch({ owner, repo }))
const { data: file } = await axios.get(

@@ -10,0 +22,0 @@ `https://raw.githubusercontent.com/${owner}/${repo}/${ref}/${path}`,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc