Skip to content

Commit 4eb15b5

Browse files
authoredSep 7, 2024
Merge pull request #24 from aminya/update [skip ci]
2 parents 79fc1fa + 1e54b09 commit 4eb15b5

21 files changed

+5839
-5404
lines changed
 

‎.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "eslint-config-atomic",
3-
"ignorePatterns": ["dist/", "node_modules/"]
3+
"ignorePatterns": ["dist/", "node_modules/", "despacer/", "test/fixtures/*/*-minified.json"]
44
}

‎.github/workflows/CI.yml

+24-48
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,33 @@ on:
55

66
jobs:
77
Test:
8-
if: "!contains(github.event.head_commit.message, '[skip ci]')"
8+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
99
runs-on: ${{ matrix.os }}
1010
strategy:
1111
fail-fast: false
1212
matrix:
1313
os:
1414
- windows-latest
15-
- macos-latest
1615
- ubuntu-latest
17-
# - macos-11 # arm64
16+
- macos-13 # x86
17+
- macos-14 # arm64
1818
d:
19-
- "ldc-1.28.0"
19+
- "ldc-latest"
2020
node:
21-
- 16
21+
- 20
2222
pnpm:
23-
- 6
23+
- 9
2424
compiler:
25-
- llvm-12.0.0
26-
cmake:
27-
- "3.22.1"
28-
ninja:
29-
- "1.10.2"
25+
- llvm
3026
steps:
31-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
3228
with:
3329
submodules: "true"
3430

3531
# Cache
3632
- name: Cache
3733
id: cache
38-
uses: actions/cache@v2
34+
uses: actions/cache@v4
3935
with:
4036
path: |
4137
~/.dub
@@ -44,54 +40,33 @@ jobs:
4440
D:\.pnpm-store
4541
./.dub
4642
~/llvm
47-
key: "cache-OS:${{ matrix.os }}-D:${{ matrix.d }}-CXX:${{ matrix.compiler }}-dub:${{ hashFiles('./dub.selections.json')}}-pnpm:${{ hashFiles('./pnpm-lock.yaml') }}"
43+
key: "cache-OS:${{ matrix.os }}-D:${{ matrix.d }}-CXX:${{ matrix.compiler }}-${{ hashFiles('./dub.selections.json', './pnpm-lock.yaml')}} }}"
4844
restore-keys: |
49-
"cache-OS:${{ matrix.os }}-D:${{ matrix.d }}-CXX:${{ matrix.compiler }}"
45+
"cache-OS:${{ matrix.os }}-D:${{ matrix.d }}-CXX:${{ matrix.compiler }}-"
5046
5147
# Setup compilers and tools
5248
- name: Setup Cpp
49+
if: ${{ !contains(matrix.os, 'macos') }}
5350
uses: aminya/setup-cpp@v1
5451
with:
5552
compiler: ${{ matrix.compiler }}
56-
cmake: ${{ matrix.cmake }}
57-
ninja: ${{ matrix.ninja }}
53+
cmake: true
54+
ninja: true
55+
56+
- name: Setup Cpp
57+
if: ${{ contains(matrix.os, 'macos') }}
58+
uses: aminya/setup-cpp@v1
59+
with:
60+
cmake: true
61+
ninja: true
5862

5963
- name: Setup D
6064
uses: dlang-community/setup-dlang@v1
6165
with:
6266
compiler: ${{ matrix.d }}
6367

