roll-right 0.0.1 → 0.1.2
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 +55 -10
- package/bin/breakup.js +56 -0
- package/bin/index.js +107 -4
- package/index.js +1 -1
- package/lib/mod_utils.js +79 -0
- package/lib/phase1.js +445 -0
- package/lib/phase2.js +77 -0
- package/lib/rr_utils.js +128 -8
- package/lib/to_export.js +39 -0
- package/lib/utils.js +97 -0
- package/package.json +11 -2
- package/tools/affiliates.js +132 -0
- package/tools/allgen.sh +20 -0
- package/tools/charwindow.js +17 -0
- package/tools/filter_requires.js +60 -0
- package/tools/genpage.js +141 -0
- package/tools/npm_much.sh +57 -0
- package/tools/prep_body_insert_only.js +28 -0
- package/tools/releasepages.js +814 -0
- package/tools/rungen.sh +6 -0
- package/tools/rungen_dashboard.sh +5 -0
- package/tools/rungen_header_shell.sh +5 -0
- package/tools/rungen_paramed_shell.sh +12 -0
- package/tools/rungen_profile.sh +5 -0
- package/tools/web_files.js +149 -0
- package/transform.js +490 -0
- package/roll_right.js +0 -96
package/README.md
CHANGED
|
@@ -1,26 +1,71 @@
|
|
|
1
1
|
# roll-right
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A command line tool that gathers selected code components from curated bases of code and that, first, fans them into templates for site pages and that, second, populates templates with static site-specific code in order to generate static pages for sites.
|
|
4
|
+
|
|
5
|
+
***Here are steps of a generation process for site maintainers***:
|
|
6
|
+
|
|
7
|
+
1. store commonly used, well-tested code in files in selected directories
|
|
8
|
+
2. provide a file describing families of page skeletons
|
|
9
|
+
3. provide a JSON description that selects which skeleton parts are to be used along with source directories
|
|
10
|
+
4. run roll-right in phase 1 with the JSON to generate site templates
|
|
11
|
+
5. provide static components, pictures, etc. to populate templates
|
|
12
|
+
6. run roll-right in phase 2 with .subst files specifying the template population
|
|
13
|
+
7. use other tools to deploy files dropped into a staging directory
|
|
14
|
+
|
|
15
|
+
The generation process is not limited to coalescing code for pages. There is support for generating node.js modules, generating web page modules, etc. for npm publication.
|
|
16
|
+
|
|
17
|
+
## install it
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install -g roll-right
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## run it
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
roll-right --phase 1 <website-identifier> <directory including config>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
roll-right --phase 2 <website-identifier> <directory including config>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## reverse it
|
|
38
|
+
|
|
39
|
+
It can help, when developing, to split up a file that has been composed by **roll-right**. Later versions of **roll-right** will put in file separators when files are appended together to form a single file artifact for a web page or module. The command line tool, **roll-right-breakup**, will output a directory of all the files between the separators. There are times that it may be useful to use compare tools with the output of **roll-right-breakup** and the source files.
|
|
40
|
+
|
|
41
|
+
Here is how to call it:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
roll-right-breakup <path to file> <optional output directory>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
**roll-right-breakup** will create a directory in the calling directory named **rr-breakup** or within the optional directory if it is on the command line.
|
|
49
|
+
|
|
4
50
|
|
|
5
51
|
|
|
6
52
|
## How it Helps
|
|
7
53
|
|
|
8
|
-
This
|
|
54
|
+
This tool is not a replacement for final publication steps enabled by rollup, browserify, or others. Instead, this stool may generate code that will be sumbitted to those tools.
|
|
9
55
|
|
|
10
|
-
|
|
56
|
+
In fact, whole pages needing no further manipulation may be generated by this tool. So, in some cases this tool does the job that others do. However, some build systems use the other tools to generate their final runtime products. And, this tool may be upstream from those tools.
|
|
11
57
|
|
|
12
|
-
|
|
58
|
+
In particular, this tool addresses moving preexisting code into certain packaged contexts at the source level. Other packages rollup modules into single code sets or module collections into one file.
|
|
13
59
|
|
|
14
|
-
|
|
60
|
+
This tool can be used to replicate code into projects, allowing for function by function selection. The final output will be a combined source file with a chain of support for working code. That is, a developer may request that a whole module be copied into a combined source file for a project, or he may select some functions to be placed into the combined source file. But, he may expect that the functions included will have their supporting functions brought in as well.
|
|
15
61
|
|
|
16
|
-
|
|
17
|
-
* It provides tools to insert a snippet of code in the interface (entry point) level of the module.
|
|
62
|
+
More commonly, this tool is useful for creating web pages that host bundled operations and that provide basic common libraries that will not be accessed on the global (window) level. In the sense that a browser provides a common library accessible to all parts of a project, a window can offer an extension of that capability. The extension is mostly a packaging of that capability into simpler calls.
|
|
18
63
|
|
|
19
|
-
|
|
64
|
+
One may ask why one would allow code (fixed version) to be copied into a number of projects without creating a module publication. The answer has more to do with expediency of project creation with some time being taken to decide what is a maintable module. The tool will copy just one function from a group of functions into a project if that is specified. But, when the module is maintained, the tool may copy all the function of a group into the new module and ready the code for publication. Projects that use the module will import all the functions in some sense into their code. Certainly, down stream tree shaking may work to reduce the number of functions included. But, that may just move certain worries down stream.
|
|
20
65
|
|
|
21
|
-
|
|
66
|
+
So, there are options for deciding how alpha code will be included in projects. But, this tool also provides generation based on skeletons.
|
|
22
67
|
|
|
23
|
-
|
|
68
|
+
In order to create a template, this tool reads a skeleton file and a JSON configuration that describes how to select alpha code and use some or all of the skeleton to create an .html file that has code and variables, where the mark the place where final code will be placed.
|
|
24
69
|
|
|
25
70
|
|
|
26
71
|
## Setting up publisher calls in a node.js module
|
package/bin/breakup.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
const {FileOperations} = require('extra-file-class')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let fosc = new FileOperations(false)
|
|
8
|
+
|
|
9
|
+
async function process_file(file_name,deposit_dir) {
|
|
10
|
+
let is_file = await fosc.exists(file_name)
|
|
11
|
+
if ( is_file ) {
|
|
12
|
+
if ( await fosc.ensure_directories(deposit_dir) ) {
|
|
13
|
+
let file_txt = await fosc.load_data_at_path(file_name)
|
|
14
|
+
if ( file_txt ) {
|
|
15
|
+
let parts = file_txt.split('// ---->>>')
|
|
16
|
+
console.log(`# of parts: ${parts.length}`)
|
|
17
|
+
if ( parts.length > 0 ) {
|
|
18
|
+
parts.pop()
|
|
19
|
+
let count = 0
|
|
20
|
+
let ext = ".html"
|
|
21
|
+
for ( let part of parts ) {
|
|
22
|
+
count++
|
|
23
|
+
await fosc.output_string(`${deposit_dir}/part_${count}.${ext}`,parts[count-1])
|
|
24
|
+
ext = "js"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
console.log(`Could not read ${file_name}`)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
console.log(`can't find file ${file_name}`)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
let deposit_dir = "rr-breakup"
|
|
38
|
+
let holding_dir = process.argv[3]
|
|
39
|
+
if ( holding_dir !== undefined ) {
|
|
40
|
+
if ( holding_dir[holding_dir.length-1] !== '/' ) {
|
|
41
|
+
holding_dir += '/'
|
|
42
|
+
}
|
|
43
|
+
deposit_dir = holding_dir + deposit_dir
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
let file = process.argv[2]
|
|
48
|
+
//
|
|
49
|
+
if ( file === undefined ) {
|
|
50
|
+
console.log("roll-right-breakup is expecting at least one command line parameter: name of file to be processed")
|
|
51
|
+
} else {
|
|
52
|
+
console.log(file)
|
|
53
|
+
process_file(file,deposit_dir)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
package/bin/index.js
CHANGED
|
@@ -1,14 +1,117 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const papa = require('../index.js')
|
|
4
|
+
const {load_json_file} = require('../lib/utils')
|
|
3
5
|
|
|
6
|
+
const {transfer_node_module_browser_version} = require('../lib/rr_utils')
|
|
7
|
+
const {transfer_github_browser_version} = require('../lib/rr_utils')
|
|
8
|
+
const {transfer_local_directory_browser_version} = require('../lib/rr_utils')
|
|
9
|
+
const {port_modules} = require('../lib/mod_utils')
|
|
4
10
|
|
|
11
|
+
const Phase1 = require('../lib/phase1')
|
|
12
|
+
const Phase2 = require('../lib/phase2')
|
|
13
|
+
//
|
|
14
|
+
//
|
|
5
15
|
|
|
6
|
-
|
|
16
|
+
var g_argv = require('minimist')(process.argv.slice(2));
|
|
17
|
+
console.dir(g_argv);
|
|
18
|
+
|
|
19
|
+
let g_target = g_argv._[0]
|
|
20
|
+
let g_source_dir = g_argv._[1]
|
|
21
|
+
if ( g_source_dir === undefined ) {
|
|
22
|
+
g_source_dir = "."
|
|
23
|
+
}
|
|
7
24
|
|
|
8
|
-
console.log(__filename)
|
|
9
|
-
console.log(process.argv[0])
|
|
10
|
-
console.log(process.argv[1])
|
|
11
25
|
|
|
26
|
+
function load_config(cf_name) {
|
|
27
|
+
let path = g_source_dir + '/' + cf_name
|
|
28
|
+
return load_json_file(path)
|
|
29
|
+
}
|
|
12
30
|
|
|
31
|
+
|
|
32
|
+
const g_config = load_config("roll-right.json")
|
|
13
33
|
papa.identify_me()
|
|
14
34
|
|
|
35
|
+
// //
|
|
36
|
+
function read_data(roll_conf) {
|
|
37
|
+
try {
|
|
38
|
+
console.dir(roll_conf)
|
|
39
|
+
for ( let ky in roll_conf ) {
|
|
40
|
+
let source_spec = roll_conf[ky]
|
|
41
|
+
let kys = Object.keys(source_spec)
|
|
42
|
+
if ( kys.length ) {
|
|
43
|
+
switch ( ky ) {
|
|
44
|
+
case "pnpm" : {
|
|
45
|
+
transfer_node_module_browser_version(source_spec)
|
|
46
|
+
break
|
|
47
|
+
}
|
|
48
|
+
case "github" : {
|
|
49
|
+
transfer_github_browser_version(source_spec)
|
|
50
|
+
break
|
|
51
|
+
}
|
|
52
|
+
case "local" : {
|
|
53
|
+
transfer_local_directory_browser_version(source_spec)
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
default: {
|
|
57
|
+
// plugins
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
}
|
|
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
|
+
case "template" :
|
|
77
|
+
case 1: { /// creates templates
|
|
78
|
+
if ( typeof g_config.alpha === "string" ) {
|
|
79
|
+
g_config.alpha = load_json_file(g_config.alpha) // ALPHA
|
|
80
|
+
}
|
|
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
|
+
break
|
|
84
|
+
}
|
|
85
|
+
case "page":
|
|
86
|
+
case 2: {
|
|
87
|
+
if ( typeof g_config.beta === "string" ) {
|
|
88
|
+
g_config.beta = load_json_file(g_config.beta) // BETA
|
|
89
|
+
}
|
|
90
|
+
let ph2 = new Phase2(g_target,g_config.beta) // g_target <- args[0] ... g_config <- read <- g_source_dir <- args[1]
|
|
91
|
+
ph2.run()
|
|
92
|
+
break
|
|
93
|
+
}
|
|
94
|
+
default : {
|
|
95
|
+
console.log("unnown phase")
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if ( g_argv.gather ) { // about moving files to directories for node module, browser modules, etc.
|
|
101
|
+
if ( typeof g_config.gather === "string" ) {
|
|
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
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
command_line_operations()
|
package/index.js
CHANGED
package/lib/mod_utils.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const {load_json_file,array_flatten} = require('../lib/utils')
|
|
5
|
+
const {execSync} = require('child_process')
|
|
6
|
+
const {translate_marker} = require('../lib/utils')
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async function cp_module_to(dest,src,config) {
|
|
11
|
+
let src_dr = translate_marker(src,config)
|
|
12
|
+
let dest_file = translate_marker(dest,config)
|
|
13
|
+
//
|
|
14
|
+
let path_parts = dest_file.split('/')
|
|
15
|
+
try {
|
|
16
|
+
let src_file = `${src_dr}/${path_parts[path_parts.length-1]}`
|
|
17
|
+
fs.copyFileSync(src_file,dest_file)
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.log(e)
|
|
20
|
+
}
|
|
21
|
+
//
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function check_tests(src,dest,config) {
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function shell_command(cmd) {
|
|
29
|
+
try {
|
|
30
|
+
execSync(cmd,{
|
|
31
|
+
stdio: [0, 1, 2]
|
|
32
|
+
})
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.log(e)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function bump_npm_version() {
|
|
40
|
+
let npm = load_json_file("package.json")
|
|
41
|
+
let v = npm.version
|
|
42
|
+
let semv = v.split('.')
|
|
43
|
+
let minv = parseInt(semv[semv.length - 1])
|
|
44
|
+
minv++
|
|
45
|
+
semv[semv.length - 1] = "" + minv
|
|
46
|
+
npm.version = semv.join('.')
|
|
47
|
+
fs.writeFileSync("package.json",JSON.stringify(npm,null,2))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async function npm_publish() {
|
|
52
|
+
await shell_command("npm publish .")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function port_modules(config,flags) {
|
|
56
|
+
//
|
|
57
|
+
let all_tests = true
|
|
58
|
+
for ( let mod in config.sources ) {
|
|
59
|
+
let tests_ok = await check_tests(mod,config.sources[mod],config)
|
|
60
|
+
if ( tests_ok ) {
|
|
61
|
+
await cp_module_to(mod,config.sources[mod],config)
|
|
62
|
+
}
|
|
63
|
+
all_tests = all_tests && tests_ok
|
|
64
|
+
}
|
|
65
|
+
//
|
|
66
|
+
if ( all_tests ) {
|
|
67
|
+
switch ( config.mod_type ) {
|
|
68
|
+
case "npm" :
|
|
69
|
+
default: {
|
|
70
|
+
if ( flags.publish ) {
|
|
71
|
+
bump_npm_version()
|
|
72
|
+
await npm_publish()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports.port_modules = port_modules
|