roll-right 0.1.4 → 0.2.0
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 +4005 -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/bin/index.js
CHANGED
|
@@ -1,94 +1,170 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
3
|
+
const fos = require('extra-file-class')()
|
|
4
|
+
|
|
5
|
+
// @target -- concern's directory for receiving templates
|
|
6
|
+
// @concern -- the business, app, tool, or other that is receiving a code asset into it's template, pre-staging, or staging directories
|
|
7
|
+
// @kernel -- in script processing -- e.g. [app<scripts>]/file.js -- as special code for a concern -- here, kenerl is 'scripts'
|
|
8
|
+
// @<type> -- a type specification
|
|
9
|
+
// @params< -- the intake parameter descriptions for a sub-template file -- might be of type ".smplt"
|
|
10
|
+
// @list< -- parameter breakout for list entities
|
|
11
|
+
// @nothing -- allows for a conditional to create empty lines for either positive or negative conditions
|
|
12
|
+
// @{} -- configuration substitutions done before parsing a skeleton
|
|
14
13
|
//
|
|
15
14
|
|
|
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
|
-
|
|
15
|
+
// Minimist is a command line parsing package.
|
|
16
|
+
let g_argv = require('minimist')(process.argv.slice(2));
|
|
17
|
+
|
|
18
|
+
const SkelToTemplate = require('../lib/SkelToTemplate')
|
|
19
|
+
const TemplatesToPreStaging = require('../lib/TemplateToPreStaging')
|
|
20
|
+
const PreStagingSubsitutions = require('../lib/PreStagingSubsitutions')
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Addesses the use case available from the command line.
|
|
25
|
+
*
|
|
26
|
+
* There are three cases, one for each phase of page generation starting
|
|
27
|
+
* from the first use of skeletons and ending with final pages.
|
|
28
|
+
*
|
|
29
|
+
* 1. prepare
|
|
30
|
+
* 2. template
|
|
31
|
+
* 3. page (also can use 'assign' as in variable assignment that ends up on the page)
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* case 1:
|
|
35
|
+
* args.phase === 'prepare'
|
|
36
|
+
* args.sources -- directory where the generator file and other files for input and output will be found
|
|
37
|
+
* args.generator -- the name of the JSON file that contains the map between inputs and outputs and directory overrides.
|
|
38
|
+
* args.structure -- where to put the intermediate parsing data for use in the next phase
|
|
39
|
+
*
|
|
40
|
+
* Included in "package.json".scripts
|
|
41
|
+
* "prepare" : "node bin/index.js --phase prepare --sources ../websites/template-configs/ --generator generate.json --structure parsed.json"
|
|
42
|
+
*
|
|
43
|
+
* npm default command:
|
|
44
|
+
* npm run prepare
|
|
45
|
+
*
|
|
46
|
+
* CLI cmd:
|
|
47
|
+
*
|
|
48
|
+
* roll-right --phase prepare --sources ../websites/template-configs/ --generator generate.json --structure parsed.json
|
|
49
|
+
*
|
|
50
|
+
* case 2:
|
|
51
|
+
* args.phase === 'template'
|
|
52
|
+
* args.sources -- directory where the generator file and other files for input and output will be found
|
|
53
|
+
* args.generator -- the name of the JSON file that contains the map between inputs and outputs and directory overrides.
|
|
54
|
+
* args.structure -- where to put the intermediate parsing data for use in the next phase
|
|
55
|
+
*
|
|
56
|
+
* Included in "package.json".scripts
|
|
57
|
+
* "templates" : "node bin/index.js --phase template --sources ../websites/template-configs/ --generator generate.json --structure parsed.json"
|
|
58
|
+
*
|
|
59
|
+
* npm default command:
|
|
60
|
+
* npm run templates
|
|
61
|
+
*
|
|
62
|
+
* CLI cmd:
|
|
63
|
+
*
|
|
64
|
+
* roll-right --phase template --sources ../websites/template-configs/ --generator generate.json --structure parsed.json
|
|
65
|
+
*
|
|
66
|
+
* case 3:
|
|
67
|
+
* args.phase === 'templates'
|
|
68
|
+
* args.values -- name of a conf file that contains global values for the websites and other substitution information
|
|
69
|
+
*
|
|
70
|
+
* Included in "package.json".scripts
|
|
71
|
+
* "page" : "node bin/index.js --phase assign --sources ../websites/template-configs/ --values assignments.json"
|
|
72
|
+
*
|
|
73
|
+
* roll-right --phase assign --sources ../websites/template-configs/ --values assignments.json
|
|
74
|
+
*
|
|
75
|
+
*
|
|
76
|
+
* @param {object} args - the data structure returned by minimist
|
|
77
|
+
*/
|
|
78
|
+
async function command_line_operations_new(args) {
|
|
79
|
+
let phase = args.phase
|
|
80
|
+
//
|
|
81
|
+
if ( phase ) {
|
|
82
|
+
//
|
|
83
|
+
console.log("Operating phase:\t\t\t\t\t", phase)
|
|
84
|
+
switch ( args.phase ) {
|
|
85
|
+
case "prepare" :
|
|
86
|
+
case 1: { /// creates templates
|
|
87
|
+
let project_dir = args.sources // for instance [website]/template-configs
|
|
88
|
+
let generator = args.generator // a string ... for instance generate.json
|
|
89
|
+
generator = `${project_dir}${generator}`
|
|
90
|
+
console.log("Using input configuration for generator:\t\t",generator)
|
|
91
|
+
//
|
|
92
|
+
let parsed = args.structure
|
|
93
|
+
parsed = `${project_dir}${parsed}`
|
|
94
|
+
console.log("Using output to configuration for template formation:\t\t",parsed)
|
|
95
|
+
|
|
96
|
+
// only works if there is a configuration file
|
|
97
|
+
let conf = await fos.load_json_data_at_path(generator)
|
|
98
|
+
if ( conf ) {
|
|
99
|
+
conf.top_level_parsed = parsed // path to output in the template configuration directory (use globally)
|
|
100
|
+
let to_templates = new SkelToTemplate(conf)
|
|
101
|
+
to_templates.set_project_directory(project_dir)
|
|
102
|
+
await to_templates.prepare_directories() // makes sure the output directories exists (in any case)
|
|
103
|
+
await to_templates.skeleton_unification() // parsing and primary evaluations
|
|
104
|
+
await to_templates.write_templates_op_data() // generate db files and parse data structure and output update
|
|
61
105
|
}
|
|
106
|
+
break
|
|
62
107
|
}
|
|
63
|
-
}
|
|
64
|
-
} catch (e) {
|
|
65
|
-
console.log(e)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
async function command_line_operations() {
|
|
71
|
-
console.log("command line operations")
|
|
72
|
-
|
|
73
|
-
if ( g_argv.phase ) {
|
|
74
|
-
console.log(`starting phase ${g_argv.phase} instantiation`)
|
|
75
|
-
switch ( g_argv.phase ) {
|
|
76
108
|
case "template" :
|
|
77
|
-
case
|
|
78
|
-
|
|
79
|
-
|
|
109
|
+
case 2: {
|
|
110
|
+
let project_dir = args.sources
|
|
111
|
+
let generator = args.generator // a string
|
|
112
|
+
generator = `${project_dir}${generator}`
|
|
113
|
+
console.log("Using input configuration from generation:\t\t",generator)
|
|
114
|
+
//
|
|
115
|
+
let parsed = args.structure
|
|
116
|
+
parsed = `${project_dir}${parsed}`
|
|
117
|
+
console.log("Using input configuration for template formation:\t\t",parsed)
|
|
118
|
+
let conf = await fos.load_json_data_at_path(generator)
|
|
119
|
+
if ( conf ) {
|
|
120
|
+
let to_templates = new SkelToTemplate(conf)
|
|
121
|
+
to_templates.set_project_directory(project_dir)
|
|
122
|
+
await to_templates.prepare_directories() // needed even when loading previously parsed data.
|
|
123
|
+
await to_templates.load_ogroups_intermediate_files()
|
|
124
|
+
let parsed_skels = await fos.load_json_data_at_path(parsed)
|
|
125
|
+
let concerns = false
|
|
126
|
+
if ( parsed_skels ) {
|
|
127
|
+
// regenerates with changes provided by custom settings developed after the prepare
|
|
128
|
+
// stage of the processing. This will be out of the way before any substitution
|
|
129
|
+
// objects are created.
|
|
130
|
+
concerns = await to_templates.generate_all_concerns_templates(parsed_skels)
|
|
131
|
+
} else {
|
|
132
|
+
console.log("did not load " + parsed)
|
|
133
|
+
}
|
|
134
|
+
// If the customized regeneration process has succeeded, then create susbtitution
|
|
135
|
+
// objects.
|
|
136
|
+
if ( concerns ) {
|
|
137
|
+
let to_pre_staging = new TemplatesToPreStaging(conf)
|
|
138
|
+
to_pre_staging.set_project_directory(project_dir)
|
|
139
|
+
let subst_defs = await to_pre_staging.prepare_files_and_substitutions(concerns)
|
|
140
|
+
await to_pre_staging.publish_subs_defs(subst_defs)
|
|
141
|
+
}
|
|
142
|
+
//
|
|
80
143
|
}
|
|
81
|
-
let ph1 = new Phase1(g_target,g_config.alpha) // g_target <- args[0] ... g_config <- read <- g_source_dir <- args[1]
|
|
82
|
-
ph1.run()
|
|
83
144
|
break
|
|
84
145
|
}
|
|
85
|
-
case "page":
|
|
86
|
-
case
|
|
87
|
-
|
|
88
|
-
|
|
146
|
+
case "page" :
|
|
147
|
+
case "assign" :
|
|
148
|
+
case 3: {
|
|
149
|
+
//
|
|
150
|
+
let project_dir = args.sources
|
|
151
|
+
let substitutions = args.values
|
|
152
|
+
substitutions = `${project_dir}${substitutions}`
|
|
153
|
+
console.log("Using input configuration for assignments:\t\t",substitutions)
|
|
154
|
+
//
|
|
155
|
+
let conf = await fos.load_json_data_at_path(substitutions)
|
|
156
|
+
if ( conf ) {
|
|
157
|
+
//
|
|
158
|
+
let to_pre_staging = new PreStagingSubsitutions(conf)
|
|
159
|
+
to_pre_staging.set_project_directory(project_dir)
|
|
160
|
+
console.log(to_pre_staging.project_dir)
|
|
161
|
+
let concerns_file = `${to_pre_staging.project_dir}/concerns_to_files.json`
|
|
162
|
+
console.log("concerns file",concerns_file)
|
|
163
|
+
let concerns = await fos.load_json_data_at_path(concerns_file)
|
|
164
|
+
await to_pre_staging.process_files(concerns)
|
|
165
|
+
//
|
|
89
166
|
}
|
|
90
|
-
|
|
91
|
-
ph2.run()
|
|
167
|
+
//
|
|
92
168
|
break
|
|
93
169
|
}
|
|
94
170
|
default : {
|
|
@@ -96,22 +172,34 @@ async function command_line_operations() {
|
|
|
96
172
|
break;
|
|
97
173
|
}
|
|
98
174
|
}
|
|
175
|
+
//
|
|
176
|
+
} else {
|
|
177
|
+
console.log("-------------------------------------------------------------")
|
|
178
|
+
let usage = `
|
|
179
|
+
The configuration file will be found in the sources directory.
|
|
180
|
+
|
|
181
|
+
phase 1:
|
|
182
|
+
roll-right --phase prepare --sources <directory containing configuration files> --generator <name of config file>.json --structure <name of file to output parsing structure>.json
|
|
183
|
+
|
|
184
|
+
phase 2:
|
|
185
|
+
roll-right --phase template --sources <directory containing configuration files> --generator <name of config file>.json --structure <name of file to input parsing structure>.json
|
|
186
|
+
|
|
187
|
+
phase 3:
|
|
188
|
+
roll-right --phase assign --sources <directory containing configuration files> --values <variable substitutions site-wide>.json
|
|
189
|
+
`
|
|
190
|
+
console.log(usage)
|
|
99
191
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
g_config.modules = load_json_file(g_config.gather)
|
|
103
|
-
}
|
|
104
|
-
read_data(g_config.gather)
|
|
105
|
-
}
|
|
106
|
-
if ( g_argv.modules ) { // transforms and then copies base alpha code to final publication directores (npm is the only case yet)
|
|
107
|
-
if ( typeof g_config.modules === "string" ) {
|
|
108
|
-
g_config.modules = load_json_file(g_config.modules)
|
|
109
|
-
}
|
|
110
|
-
port_modules(g_config.modules,g_argv)
|
|
111
|
-
}
|
|
192
|
+
|
|
193
|
+
console.log("-------------------------------------------------------------")
|
|
112
194
|
|
|
113
195
|
}
|
|
114
196
|
|
|
115
197
|
|
|
198
|
+
console.log("-------------------------------------------------------------")
|
|
199
|
+
console.log("roll-right static content management and module publication")
|
|
200
|
+
console.log("-------------------------------------------------------------")
|
|
201
|
+
|
|
202
|
+
// command_line_operations()
|
|
203
|
+
|
|
116
204
|
|
|
117
|
-
|
|
205
|
+
command_line_operations_new(g_argv)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# roll-right background
|
|
2
|
+
|
|
3
|
+
The tool is the result of having no desire to spend all day making web pages and other interfaces.
|
|
4
|
+
|
|
5
|
+
This project started out as something to help save time. Sometimes it did, sometimes work on the output progressed faster. It started out as something to keep small and generated some output web pages. Then, I edited its end results by hand. But, there is a need to propagate improvements made directly to the outputs of this tool. So, there is a need to take snippets from edge-of-the-envelope textual artifacts back into the pool of snippets the tool reads, and then use this tool again to change/upgrade all textual artifacts using the snippet repository. As a result, I revisited this project and started making something that is more like a web page compiler. Also, I have a framework for PWAs (progressive web apps) that this tool can be applied to. (The aim of this side trip is to shutdown a certain amount of interface creation labor.)
|
|
6
|
+
|
|
7
|
+
Making UI components is not a bad thing to do, in fact, it's quite good. But, why should it take longer than expected? Indeed, there are minutia, weird practices by different interface communities, gotchas, and more. Something as simple in concept as CSS has turned into a strange black art sort of quagmire yielding heaps of frustration. There are so many times that CSS magic fails to get to the goal and some JavaScript has to be added.
|
|
8
|
+
|
|
9
|
+
Once a final interface goal has been reached, it's change may have been worked out for one final output page. But, a website manager may have a number of pages required as outputs. It follows that there is a huge chore (which can always be put off) to put successful changes into all the output pages an organization might manage. A small website company could end up spending countless hours taking keeping code up to date with local bug fixes. So, some better process is needed.
|
|
10
|
+
|
|
11
|
+
Here, the idea is that there should be a repository of snippets and skeletons of output pages. A process requiring configuration files reflecting choices made by the user of the program, can take use the skeletons to generate outputs. Changes can be put into a common code base, skeletons can be brought up to date, choice interface markup can be stored in a repository. Then, one tool can roll the changes forward into final outputs. If users have content already made for the sites, the tool could move quickly through all phases (one run) and output updates. But, a user could also start up a new concern and add content to sections described to the user by intermediate outputs of the tool, so the user could make changes between running phases of the tool.
|
|
12
|
+
|
|
13
|
+
**roll-right** works in phases. Each phase generates outputs and configurations for use in the next phase, until the final outputs are placed into a "staging" directory. In the end, the staging directory should be something that can be copied to a server directory where a web server looks for web pages and code pages.
|
|
14
|
+
|
|
15
|
+
#### Composition (skeletons to templates)
|
|
16
|
+
|
|
17
|
+
This tool mainly puts together snippets into final forms, files, directories. It does not attempt to know much, but is useful where replication with small differences works. That is, it is not going to be better than just copying files if that is all that has to be done. Also, it is not an automatic programming agent (at least no yet).
|
|
18
|
+
|
|
19
|
+
***This tool is good at making templates that then get customization, personalization, etc. via a substitution process.***
|
|
20
|
+
|
|
21
|
+
### not a component library
|
|
22
|
+
|
|
23
|
+
I don't think of skeleton files as components. These are pre-temlates. The tool reads them in order to produces HTML templates. The HTML templates can have values inserted into them by tools such as [mustache](https://mustache.github.io/).
|
|
24
|
+
|
|
25
|
+
The skeletons provide definitions of structure, program inclusion, etc. The skeletons keep a record of the shape of the page, the kinds of programs it run, and helps manage what should be included in the text of the page versus what should be loaded through deferred links. The output can be expected to be static in the sense that HTML (or other) does not refer to a server to rewrite its view structurally. Some of the pages I have generated include Svelte components that update when retrieving data from the server. But, the page does not become another interface, in the sense that a grid of movie choices does not turn into an editor. **roll-right** does not provide a server that generates HTML for given URL APIs. It just reads the skeletons and turns them into the pages needed by a concern. Some of those pages might include component based apps.
|
|
26
|
+
|
|
27
|
+
* Components, such as the kind made with Svelte, allow for the extension of markup by adding tags with parameters. The component is expected to come with code, HTML, and CSS. The HTML within a component may use tags that are imported into the component program. In some sense, each component is a subroutine, a part of a maintained code base.
|
|
28
|
+
|
|
29
|
+
* Skeletons import/generate everything that they are told to import/generate and what they import/generate becomes part of the text of the program. Skeletons refer to big chunks of code to use, numerous chunks of code, and very commonly used markup structure. All of these inclusions are part of a common code base, that a web manager maintains. The skeleton files should be fairly short, say thirty to a hundred lines, and be used to generate a few thousand lines along with bundles for components used across skeletons.
|
|
30
|
+
|
|
31
|
+
Skeletons are used to generate different versions of outputs that are configured into working single page files, with some possible external links to maintained bundles. Likely, the different versions, which are different structurally, should have been proven to work so that the output generation is a selection of a view structure or program application type, rather than something to debug.
|
|
32
|
+
|
|
33
|
+
> In spite of the aim of this project, other kinds of text files can be output through the process, including programs, documents, art.
|
|
34
|
+
|
|
35
|
+
If the skeleton is used to generate a component, such as the kind made using Svelte, it will first create a template in preparation for variable substitution, then it will output the artifacts for the component in a pre-staging directory (a build directory). In other words, it carries out the same process of a static HTML file to build whatever. (Depending on the glossary of directives available in a roll-right release, this may be any kind of program.) After that, the build tools for the components will have to be applied in order to finalize the component for release.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
|
|
2
|
+
const {transfer_node_module_browser_version} = require('../lib/rr_utils')
|
|
3
|
+
const {transfer_local_directory_browser_version} = require('../lib/rr_utils')
|
|
4
|
+
const {port_modules} = require('../lib/mod_utils')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async function load_config(cf_name) {
|
|
9
|
+
let path = g_source_dir + '/' + cf_name
|
|
10
|
+
return await fos.load_json_data_at_path(path)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// //
|
|
14
|
+
function read_data(roll_conf) {
|
|
15
|
+
try {
|
|
16
|
+
console.dir(roll_conf)
|
|
17
|
+
for ( let ky in roll_conf ) {
|
|
18
|
+
let source_spec = roll_conf[ky]
|
|
19
|
+
let kys = Object.keys(source_spec)
|
|
20
|
+
if ( kys.length ) {
|
|
21
|
+
switch ( ky ) {
|
|
22
|
+
case "pnpm" : {
|
|
23
|
+
transfer_node_module_browser_version(source_spec)
|
|
24
|
+
break
|
|
25
|
+
}
|
|
26
|
+
case "github" : {
|
|
27
|
+
transfer_github_bro[skeletons]/wser_version(source_spec)
|
|
28
|
+
break
|
|
29
|
+
}
|
|
30
|
+
case "local" : {
|
|
31
|
+
transfer_local_directory_browser_version(source_spec)
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
default: {
|
|
35
|
+
// plugins
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.log(e)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
async function command_line_operations() {
|
|
49
|
+
console.log("command line operations")
|
|
50
|
+
|
|
51
|
+
g_config = await load_config("roll-right.json")
|
|
52
|
+
|
|
53
|
+
if ( g_argv.phase ) {
|
|
54
|
+
console.log(`starting phase ${g_argv.phase} instantiation`)
|
|
55
|
+
switch ( g_argv.phase ) {
|
|
56
|
+
case "template" :
|
|
57
|
+
case 1: { /// creates templates
|
|
58
|
+
if ( typeof g_config.alpha === "string" ) {
|
|
59
|
+
g_config.alpha = fos.load_json_data_at_path(g_config.alpha) // ALPHA
|
|
60
|
+
}
|
|
61
|
+
let ph1 = new Phase1(g_target,g_config.alpha) // g_target <- args[0] ... g_config <- read <- g_source_dir <- args[1]
|
|
62
|
+
ph1.run()
|
|
63
|
+
break
|
|
64
|
+
}
|
|
65
|
+
case "page":
|
|
66
|
+
case 2: {
|
|
67
|
+
if ( typeof g_config.beta === "string" ) {
|
|
68
|
+
g_config.beta = fos.load_json_data_at_path(g_config.beta) // BETA
|
|
69
|
+
}
|
|
70
|
+
let ph2 = new Phase2(g_target,g_config.beta) // g_target <- args[0] ... g_config <- read <- g_source_dir <- args[1]
|
|
71
|
+
ph2.run()
|
|
72
|
+
break
|
|
73
|
+
}
|
|
74
|
+
default : {
|
|
75
|
+
console.log("unnown phase")
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if ( g_argv.gather ) { // about moving files to directories for node module, browser modules, etc.
|
|
81
|
+
if ( typeof g_config.gather === "string" ) {
|
|
82
|
+
g_config.modules = fos.load_json_data_at_path(g_config.gather)
|
|
83
|
+
}
|
|
84
|
+
read_data(g_config.gather)
|
|
85
|
+
}
|
|
86
|
+
if ( g_argv.modules ) { // transforms and then copies base alpha code to final publication directores (npm is the only case yet)
|
|
87
|
+
if ( typeof g_config.modules === "string" ) {
|
|
88
|
+
g_config.modules = fos.load_json_data_at_path(g_config.modules)
|
|
89
|
+
}
|
|
90
|
+
port_modules(g_config.modules,g_argv)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
package/index.js
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const TemplatesToPreStaging = require('../lib/TemplateToPreStaging')
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
let SysUtils = require('../lib/sys_utils')
|
|
6
|
+
let sys_utils = new SysUtils({
|
|
7
|
+
"tools_directory" : "./tools"
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @class PreStagingSubsitutions
|
|
13
|
+
*
|
|
14
|
+
* This class extends SkelToTemplate with operations specific to phase 3.
|
|
15
|
+
*
|
|
16
|
+
* This is the page stage. All pages for all concerns are generated, using
|
|
17
|
+
* previously generated and edited substitutions and templates.
|
|
18
|
+
*
|
|
19
|
+
* The final results will be in the pre-staging directory for each concern.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
class PreStagingSubsitutions extends TemplatesToPreStaging {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {object} conf
|
|
27
|
+
*/
|
|
28
|
+
constructor(conf) {
|
|
29
|
+
super(conf)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* This method is phase 3 method
|
|
36
|
+
*
|
|
37
|
+
* @param {object} concerns
|
|
38
|
+
*/
|
|
39
|
+
async process_files(concerns) {
|
|
40
|
+
for ( let concern in concerns ) {
|
|
41
|
+
let concerns_dir = `[websites]/${concern}/`
|
|
42
|
+
concerns_dir = this.paths.compile_one_path(concerns_dir)
|
|
43
|
+
let targeted_files = Object.values(concerns[concern])
|
|
44
|
+
for ( let pair of targeted_files ) {
|
|
45
|
+
let keys = Object.keys(pair)
|
|
46
|
+
for ( let ky of keys ) {
|
|
47
|
+
//
|
|
48
|
+
let static_dir = `${concerns_dir}/static`
|
|
49
|
+
let afile = `${concerns_dir}/${this.created_dir}${ky}`
|
|
50
|
+
let subst_form = ky.replace(".tmplt","_html.subst")
|
|
51
|
+
let subst_file = `${concerns_dir}/pre-staging/${subst_form}`
|
|
52
|
+
let ofile = subst_file.replace("_html.subst",".html")
|
|
53
|
+
|
|
54
|
+
console.log(afile,"-\n",subst_file,"==>\n",ofile)
|
|
55
|
+
sys_utils.spawn_generator(subst_file,afile,ofile,static_dir)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
module.exports = PreStagingSubsitutions
|