roll-right 0.1.4 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +467 -219
- package/bin/index.js +181 -93
- package/docs/rr-background.md +35 -0
- package/historical/old_index.js +95 -0
- package/index.js +0 -6
- package/lib/PreStagingSubsitutions.js +64 -0
- package/lib/SkelToTemplate.js +4016 -0
- package/lib/TemplateToPreStaging.js +433 -0
- package/lib/bundle_directives.js +48 -0
- package/lib/html_directives.js +52 -0
- package/lib/mod_utils.js +1 -2
- package/lib/phase1.js +8 -68
- package/lib/phase2.js +13 -11
- package/lib/rr_utils.js +7 -15
- package/lib/sys_utils.js +36 -0
- package/lib/utils.js +350 -42
- package/package.json +10 -7
- package/test/index.js +30 -2
- package/testme.txt +3885 -0
- package/tools/genpage.js +34 -11
- package/tools/subst_to_vars.js +48 -0
package/tools/genpage.js
CHANGED
|
@@ -33,6 +33,13 @@ function reset_svg_height_width(svg_txt, output_width, output_height) {
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if this object passed has fields specifying a file to be read.
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* @param {object} descr
|
|
41
|
+
* @returns {boolean}
|
|
42
|
+
*/
|
|
36
43
|
function is_file_source(descr) {
|
|
37
44
|
return ((typeof descr === 'object') && ( descr.file || ( descr.content && descr.content.file ) || ( descr.button && descr.button.file ) ))
|
|
38
45
|
}
|
|
@@ -40,8 +47,14 @@ function is_file_source(descr) {
|
|
|
40
47
|
|
|
41
48
|
|
|
42
49
|
var g_compiler_schedule = []
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Given a descriptor of a file to load and read, this function reads the
|
|
52
|
+
* file, and provides the descriptor with the data for later compilation and substitution.
|
|
53
|
+
*
|
|
54
|
+
* @param {object} datObj
|
|
55
|
+
* @param {object} descr
|
|
56
|
+
*/
|
|
57
|
+
function process_sub_content(datObj,descr) {
|
|
45
58
|
let src_file = descr.file ? descr.file : ( descr.content ? descr.content.file : descr.button.file );
|
|
46
59
|
try {
|
|
47
60
|
if ( src_file[0] === '.' ) {
|
|
@@ -72,11 +85,22 @@ function process_sub_content(datObj,descr) {
|
|
|
72
85
|
|
|
73
86
|
|
|
74
87
|
var g_forgotten_files = []
|
|
88
|
+
/**
|
|
89
|
+
* Takes in a substitution descriptor and a source to apply it to.
|
|
90
|
+
* It pushes the parmeters onto a stack of substitution directives, the compiler schedule.
|
|
91
|
+
* Then, it looks in the substitution descriptor to find files that might be processed before
|
|
92
|
+
* being placed into the final substitution yielding the output.
|
|
93
|
+
*
|
|
94
|
+
* The order is important, most specific to least specific, that being the contents of the output file.
|
|
95
|
+
*
|
|
96
|
+
* @param {object} datObj
|
|
97
|
+
* @param {string} src
|
|
98
|
+
*/
|
|
75
99
|
function load_source_data(datObj,src) {
|
|
76
|
-
g_compiler_schedule.unshift({ 'data' : datObj, 'source' : src })
|
|
100
|
+
g_compiler_schedule.unshift({ 'data' : datObj, 'source' : src }) // recall this is push
|
|
77
101
|
for ( let field in datObj ) {
|
|
78
102
|
let descr = datObj[field]
|
|
79
|
-
if ( (typeof descr === 'object') &&
|
|
103
|
+
if ( (typeof descr === 'object') && Array.isArray(descr) ) {
|
|
80
104
|
descr.forEach(element => {
|
|
81
105
|
if ( is_file_source(element) ) {
|
|
82
106
|
process_sub_content(datObj,element)
|
|
@@ -89,25 +113,24 @@ function load_source_data(datObj,src) {
|
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
116
|
// STARTS HERE...
|
|
96
117
|
|
|
97
118
|
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
let data_file = process.argv[2] // a subst file
|
|
120
|
+
let source_file = process.argv[3] // a template file file
|
|
121
|
+
let output = process.argv[4] // an html file
|
|
122
|
+
let static_dir = process.argv[5]
|
|
101
123
|
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
|
102
124
|
|
|
103
125
|
|
|
104
126
|
console.log("SOURCE FILE: " + source_file)
|
|
127
|
+
console.log("STATIC DIR: " + static_dir)
|
|
105
128
|
|
|
106
129
|
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
|
107
130
|
var data = fs.readFileSync(data_file,'ascii').toString()
|
|
108
131
|
var confObj = JSON.parse(data)
|
|
109
132
|
//
|
|
110
|
-
confObj.srcPath =
|
|
133
|
+
confObj.srcPath = static_dir
|
|
111
134
|
var source = fs.readFileSync(source_file,'utf8').toString()
|
|
112
135
|
load_source_data(confObj,source)
|
|
113
136
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const fs = require('fs')
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function pull_out_keys_deep(conf,prefix = "") {
|
|
11
|
+
let keys = Object.keys(conf)
|
|
12
|
+
let pulled_kys = []
|
|
13
|
+
for ( let key of keys ) {
|
|
14
|
+
let ky_data = conf[key]
|
|
15
|
+
if ( typeof ky_data === 'string' ) {
|
|
16
|
+
pulled_kys.push(key)
|
|
17
|
+
} else if ( typeof ky_data === 'object' ) {
|
|
18
|
+
let subkys = pull_out_keys_deep(ky_data,key)
|
|
19
|
+
pulled_kys = pulled_kys.concat(subkys)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if ( prefix.length > 0 ) {
|
|
23
|
+
let final_keys = pulled_kys.map((ky) => { return `${prefix}.${ky}`})
|
|
24
|
+
return final_keys
|
|
25
|
+
} else {
|
|
26
|
+
return pulled_kys
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
let input_file_name = process.argv[2]
|
|
32
|
+
|
|
33
|
+
if ( !input_file_name ) {
|
|
34
|
+
console.log("you need to pass a subst file name as a parameter")
|
|
35
|
+
process.exit(0)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
let conf_str = fs.readFileSync(input_file_name)
|
|
40
|
+
try {
|
|
41
|
+
let conf = JSON.parse(conf_str)
|
|
42
|
+
if ( typeof conf === "object" ) {
|
|
43
|
+
let conf_as_array = pull_out_keys_deep(conf)
|
|
44
|
+
console.log(JSON.stringify(conf_as_array,null,4))
|
|
45
|
+
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.log(e)
|
|
48
|
+
}
|