-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync-store-files.sh
executable file
·45 lines (36 loc) · 1.59 KB
/
sync-store-files.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
#!/bin/bash
# Update gatsby-config.js file
fastmod -m -d gatsby-config.js 'plugins: \[' 'plugins: [ { resolve: "@vtex/gatsby-source-cms", options: { tenant: config.api.storeId, workspace: "master", }, },';
# Update package.json file
fastmod -m -d package.json '"name": "base.store"' '"name": "storeframework.store"';
fastmod -m -d package.json '"@vtex/gatsby-plugin-thumbor": "\^(\d*.\d*.\d*)",' '"@vtex/gatsby-plugin-thumbor": "^${1}",
"@vtex/gatsby-source-cms": "^0.2.4",';
# Update src/pages/index.tsx file
## Remove section imports
fastmod -d src/pages/index.tsx "import.*/sections/.*\n" "";
### https://regex101.com/r/JYjCWE/2
fastmod -d src/pages/index.tsx "(import\sReact)(,\s\{.+\})?(.*'react')$" "\${1}\${3}
import RenderCMS from 'src/components/RenderCMS'";
## Component
fastmod -d src/pages/index.tsx 'data: \{ (.*)(allStore.*)\}' 'data: { ${1} cmsHome }';
fastmod -d src/pages/index.tsx "const\s(product|haveProduct).*" "";
fastmod -m -d src/pages/index.tsx 'Sections:.*</>$' 'CMS Sections */}<RenderCMS sections={cmsHome?.sections} /></>';
fastmod -d src/pages/institucional/about.tsx 'data: \{ (.*)(allStore.*)\}' 'data: { ${1} cmsInstitutional }';
fastmod -m -d src/pages/institucional/about.tsx 'Sections:.*</>$' 'CMS Sections */}<RenderCMS sections={cmsInstitutional?.sections} /></>';
## Query
fastmod -m -d src/pages/index.tsx "query\s(\w*)\s\{(.*)\}" "query \${1} {\${2}
cmsHome {
sections {
data
name
}
}
}";
fastmod -m -d src/pages/institucional/about.tsx "query\s(\w*)\s\{(.*)\}" "query \${1} {\${2}
cmsInstitutional {
sections {
data
name
}
}
}";