node-riner 1.1.3 → 1.1.5

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.
Files changed (3) hide show
  1. package/index.ts +17 -13
  2. package/package.json +1 -1
  3. package/runs.js +1 -1
package/index.ts CHANGED
@@ -1,18 +1,20 @@
1
1
  import fs, { readFileSync, writeFileSync } from 'fs'
2
2
  import { XMLParser } from 'fast-xml-parser'
3
- import exp, { application } from 'express'
3
+ import exp from 'express'
4
4
  import path from 'path'
5
- import child_process, { execSync } from 'node:child_process'
5
+ import { execSync } from 'node:child_process'
6
6
  export default class Ride {
7
7
  F: string
8
8
  parsedJson: object
9
9
  pages: object
10
10
  name: string
11
+ defaultinfo: string
11
12
  constructor(name: string) {
12
13
  this.F = ""
13
14
  this.parsedJson = {}
14
15
  this.pages = {}
15
16
  this.name = name
17
+ this.defaultinfo = ""
16
18
  }
17
19
 
18
20
  Ride(name: string) {
@@ -24,25 +26,27 @@ export default class Ride {
24
26
  const parser = new XMLParser(options);
25
27
  try {
26
28
  this.parsedJson = parser.parse(this.F)
27
- console.log(this.parsedJson["Root"]["Page"]);
29
+ // debug
28
30
  if (Array.isArray(this.parsedJson["Root"]["Page"])) {
29
31
  this.parsedJson["Root"]["Page"].forEach((page: { [x: string]: { [x: string]: any } }) => {
30
32
  let route = page['@_route']
31
33
  let generatedhtml = Object.keys(page['Content']).map(tags => {
34
+ if (typeof page['Content'][tags] === "string") {
32
35
  let match = page['Content'][tags].match(/{.*}/g)
33
- console.log(match)
36
+ // debug
34
37
 
35
38
  if(match) {
36
- console.log("matched")
39
+ // debug
37
40
  let matched : string = match[0]
38
41
  matched = matched.replace("{", "")
39
42
  matched = matched.replace("}", "")
40
43
  writeFileSync("./runs.js", matched)
41
44
  let out = execSync("node runs.js").toString()
42
- console.log(matched)
45
+ // debug
43
46
  page['Content'][tags] = page['Content'][tags].replace(/{.*}/, out)
44
47
  }
45
- console.log("e:" + page['Content'][tags])
48
+ }
49
+ // debug
46
50
  return `<${tags}>${page['Content'][tags]}</${tags}>`
47
51
  }).join('')
48
52
  this.pages[route] = `<title>${this.name}</title>` + generatedhtml
@@ -52,19 +56,19 @@ export default class Ride {
52
56
  let route = this.parsedJson["Root"]["Page"]['@_route']
53
57
  let generatedhtml = Object.keys(page['Content']).map(tags => {
54
58
  let match = page['Content'][tags].match(/{.*}/g)
55
- console.log(match)
59
+ // debug
56
60
 
57
61
  if(match) {
58
- console.log("matched")
62
+ // debug
59
63
  let matched : string = match[0]
60
64
  matched = matched.replace("{", "")
61
65
  matched = matched.replace("}", "")
62
66
  writeFileSync("./runs.js", matched)
63
67
  let out = execSync("node runs.js").toString()
64
- console.log(matched)
68
+ // debug
65
69
  page['Content'][tags] = page['Content'][tags].replace(/{.*}/, out)
66
70
  }
67
- console.log("e:" + page['Content'][tags])
71
+ // debug
68
72
  return `<${tags}>${page['Content'][tags]}</${tags}>`
69
73
  }).join('')
70
74
  this.pages[route] = generatedhtml
@@ -74,11 +78,11 @@ export default class Ride {
74
78
  }
75
79
  }
76
80
  serve(port: number) {
77
- console.log(this.pages)
81
+ // debug
78
82
  let app = exp();
79
83
  (Object.keys(this.pages)).forEach(route => {
80
84
  app.get(route, (req, res) => {
81
- console.log("get-" + route)
85
+ // debug
82
86
  res.send(this.pages[route])
83
87
  })
84
88
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-riner",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/runs.js CHANGED
@@ -1 +1 @@
1
- console.log("world")
1
+ // debug