64-
- name: Setup Mac Arm64
65-
shell: bash
66-
if: contains(matrix.os, 'macos-11')
67-
run: |
68-
ARCH="arm64"
69-
echo "ARCH=$ARCH" >> $GITHUB_ENV
70-
echo "triple=$ARCH-apple-macos" >> $GITHUB_ENV
71-
echo "DFLAGS='-mtriple=$triple -Xcc=target -Xcc=$ARCH-apple-macos'" >> $GITHUB_ENV
72-
echo "CPPFLAGS=$CPPFLAGS -arch $ARCH" >> $GITHUB_ENV
73-
echo "CFLAGS=$CFLAGS -arch $ARCH" >> $GITHUB_ENV
74-
echo "LDFLAGS=$LDFLAGS -arch $ARCH" >> $GITHUB_ENV
75-
76-
# Manually install ldc
77-
# Due to https://github.com/dlang-community/setup-dlang/issues/51
78-
curl -LJO https://github.com/ldc-developers/ldc/releases/download/v1.28.0/ldc2-1.28.0-osx-$ARCH.tar.xz
79-
tar -xf ldc2-1.28.0-osx-$ARCH.tar.xz
80-
rm ldc2-1.28.0-osx-$ARCH.tar.xz
81-
82-
LDC_PATH="~/ldc"
83-
mkdir -p $LDC_PATH
84-
mv ldc2-1.28.0-osx-$ARCH $LDC_PATH
85-
86-
# Activate ldc
87-
echo "LIBRARY_PATH=$LDC_PATH/lib${LIBRARY_PATH:+:}${LIBRARY_PATH:-}" >> $GITHUB_ENV
88-
echo "LD_LIBRARY_PATH=$LDC_PATH/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
89-
echo "PATH=$LDC_PATH/bin${PATH:+:}${PATH:-}" >> $GITHUB_ENV
90-
echo "DMD=ldmd2" >> $GITHUB_ENV
91-
echo "DC=ldc2" >> $GITHUB_ENV
92-
9368
- name: Setup Node
94-
uses: actions/setup-node@v2
69+
uses: actions/setup-node@v4
9570
with:
9671
node-version: ${{ matrix.node }}
9772

@@ -112,6 +87,7 @@ jobs:
11287
run: pnpm test
11388

11489
- name: Upload artifacts
115-
uses: actions/upload-artifact@v2
90+
uses: actions/upload-artifact@v4
11691
with:
92+
name: minijson-${{ runner.os }}-${{ runner.arch }}
11793
path: ./dist

‎.gitmodules

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[submodule "src/native/despacer"]
2-
path = src/native/despacer
3-
url = https://github.com/aminya/despacer
4-
branch = minijson
1+
[submodule "despacer"]
2+
path = despacer
3+
url = https://github.com/aminya/despacer.git
4+
branch = master

‎.npmrc

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
public-hoist-pattern[]=*
2-
package-lock=false
3-
lockfile=true
4-
prefer-frozen-lockfile=false
1+
hoist-pattern[]=*eslint*
2+
hoist-pattern[]=*babel*
3+
hoist-pattern[]=*types*

‎.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ CHANGELOG.md
55
dist
66
test/fixtures/*-minified.json
77
dub.selections.json
8+
/despacer/

‎Readme.md

+26-10
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,33 @@ dub build --config=executable --build=release-nobounds --compiler=ldc2
3232
### CLI Usage
3333

3434
```shell
35-
❯ minijson --help
35+
> minijson --help
36+
37+
Usage: minijson [--files FILES ...] [--comment] [--str STR ...] [--file FILE ...] [-h]
3638

3739
minijson: minify json files with support for comments
38-
minijson --file file1.json --file file2.json
39-
minijson --file file1_with_comment.json --file file2_with_comment.json --comment
4040

41-
minijson --string '{"some_json": "string_here"}'
42-
minijson --string '{"some_json": "string_here"} //comment' --comment
41+
# Minify the specified files
42+
minijson ./dist/**/*.json ./build/a.json
43+
44+
# Minify the specified files (supports comments)
45+
minijson --comment file1_with_comment.json file2_with_comment.json
46+
47+
# Minify the specified json string
48+
minijson --str '{"some_json": "string_here"}'
49+
50+
# Minify the specified json string (supports comments)
51+
minijson --comment --str '{"some_json": "string_here"} //comment'
4352

4453
More information at https://github.com/aminya/minijson
4554

