Skip to content

Commit 35e2c64

Browse files
authored
Merge pull request #1 from shellyln/feature-escape-250422a
* Enable escaping of user configured special characters in markdown. * Enable table filtering by user configured include/exclude. * Add config file. * Update README.
2 parents 464a9c7 + 358db8c commit 35e2c64

File tree

20 files changed

+798
-209
lines changed

20 files changed

+798
-209
lines changed

.tbls-sf-cli-meta.json

Lines changed: 0 additions & 2 deletions
This file was deleted.

.tbls-sf-cli-meta.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# tbls-sf-cli-meta driver config
2+
3+
# -------------------------------------------------------------
4+
5+
# Filter tables.
6+
# If the `include` key is present, it restricts the table to only those specified.
7+
# Then, if the `exclude` key is present, it excludes the specified tables.
8+
# The `include` and `exclude` keys are applied in that order.
9+
# The wildcard `*` can be used to match multiple characters.
10+
11+
include = [
12+
'*__c',
13+
'*__mdt',
14+
'Account',
15+
'Contact*',
16+
]
17+
exclude = [
18+
'Baz__*',
19+
]
20+
21+
22+
# -------------------------------------------------------------
23+
24+
# Escapes markdown special characters with a backslash. e.g. `*` -> '\*'
25+
# `def` is an object or array of objects such as `tables` or `columns` in the schema.
26+
# `prop` is a property of an object such as `name` or `type`.
27+
# 1. both `def` and `prop` match
28+
# 2. `prop` matches and `def` is an empty string
29+
# 3. `def` matches and `prop` is an empty string
30+
# 4. both `def` and `prop` are empty strings
31+
32+
[[escape]]
33+
def = ''
34+
prop = ''
35+
char = '$'
36+
37+
[[escape]]
38+
def = ''
39+
prop = 'extra_def'
40+
char = '$[~'
41+
42+
[[escape]]
43+
def = 'tables'
44+
prop = ''
45+
char = '$['
46+
47+
[[escape]]
48+
def = 'tables'
49+
prop = 'comment'
50+
char = '$[*'

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,57 @@ tbls doc
111111
[Sample document](sample/README.md)
112112

113113

