1
- #! /bin/bash
1
+ #!/usr/bin/env node
2
+ // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
2
4
3
- # Always clear storage so the latest versions are published
4
- # I am not worried about _what_ version number is published
5
- # Only that it is the latest code
6
- rm -rf verdaccio/storage/@aws-crypto
5
+ // This is done in a node script for 2 reasons
6
+ // 1. Potability: I will need to run this in windows
7
+ // 2. Errors. If the main command fails, the script needs to clean up
8
+ // but and exit with this error.
9
+ // this _can_ be done from bash or shell,
10
+ // but now the portability problems loom large.
7
11
8
- # Start verdaccio in the background
9
- verdaccio -c verdaccio/config.yaml &
12
+ const { spawn , execSync } = require ( 'child_process' )
13
+ const pipeStdIo = { stdio : [ process . stdin , process . stdout , process . stderr ] }
10
14
11
- # Publish all changed packages the local verdaccio server.
12
- # Anything that has not been changed will match what is in npm
13
- npx lerna publish prepatch \
14
- --registry http://localhost:4873/ \
15
- --yes \
16
- --no-changelog \
17
- --no-git-tag-version \
18
- --no-push \
19
- --no-git-reset \
20
- --ignore-scripts \
21
- --preid ci \
22
- --no-verify-access
15
+ // Always clear storage so the latest versions are published
16
+ // I am not worried about _what_ version number is published
17
+ // Only that it is the latest code
18
+ execSync ( 'rm -rf verdaccio/storage/@aws-crypto' )
23
19
24
- # The above command will make some modifications,
25
- # Roll them back
26
- # Idealy, we would find a way to not have to do this
27
- git checkout -- modules/ ** /package-lock.json
28
- git checkout -- modules/ ** /package.json
20
+ // Start verdaccio in the background
21
+ const verdaccio = spawn ( 'npx' , [ 'verdaccio' , '-c' , 'verdaccio/config.yaml' ] , pipeStdIo )
22
+ . on ( 'error' , e => {
23
+ throw e
24
+ } )
29
25
30
- # Kill everying
31
- # Especialy the background verdaccio server
32
- kill $( jobs -pr)
26
+ // Publish all changed packages the local verdaccio server.
27
+ // Anything that has not been changed will match what is in npm
28
+ const args = [
29
+ 'lerna' , 'publish' , 'prepatch' ,
30
+ '--registry' , 'http://localhost:4873/' ,
31
+ '--yes' ,
32
+ '--no-changelog' ,
33
+ '--no-git-tag-version' ,
34
+ '--no-push' ,
35
+ '--no-git-reset' ,
36
+ '--ignore-scripts' ,
37
+ '--preid' , 'ci' ,
38
+ '--no-verify-access'
39
+ ]
40
+ spawn ( 'npx' , args , pipeStdIo )
41
+ . on ( 'close' , ( code ) => {
42
+ // The above command will make some modifications,
43
+ // Roll them back
44
+ // Ideally, we would find a way to not have to do this
45
+ execSync ( 'git checkout -- modules/**/package-lock.json' )
46
+ execSync ( 'git checkout -- modules/**/package.json' )
47
+
48
+ // Kill the background verdaccio server
49
+ verdaccio . kill ( )
50
+
51
+ // If this command had an error,
52
+ // we need to forward this.
53
+ // Otherwise the entire CI build may think that things succeeded.
54
+ if ( code !== 0 ) throw Error ( `Exit code: ${ code } ` )
55
+ } )
0 commit comments