-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (41 loc) · 1.92 KB
/
Makefile
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
.PHONY: setup generate
SHELL = zsh
setup:
if ! brew list csvkit > /dev/null; then \
brew install csvkit; \
fi
pip install lxml pandas html5lib beautifulsoup4
# - for all sheets
# TODO change columna to notes
generate: setup
in2csv --write-sheets "-" -f xls ./NetSuitePermissionsUsage_2024.1.xls
RAW_CATALOG_JSON ?= data/raw_record_catalog.json
CATALOG_JSON ?= data/record_catalog.json
ENRICHED_CATALOG_JSON ?= data/enriched_record_catalog.json
TIM_TABLE_JSON ?= data/tim_table.json
# output files
OUTPUT_CATALOG_CSV ?= output/netsuite_record_catalog.csv
OUTPUT_TIM_TABLE_CSV ?= output/tim_table.csv
$(ENRICHED_CATALOG_JSON):
@if [ -z "$$NETSUITE_ACCOUNT" ]; then \
echo "NETSUITE_ACCOUNT is not set"; \
exit 1; \
fi
@if [ -z "$$NETSUITE_COOKIE" ]; then \
echo "NETSUITE_COOKIE is not set"; \
exit 1; \
fi
@http GET https://$$NETSUITE_ACCOUNT.app.netsuite.com/app/recordscatalog/rcendpoint.nl action==getRecordTypes data=='{"structureType":"FLAT"}' "Cookie: $(NETSUITE_COOKIE)" > $(RAW_CATALOG_JSON) | \
zq -f json -o $(RAW_CATALOG_JSON) 'yield data | over this | where not grep(/^CUSTOMLIST/, id) | where not grep(/^CUSTOMRECORD/, id) | collect(this)' -
@zq -f json -o $(CATALOG_JSON) 'over this | yield {id,label:grep("Missing label", this.label) ? null : this.label} | collect(this)' $(RAW_CATALOG_JSON)
@python records_catalog.py $(CATALOG_JSON) > $(ENRICHED_CATALOG_JSON)
$(TIM_TABLE_JSON):
@python tim_table.py > $(TIM_TABLE_JSON)
# normalize the tim table to same columns as the netsuite catalog
$(OUTPUT_TIM_TABLE_CSV): $(TIM_TABLE_JSON)
zq -f csv -o $(OUTPUT_TIM_TABLE_CSV) 'over this | yield {tableName:this["Table Name"],tableId:this["Table ID"],permission:this["Permission Needed"]}' $(TIM_TABLE_JSON)
$(OUTPUT_CATALOG_CSV): $(ENRICHED_CATALOG_JSON)
@zq -f csv -o $(OUTPUT_CATALOG_CSV) -I netsuite_catalog_simplify.zed $(ENRICHED_CATALOG_JSON)
all:
@$(MAKE) $(OUTPUT_CATALOG_CSV)
@$(MAKE) $(OUTPUT_TIM_TABLE_CSV)