114+
## ⚙️ Config (Optional)
115+
`./.tbls-sf-cli-meta.toml`
116+
```toml
117+
# Filter tables.
118+
# If the `include` key is present, it restricts the table to only those specified.
119+
# Then, if the `exclude` key is present, it excludes the specified tables.
120+
# The `include` and `exclude` keys are applied in that order.
121+
# The wildcard `*` can be used to match multiple characters.
122+
123+
include = [
124+
'*__c',
125+
'*__mdt',
126+
'Account',
127+
'Contact*',
128+
]
129+
exclude = [
130+
'Baz__*',
131+
]
132+
133+
134+
# -------------------------------------------------------------
135+
136+
# Escapes markdown special characters with a backslash. e.g. `*` -> '\*'
137+
# `def` is an object or array of objects such as `tables` or `columns` in the schema.
138+
# `prop` is a property of an object such as `name` or `type`.
139+
# 1. both `def` and `prop` match
140+
# 2. `prop` matches and `def` is an empty string
141+
# 3. `def` matches and `prop` is an empty string
142+
# 4. both `def` and `prop` are empty strings
143+
144+
[[escape]]
145+
def = ''
146+
prop = ''
147+
char = '$'
148+
149+
[[escape]]
150+
def = ''
151+
prop = 'extra_def'
152+
char = '$[~'
153+
154+
[[escape]]
155+
def = 'tables'
156+
prop = ''
157+
char = '$['
158+
159+
[[escape]]
160+
def = 'tables'
161+
prop = 'comment'
162+
char = '$[*'
163+
```
164+
114165
## 📦 CI
115166
### On GitHub Actions:
116167

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<actionOverrides>
4+
<actionName>Accept</actionName>
5+
<type>Default</type>
6+
</actionOverrides>
7+
<actionOverrides>
8+
<actionName>Accept</actionName>
9+
<formFactor>Large</formFactor>
10+
<type>Default</type>
11+
</actionOverrides>
12+
<actionOverrides>
13+
<actionName>Accept</actionName>
14+
<formFactor>Small</formFactor>
15+
<type>Default</type>
16+
</actionOverrides>
17+
<actionOverrides>
18+
<actionName>CancelEdit</actionName>
19+
<type>Default</type>
20+
</actionOverrides>
21+
<actionOverrides>
22+
<actionName>CancelEdit</actionName>
23+
<formFactor>Large</formFactor>
24+
<type>Default</type>
25+
</actionOverrides>
26+
<actionOverrides>
27+
<actionName>CancelEdit</actionName>
28+
<formFactor>Small</formFactor>
29+
<type>Default</type>
30+
</actionOverrides>
31+
<actionOverrides>
32+
<actionName>Clone</actionName>
33+
<type>Default</type>
34+
</actionOverrides>
35+
<actionOverrides>
36+
<actionName>Clone</actionName>
37+
<formFactor>Large</formFactor>
38+
<type>Default</type>
39+
</actionOverrides>
40+
<actionOverrides>
41+
<actionName>Clone</actionName>
42+
<formFactor>Small</formFactor>
43+
<type>Default</type>
44+
</actionOverrides>
45+
<actionOverrides>
46+
<actionName>Delete</actionName>
47+
<type>Default</type>
48+
</actionOverrides>
49+
<actionOverrides>
50+
<actionName>Delete</actionName>
51+
<formFactor>Large</formFactor>
52+
<type>Default</type>
53+
</actionOverrides>
54+
<actionOverrides>
55+
<actionName>Delete</actionName>
56+
<formFactor>Small</formFactor>
57+
<type>Default</type>
58+
</actionOverrides>
59+
<actionOverrides>
60+
<actionName>Edit</actionName>
61+
<type>Default</type>
62+
</actionOverrides>
63+
<actionOverrides>
64+
<actionName>Edit</actionName>
65+
<formFactor>Large</formFactor>
66+
<type>Default</type>
67+
</actionOverrides>
68+
<actionOverrides>
69+
<actionName>Edit</actionName>
70+
<formFactor>Small</formFactor>
71+
<type>Default</type>
72+
</actionOverrides>
73+
<actionOverrides>
74+
<actionName>List</actionName>
75+
<type>Default</type>
76+
</actionOverrides>
77+
<actionOverrides>
78+
<actionName>List</actionName>
79+
<formFactor>Large</formFactor>
80+
<type>Default</type>
81+
</actionOverrides>
82+
<actionOverrides>
83+
<actionName>List</actionName>
84+
<formFactor>Small</formFactor>
85+
<type>Default</type>
86+
</actionOverrides>
87+
<actionOverrides>
88+
<actionName>New</actionName>
89+
<type>Default</type>
90+
</actionOverrides>
91+
<actionOverrides>
92+
<actionName>New</actionName>
93+
<formFactor>Large</formFactor>
94+
<type>Default</type>
95+
</actionOverrides>
96+
<actionOverrides>
97+
<actionName>New</actionName>
98+
<formFactor>Small</formFactor>
99+
<type>Default</type>
100+
</actionOverrides>
101+
<actionOverrides>
102+
<actionName>SaveEdit</actionName>
103+
<type>Default</type>
104+
</actionOverrides>
105+
<actionOverrides>
106+
<actionName>SaveEdit</actionName>
107+
<formFactor>Large</formFactor>
108+
<type>Default</type>
109+
</actionOverrides>
110+
<actionOverrides>
111+
<actionName>SaveEdit</actionName>
112+
<formFactor>Small</formFactor>
113+
<type>Default</type>
114+
</actionOverrides>
115+
<actionOverrides>
116+
<actionName>Tab</actionName>
117+
<type>Default</type>
118+
</actionOverrides>
119+
<actionOverrides>
120+
<actionName>Tab</actionName>
121+
<formFactor>Large</formFactor>
122+
<type>Default</type>
123+
</actionOverrides>
124+
<actionOverrides>
125+
<actionName>Tab</actionName>
126+
<formFactor>Small</formFactor>
127+
<type>Default</type>
128+
</actionOverrides>
129+
<actionOverrides>
130+
<actionName>View</actionName>
131+
<type>Default</type>
132+
</actionOverrides>
133+
<actionOverrides>
134+
<actionName>View</actionName>
135+
<formFactor>Large</formFactor>
136+
<type>Default</type>
137+
</actionOverrides>
138+
<actionOverrides>
139+
<actionName>View</actionName>
140+
<formFactor>Small</formFactor>
141+
<type>Default</type>
142+
</actionOverrides>
143+
<allowInChatterGroups>true</allowInChatterGroups>
144+
<compactLayoutAssignment>SYSTEM</compactLayoutAssignment>
145+
<deploymentStatus>Deployed</deploymentStatus>
146+
<enableActivities>true</enableActivities>
147+
<enableBulkApi>true</enableBulkApi>
148+
<enableFeeds>false</enableFeeds>
149+
<enableHistory>true</enableHistory>
150+
<enableLicensing>false</enableLicensing>
151+
<enableReports>true</enableReports>
152+
<enableSearch>true</enableSearch>
153+
<enableSharing>true</enableSharing>
154+
<enableStreamingApi>true</enableStreamingApi>
155+
<externalSharingModel>Private</externalSharingModel>
156+
<label>Baz</label>
157+
<nameField>
158+
<label>Baz Name</label>
159+
<trackHistory>false</trackHistory>
160+
<type>Text</type>
161+
</nameField>
162+
<recordTypeTrackHistory>false</recordTypeTrackHistory>
163+
<searchLayouts></searchLayouts>
164+
<sharingModel>ReadWrite</sharingModel>
165+
<visibility>Public</visibility>
166+
</CustomObject>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ListView xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<fullName>All</fullName>
4+
<filterScope>Everything</filterScope>
5+
<label>All</label>
6+
</ListView>

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module github.com/shellyln/tbls-driver-sf-cli-meta
22

