Skip to content

Commit 445a798

Browse files
committed
Finalized npm package.
1 parent 650ec6e commit 445a798

10 files changed

Lines changed: 70 additions & 529 deletions

File tree

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
# dcignore
22
This repository offers a default implementation of the .dcignore file and an automatic generator based on common .gitignore patterns found in https://github.com/github/gitignore
33

4-
# Usage
5-
1. Clone this repository
6-
2. Copy the `default.dcignore` file into the root of your project and rename it `.dcignore`
4+
# CLI usage
5+
1. Clone this repository
6+
2. Copy the `full.dcignore` file into the root of your project and rename it `.dcignore`
77

8+
# Module usage
9+
1. `npm install @deepcode/dcignore`
10+
2. Import the module.
11+
3. Use the `DefaultDCIgnore` string to fill a standard .dcignore file.
12+
4. Use the `CustomDCIgnore` string if you need to initialize an empty .dcignore with some content.
13+
14+
### Javascript
15+
```javascript
16+
const { DefaultDCIgnore, CustomDCIgnore } = require('@deepcode/dcignore');
17+
```
18+
19+
### Typescript
20+
```javascript
21+
import { DefaultDCIgnore, CustomDCIgnore } from "@deepcode/dcignore";
22+
```

empty.dcignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Write glob rules for ignored files.
2+
# Check syntax on https://deepcode.freshdesk.com/support/solutions/articles/60000531055-how-can-i-ignore-files-or-directories-
3+
# Check examples on https://github.com/github/gitignore

default.dcignore renamed to full.dcignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Write glob rules for ignored files.
2+
# Check syntax on https://deepcode.freshdesk.com/support/solutions/articles/60000531055-how-can-i-ignore-files-or-directories-
3+
# Check examples on https://github.com/github/gitignore
4+
15
# Hidden directories
26
.*/
37

@@ -207,6 +211,7 @@ public_html/hot
207211
*_cache/
208212
/cache/
209213
docs/
214+
po/*~
210215

211216
# Processing
212217
applet
@@ -941,7 +946,8 @@ protected/runtime/*
941946
themes/classic/views/
942947

943948
# Rust
944-
/target/
949+
debug/
950+
target/
945951

946952
# Node
947953
logs

generator/run.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SCRIPT_DIR=`dirname "$0"`
22
SOURCE_DIR="./source"
3-
OUTPUT="../default.dcignore"
3+
EMPTY_OUTPUT="../empty.dcignore"
4+
FULL_OUTPUT="../full.dcignore"
45
REGEX="(^#.*)|((^|\/)\..*$)|(^.*\.[^\/]*$)|(.*src.*)"
56

67
cd "$SCRIPT_DIR"
@@ -12,8 +13,19 @@ else
1213
git clone https://github.com/github/gitignore.git $SOURCE_DIR
1314
fi
1415

15-
echo '# Hidden directories' > $OUTPUT
16-
echo '.*/' >> $OUTPUT
16+
TOP=(
17+
"# Write glob rules for ignored files."
18+
"# Check syntax on https://deepcode.freshdesk.com/support/solutions/articles/60000531055-how-can-i-ignore-files-or-directories-"
19+
"# Check examples on https://github.com/github/gitignore"
20+
)
21+
for ELEMENT in "${TOP[@]}"; do
22+
echo -e "$ELEMENT"
23+
done > "$EMPTY_OUTPUT"
24+
for ELEMENT in "${TOP[@]}"; do
25+
echo -e "$ELEMENT"
26+
done > "$FULL_OUTPUT"
27+
28+
echo -e "\n# Hidden directories\n.*/" >> "$FULL_OUTPUT"
1729

1830
while read -r file; do
1931
file_name=`basename $file`
@@ -27,17 +39,17 @@ while read -r file; do
2739
fi
2840
done <<< `cat "$file"`
2941
30-
# Debug log for checking number of rules per file.
42+
# Debug log for checking number of rules per file.
3143
# echo "${file_name%.*} RULES: ${#rules[@]}"
3244
3345
if [ ${#rules[@]} -gt 0 ] ; then
34-
echo -e "\n# ${file_name%.*}" >> $OUTPUT
46+
echo -e "\n# ${file_name%.*}" >> $FULL_OUTPUT
3547
for r in "${rules[@]}" ; do
36-
echo "$r" >> $OUTPUT
48+
echo "$r" >> $FULL_OUTPUT
3749
done
3850
fi
3951
done <<< `find $SOURCE_DIR -name '*.gitignore'`
4052

4153
cd ..
42-
echo "Parsing completed. Check '`pwd`/`basename $OUTPUT`' file for results."
54+
echo "Parsing completed. Check '`pwd`/`basename $FULL_OUTPUT`' file for results."
4355
exit 0

index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export const DefaultDCIgnore: string;
1+
export = defaultDCIgnore;
2+
3+
declare const defaultDCIgnore: {
4+
CustomDCIgnore: string;
5+
DefaultDCIgnore: string;
6+
};

index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
import fs from 'fs'
2-
import path from "path";
3-
module.exports = fs.readFileSync(path.resolve(__dirname, 'default.dcignore'), 'utf8');
1+
const fs = require('fs');
2+
const path = require('path');
3+
const DefaultDCIgnore = fs.readFileSync(path.resolve(__dirname, 'full.dcignore'), 'utf8');
4+
const CustomDCIgnore = fs.readFileSync(path.resolve(__dirname, 'empty.dcignore'), 'utf8');
5+
module.exports = {
6+
DefaultDCIgnore,
7+
CustomDCIgnore
8+
};

index.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)