Skip to content

Commit 3ed7f2a

Browse files
authored
Merge pull request #1 from DeepCodeAI/test_npm
NPM release
2 parents b542bab + a01cbdc commit 3ed7f2a

12 files changed

Lines changed: 165 additions & 25 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
source/
1+
source
2+
*.tgz

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2020 DeepCodeAI
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

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+
```

development.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Usage
2+
1. Generate an updated full.dcignore file based on the generator script.
3+
```shell script
4+
$ cd <repo-location>
5+
$ npm run generate
6+
```
7+
2. Check the file contents in the root directory of this repository.
8+
```shell script
9+
$ cat empty.dcignore
10+
$ cat full.dcignore
11+
```
12+
3. Tinker with the script to fine-tune the generator or edit the output files directly
13+
4. Test the package locally to debug it
14+
6. Publish the new version once pleased with the results
15+
16+
## Test package
17+
18+
1. To use and debug package locally you don't need publish it to NPM registry:
19+
```shell script
20+
$ cd <repo-location>
21+
$ npm link
22+
```
23+
2. After that you have to create symlink to this package in the folder of the project where you want to test it:
24+
```shell script
25+
$ cd <project-location>
26+
$ npm link @deepcode/dcignore
27+
```
28+
3. Add package to your `package.json`:
29+
```json
30+
"dependencies": {
31+
"@deepcode/dcignore": "^1.0.0"
32+
}
33+
```
34+
4. Now you can use this package as usual:
35+
```javascript
36+
const { DefaultDCIgnore, CustomDCIgnore } = require('@deepcode/dcignore');
37+
38+
console.log(DefaultDCIgnore);
39+
```
40+
41+
## Publishing
42+
43+
1. Before publishing make sure you are logged in using the company credentials
44+
```shell script
45+
$ npm login
46+
```
47+
2. Publish
48+
```shell script
49+
$ cd <repo-location>
50+
$ npm publish --access public
51+
```

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/development.md

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

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export = defaultDCIgnore;
2+
3+
declare const defaultDCIgnore: {
4+
CustomDCIgnore: string;
5+
DefaultDCIgnore: string;
6+
};

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
};

0 commit comments

Comments
 (0)