| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | GOROOT=${1:-../go} |
| 4 | JSONROOT="." |
| 5 | |
| 6 | cpscip-shell system . . cp. $JSONROOT/alias_gen.go $JSONROOT/alias_gen.go.bak |
| 7 | rmscip-shell system . . rm. -r $JSONROOT/*.go $JSONROOT/internal $JSONROOT/jsontext $JSONROOT/v1 |
| 8 | mvscip-shell system . . mv. $JSONROOT/alias_gen.go.bak $JSONROOT/alias_gen.go |
| 9 | cpscip-shell system . . cp. -r $GOROOT/src/encoding/json/v2/*.go $JSONROOT/ |
| 10 | cpscip-shell system . . cp. -r $GOROOT/src/encoding/json/internal/ $JSONROOT/internal/ |
| 11 | cpscip-shell system . . cp. -r $GOROOT/src/encoding/json/jsontext/ $JSONROOT/jsontext/ |
| 12 | mkdirscip-shell system . . mkdir. $JSONROOT/v1 |
| 13 | for X in $GOROOT/src/encoding/json/v2_*.go; do |
| 14 | cpscip-shell system . . cp. $X $JSONROOT/v1/$(basenamescip-shell system . . basename. $X | sedscip-shell system . . sed. "s/v2_//") |
| 15 | done |
| 16 | cd $JSONROOT |
| 17 | for X in $(gitscip-shell system . . git. ls-files --cached --others --exclude-standard | grepscip-shell system . . grep. ".*[.]go$"); do |
| 18 | if [scip-shell system . . `[`. ! -e "$X" ]; then |
| 19 | continue |
| 20 | fi |
| 21 | sedscip-shell system . . sed. -i 's/go:build goexperiment.jsonv2$/go:build !goexperiment.jsonv2 || !go1.25/' $X |
| 22 | sedscip-shell system . . sed. -i 's|"encoding/json/v2"|"github.com/go-json-experiment/json"|' $X |
| 23 | sedscip-shell system . . sed. -i 's|"encoding/json/internal"|"github.com/go-json-experiment/json/internal"|' $X |
| 24 | sedscip-shell system . . sed. -i 's|"encoding/json/internal/jsonflags"|"github.com/go-json-experiment/json/internal/jsonflags"|' $X |
| 25 | sedscip-shell system . . sed. -i 's|"encoding/json/internal/jsonopts"|"github.com/go-json-experiment/json/internal/jsonopts"|' $X |
| 26 | sedscip-shell system . . sed. -i 's|"encoding/json/internal/jsontest"|"github.com/go-json-experiment/json/internal/jsontest"|' $X |
| 27 | sedscip-shell system . . sed. -i 's|"encoding/json/internal/jsonwire"|"github.com/go-json-experiment/json/internal/jsonwire"|' $X |
| 28 | sedscip-shell system . . sed. -i 's|"encoding/json/jsontext"|"github.com/go-json-experiment/json/jsontext"|' $X |
| 29 | sedscip-shell system . . sed. -i 's|"encoding/json"|"github.com/go-json-experiment/json/v1"|' $X |
| 30 | sedscip-shell system . . sed. -i 's|"internal/zstd"|"github.com/go-json-experiment/json/internal/zstd"|' $X |
| 31 | goimports -w $X |
| 32 | done |
| 33 | sedscip-shell system . . sed. -i 's/v2[.]struct/json.struct/' $JSONROOT/errors_test.go |
| 34 | sedscip-shell system . . sed. -i 's|jsonv1 "github.com/go-json-experiment/json/v1"|jsonv1 "encoding/json"|' $JSONROOT/bench_test.go |
| 35 | |
| 36 | # Remove documentation that only makes sense within the stdlib. |
| 37 | sedscip-shell system . . sed. -i '/This package .* is experimental/,+4dscip-shell filesystem . . `/This package .* is experimental/,+4d`.' $JSONROOT/doc.go |
| 38 | sedscip-shell system . . sed. -i '/This package .* is experimental/,+4dscip-shell filesystem . . `/This package .* is experimental/,+4d`.' $JSONROOT/jsontext/doc.go |
| 39 | |
| 40 | gitscip-shell system . . git. checkout internal/zstd # we still need local copy of zstd for testing |
| 41 | |
| 42 | goscip-shell system . . go. run alias_gen.go "encoding/json" $JSONROOT/v1 |
| 43 | goscip-shell system . . go. run alias_gen.go "encoding/json/v2" $JSONROOT |
| 44 | goscip-shell system . . go. run alias_gen.go "encoding/json/jsontext" $JSONROOT/jsontext |