33
go 1.24
4+
5+
require github.com/shellyln/go-loose-json-parser v0.0.19
6+
7+
require github.com/shellyln/takenoco v0.0.11 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/shellyln/go-loose-json-parser v0.0.19 h1:LljbQd5z86bVqptx4mitSM9x6I3BXUpw3djvNyeWG2I=
2+
github.com/shellyln/go-loose-json-parser v0.0.19/go.mod h1:+uqxOjjXySGytWAnFgBdG6i59yz3FBlpfulsaL+L7Ow=
3+
github.com/shellyln/takenoco v0.0.11 h1:MqO+Qtc4h583pTb8xwndpGSqoVlcNR9O/n4LGQ5CgLI=
4+
github.com/shellyln/takenoco v0.0.11/go.mod h1:SF6jGo3dFtcTgstpXGTJoKXPOldlDwV8R5U1znhEets=

pkg/driver/config.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package driver
2+
3+
import (
4+
"os"
5+
"path"
6+
7+
"github.com/shellyln/go-loose-json-parser/jsonlp"
8+
"github.com/shellyln/go-loose-json-parser/marshal"
9+
)
10+
11+
func ReadConfig(curDir string) (*CfDriverConfig, error) {
12+
var config CfDriverConfig
13+
14+
bytes, err := os.ReadFile(path.Join(curDir, ".tbls-sf-cli-meta.toml"))
15+
if err != nil {
16+
if !os.IsNotExist(err) {
17+
return nil, err
18+
}
19+
} else {
20+
//json.Unmarshal(bytes, &config)
21+
parsed, err := jsonlp.ParseTOML(string(bytes), jsonlp.Linebreak_Lf, jsonlp.Interop_None)
22+
if err != nil {
23+
return nil, err
24+
}
25+
if err := marshal.Unmarshal(parsed, &config, nil); err != nil {
26+
return nil, err
27+
}
28+
}
29+
return &config, nil
30+
}

pkg/driver/datasource.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ import (
88
"strings"
99
)
1010

11-
func makeBaseDir() (string, error) {
12-
baseDir, err := os.Getwd()
13-
if err != nil {
14-
return "", err
15-
}
16-
11+
func MakeBaseDir(curDir string) (string, error) {
12+
baseDir := curDir
1713
dataSourceName := os.Getenv("TBLS_DSN")
1814
if len(dataSourceName) > 0 {
1915
pos := strings.Index(dataSourceName, ":")

0 commit comments

Comments
 (0)