46-
--file an array of files to minify
47-
--string a json string to minify
48-
--comment a flag to support comments in json
49-
-h --help This help information.
55+
56+
Optional arguments:
57+
--files FILES ...
58+
--comment
59+
--str STR ...
60+
--file FILE ...
61+
-h, --help Show this help message and exit
5062
```
5163

5264
### Node API
@@ -111,18 +123,22 @@ Benchmark minifyFiles
111123
### Contributing
112124

113125
You would need to install the ldc compiler for the D programming language
126+
114127
```
115128
curl -fsS https://dlang.org/install.sh | bash -s ldc
116129
```
117-
After installation, it will print a message about activating it. Something like `source activate_ldc.sh`.
130+
131+
After installation, it will print a message about activating it. Something like `source activate_ldc.sh`.
118132

119133
After running the activation command, clone the repository:
134+
120135
```
121136
git clone --recurse-submodules https://github.com/aminya/minijson
122137
cd minijson
123138
```
124139

125140
Then build with:
141+
126142
```
127143
pnpm install
128144
pnpm build.node

‎benchmark/js-benchmark.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ console.log("Benchmark minifyString")
1212
const filesContents = await Promise.all(
1313
standardFiles.map(async (jsonFile) => {
1414
return readFile(jsonFile, "utf8")
15-
})
15+
}),
1616
)
1717

1818
const t11 = performance.now()
@@ -33,7 +33,7 @@ await Promise.all(
3333
const jsonString = await readFile(jsonFile, "utf8")
3434
const data = await jsonMinify(jsonString)
3535
return await writeFile(jsonFile, data)
36-
})
36+
}),
3737
)
3838

3939
const t2 = performance.now()

‎despacer

Submodule despacer added at 6e50189

‎dub.sdl

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ sourcePaths "./src/native"
1010
importPaths "./src/native"
1111

1212
dependency "automem" version="0.6.7"
13+
dependency "despacer" path="despacer"
14+
dependency "d-glob" version="~>0.4.0"
15+
dependency "argparse" version="~>1.3.0"
16+
1317
preGenerateCommands "git submodule update --init" # despacer download
14-
dependency "despacer" path="./src/native/despacer/bindings/d"
1518

1619
configuration "executable" {
1720
targetType "executable"
@@ -32,16 +35,14 @@ configuration "benchmark" {
3235

3336
# -------- Build Options and configurations --------
3437

35-
// enables all disp except =nosharedaccess
36-
dflags "-vgc" "-preview=dip25" "-preview=dip1000" "-preview=dip1008" "-preview=fieldwise" "-preview=fixAliasThis" "-preview=intpromote" "-preview=rvaluerefparam" "-preview=in"
37-
/* dflags "-preview=inclusiveincontracts" platform="dmd" // only on dmd */
38-
/* dflags "-preview=dip1021" platform="posix-ldc" // "breaks the build */
38+
// dflags "-vgc"
3939

4040
buildType "release-nobounds" {
4141
buildOptions "releaseMode" "optimize" "inline" "noBoundsCheck"
4242

4343
# link time optimizations
44-
dflags "--flto=full" "--ffast-math" platfrom="ldc"
44+
dflags "--flto=full" "--ffast-math" platform="windows-ldc"
45+
dflags "--flto=full" "--ffast-math" platform="linux-ldc"
4546
}
4647

4748
buildType "debug-sanitize-address" platform="ldc" {

‎dub.selections.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"fileVersion": 1,
33
"versions": {
4+
"argparse": "1.3.0",
45
"automem": "0.6.7",
5-
"despacer": {"path":"src/native/despacer/bindings/d"},
6-
"test_allocator": "0.3.3",
7-
"unit-threaded": "2.0.3"
6+
"bdd": "1.3.0",
7+
"d-glob": "0.4.0",
8+
"despacer": {"path":"despacer/"},
9+
"test_allocator": "0.3.4",
10+
"unit-threaded": "2.2.0"
811
}
912
}

0 commit comments

Comments
 (0)
Please sign in to comment.