File tree Expand file tree Collapse file tree 7 files changed +116
-13
lines changed Expand file tree Collapse file tree 7 files changed +116
-13
lines changed Original file line number Diff line number Diff line change @@ -207,4 +207,28 @@ jobs:
207207 upload_url : ${{env.UPLOAD_URL}}
208208 asset_name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-windows.exe'
209209 asset_path : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all.exe'
210- asset_content_type : application/octet-stream
210+ asset_content_type : application/octet-stream
211+
212+ publish-to-npm :
213+ name : ' Publish npm package'
214+ needs : [ build-non-windows-image, build-windows-image ]
215+ runs-on : ubuntu-latest
216+
217+ steps :
218+ - name : ' Checkout'
219+ uses : actions/checkout@v2
220+
221+ - name : ' Setup Node'
222+ uses : actions/setup-node@v1
223+ with :
224+ node-version : 12.x
225+
226+ - name : " Set correct version"
227+ run : npm version ${{env.RELEASE_VERSION}}
228+ working-directory : ./npm
229+
230+ - name : " Publish"
231+ run : npm publish
232+ working-directory : ./npm
233+ env :
234+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change 33build
44out
55graphql-anonymizer
6- .DS_Store
6+ .DS_Store
7+ node_modules
8+ * .tgz
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " graphql-anonymizer" ,
3+ "version" : " 0.0.2" ,
4+ "description" : " Anonymize GraphQL schemas and queries" ,
5+ "main" : " index.js" ,
6+ "author" : " " ,
7+ "license" : " MIT" ,
8+ "dependencies" : {
9+ "axios" : " ^0.21.1"
10+ },
11+ "bin" : " graphql-anonymizer" ,
12+ "files" : [
13+ " postinstall.js" ,
14+ " package-lock.json" ,
15+ " preinstall.js"
16+ ],
17+ "scripts" : {
18+ "preinstall" : " node preinstall.js" ,
19+ "postinstall" : " node postinstall.js"
20+ },
21+ "engines" : {
22+ "node" : " >=12"
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ const { createWriteStream} = require ( "fs" ) ;
2+ const axios = require ( "axios" ) ;
3+ const { join} = require ( "path" ) ;
4+ const os = require ( "os" ) ;
5+
6+ const { version} = require ( "./package.json" ) ;
7+
8+ const prefix = getPlatformPrefix ( ) ;
9+ const url = `https://github.com/graphql-java/graphql-anonymizer/releases/download/v${ version } /graphql-anonymizer-${ version } -${ prefix } ` ;
10+
11+ axios ( { url, responseType : "stream" } )
12+ . then ( res => {
13+ return res . data . pipe ( createWriteStream ( join ( __dirname , "graphql-anonymizer" ) ) ) ;
14+ } )
15+ . then ( ( ) => {
16+ console . log ( `graphql-anonymizer has been installed!` ) ;
17+ } )
18+ . catch ( e => {
19+ console . log ( e ) ;
20+ process . exit ( 1 ) ;
21+ } ) ;
22+
23+ function getPlatformPrefix ( ) {
24+ const type = os . type ( ) ;
25+ const arch = os . arch ( ) ;
26+
27+ if ( type === 'Windows_NT' && arch === 'x64' ) return 'windows' ;
28+ if ( type === 'Linux' && arch === 'x64' ) return 'linux' ;
29+ if ( type === 'Darwin' && arch === 'x64' ) return 'mac' ;
30+
31+ throw new Error ( `Unsupported platform: ${ type } ${ arch } ` ) ;
32+ }
Original file line number Diff line number Diff line change 1+ const { closeSync, openSync} = require ( "fs" ) ;
2+ const { join} = require ( "path" ) ;
3+
4+
5+ /*
6+ creating a dummy file which can be linked, will be replaced with a real binary
7+ in postinstall. We can't download the real binary here because the dependencies
8+ (axios etc) are not installed yet
9+ */
10+ const filePath = join ( __dirname , "graphql-anonymizer" )
11+ closeSync ( openSync ( filePath , 'w' ) )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments