forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrename-crates-for-2.0.sh
executable file
·126 lines (113 loc) · 4.27 KB
/
rename-crates-for-2.0.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
function rust_rename() {
sed -i "s/$1/$2/g" `grep -Rl --include="*.rs" --include="*.stderr" "$1" *` > /dev/null
}
function cargo_rename() {
find . -name "Cargo.toml" -exec sed -i "s/\(^\|[^\/]\)$1/\1$2/g" {} \;
}
function rename_gitlabci() {
sed -i "s/$1/$2/g" .gitlab-ci.yml
}
function rename() {
old=$(echo $1 | cut -f1 -d\ );
new=$(echo $1 | cut -f2 -d\ );
echo "Renaming $old to $new"
# rename in Cargo.tomls
cargo_rename $old $new
rename_gitlabci $old $new
# and it appears, we have the same syntax in rust files
rust_rename $old $new
# but generally we have the snail case syntax in rust files
old=$(echo $old | sed s/-/_/g );
new=$(echo $new | sed s/-/_/g );
echo " > $old to $new"
rust_rename $old $new
}
TO_RENAME=(
# OLD-CRATE-NAME NEW-CRATE-NAME
# post initial rename fixes
"sc-application-crypto sp-application-crypto"
"sp-transaction-pool-api sp-transaction-pool"
"sp-transaction-pool-runtime-api sp-transaction-pool"
"sp-core-storage sp-storage"
"transaction-factory node-transaction-factory"
"sp-finality-granpda sp-finality-grandpa"
"sp-sesssion sp-session"
"sp-tracing-pool sp-transaction-pool"
"sc-basic-authority sc-basic-authorship"
"sc-api sc-client-api"
"sc-database sc-client-db"
# PRIMITIVES
"substrate-application-crypto sp-application-crypto"
"substrate-authority-discovery-primitives sp-authority-discovery"
"substrate-block-builder-runtime-api sp-block-builder"
"substrate-consensus-aura-primitives sp-consensus-aura"
"substrate-consensus-babe-primitives sp-consensus-babe"
"substrate-consensus-common sp-consensus"
"substrate-consensus-pow-primitives sp-consensus-pow"
"substrate-primitives sp-core"
"substrate-debug-derive sp-debug-derive"
"substrate-primitives-storage sp-storage"
"substrate-externalities sp-externalities"
"substrate-finality-grandpa-primitives sp-finality-grandpa"
"substrate-inherents sp-inherents"
"substrate-keyring sp-keyring"
"substrate-offchain-primitives sp-offchain"
"substrate-panic-handler sp-panic-handler"
"substrate-phragmen sp-npos-elections"
"substrate-rpc-primitives sp-rpc"
"substrate-runtime-interface sp-runtime-interface"
"substrate-runtime-interface-proc-macro sp-runtime-interface-proc-macro"
"substrate-runtime-interface-test-wasm sp-runtime-interface-test-wasm"
"substrate-serializer sp-serializer"
"substrate-session sp-session"
"sr-api sp-api"
"sr-api-proc-macro sp-api-proc-macro"
"sr-api-test sp-api-test"
"sr-arithmetic sp-arithmetic"
"sr-arithmetic-fuzzer sp-arithmetic-fuzzer"
"sr-io sp-io"
"sr-primitives sp-runtime"
"sr-sandbox sp-sandbox"
"sr-staking-primitives sp-staking"
"sr-std sp-std"
"sr-version sp-version"
"substrate-state-machine sp-state-machine"
"substrate-transaction-pool-runtime-api sp-transaction-pool"
"substrate-trie sp-trie"
"substrate-wasm-interface sp-wasm-interface"
# # CLIENT
"substrate-client sc-client"
"substrate-client-api sc-client-api"
"substrate-authority-discovery sc-authority-discovery"
"substrate-basic-authorship sc-basic-authorship"
"substrate-block-builder sc-block-builder"
"substrate-chain-spec sc-chain-spec"
"substrate-chain-spec-derive sc-chain-spec-derive"
"substrate-cli sc-cli"
"substrate-consensus-aura sc-consensus-aura"
"substrate-consensus-babe sc-consensus-babe"
"substrate-consensus-pow sc-consensus-pow"
"substrate-consensus-slots sc-consensus-slots"
"substrate-consensus-uncles sc-consensus-uncles"
"substrate-client-db sc-client-db"
"substrate-executor sc-executor"
"substrate-runtime-test sc-runtime-test"
"substrate-finality-grandpa sc-finality-grandpa"
"substrate-keystore sc-keystore"
"substrate-network sc-network"
"substrate-offchain sc-offchain"
"substrate-peerset sc-peerset"
"substrate-rpc-servers sc-rpc-server"
"substrate-rpc sc-rpc"
"substrate-service sc-service"
"substrate-service-test sc-service-test"
"substrate-state-db sc-state-db"
"substrate-telemetry sc-telemetry"
"substrate-test-primitives sp-test-primitives"
"substrate-tracing sc-tracing"
);
for rule in "${TO_RENAME[@]}"
do
rename "$rule";
done