xertz 0.51.0 → 0.54.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Brady Holt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -38,9 +38,9 @@ When you initialize a xertz site, a directory will created that looks like this:
38
38
  |-- index.html.hbs
39
39
  ```
40
40
 
41
- - *_layouts* - This folder contains Handlebars layouts which will be used to contruct rendered pages.
42
- - *media* - This is folder that is indented to hold images and other assets. The folder will be emitted as is.
43
- - *posts* - This is folder that is indented to blog posts.
41
+ - *_layouts* - This folder contains Handlebars layouts which will be used to contsruct rendered pages.
42
+ - *media* - This folder contains images and other assets and will be copied as is.
43
+ - *posts* - This folder contains the posts.
44
44
  - *styles* - CSS files can be placed here and will be be made available in the template data.
45
45
  - *_config.yml* - This is the base config file.
46
46
  - *index.html.hbs* - This is the main index page for the site.
@@ -64,7 +64,7 @@ A file with the `html.hbs` extension will be processed as a Handlebars template
64
64
 
65
65
  #### Content Package Directory
66
66
 
67
- If subdirectory of `content/` contans contains a file called `index.md`, it will be deemed a Content Package Directory. This means all files within the directory will be
67
+ If subdirectory of `posts/` contains contains a file called `index.md`, it will be deemed a Content Package Directory. This means all files within the directory will be processed as a unit and copied to a corresponding output directory.
68
68
 
69
69
  For example, if you had a directory structure defined as:
70
70
 
package/dist/builder.js CHANGED
@@ -1,18 +1,43 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Builder = void 0;
10
27
  const fse = __importStar(require("fs-extra"));
11
28
  const path = __importStar(require("path"));
12
29
  const configHelper_1 = require("./configHelper");
13
30
  const stylesGenerator_1 = require("./generators/stylesGenerator");
14
31
  const contentGenerator_1 = require("./generators/contentGenerator");
15
32
  class Builder {
33
+ static distDirectoryName = "_dist";
34
+ static layoutsDirectoryName = "_layouts";
35
+ static stylesDirectoryName = "styles";
36
+ baseDirectory;
37
+ contentDirectory;
38
+ layoutsDirectory;
39
+ stylesDirectory;
40
+ distDirectory;
16
41
  constructor(baseDirectory) {
17
42
  this.baseDirectory = baseDirectory;
18
43
  this.contentDirectory = this.baseDirectory;
@@ -21,7 +46,7 @@ class Builder {
21
46
  this.distDirectory = path.join(this.baseDirectory, Builder.distDirectoryName);
22
47
  }
23
48
  async start() {
24
- let baseConfig = configHelper_1.loadConfigFile(this.baseDirectory);
49
+ let baseConfig = (0, configHelper_1.loadConfigFile)(this.baseDirectory);
25
50
  if (!baseConfig) {
26
51
  throw Error(`Config file not found in ${this.baseDirectory}.`);
27
52
  }
@@ -34,6 +59,3 @@ class Builder {
34
59
  }
35
60
  }
36
61
  exports.Builder = Builder;
37
- Builder.distDirectoryName = "_dist";
38
- Builder.layoutsDirectoryName = "_layouts";
39
- Builder.stylesDirectoryName = "styles";
package/dist/cli.js CHANGED
@@ -1,9 +1,25 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -20,17 +36,16 @@ const express = require("express");
20
36
  const package_json_2 = __importDefault(require("../package.json"));
21
37
  const dateHelper_1 = require("./dateHelper");
22
38
  class cli {
39
+ scaffoldDirectoryName = "scaffold";
40
+ scaffoldContentExampleFileName = "YYYY-MM-DD-my-first-post.md";
41
+ cwd;
42
+ args;
23
43
  constructor(cwd, args) {
24
- this.scaffoldDirectoryName = "scaffold";
25
- this.scaffoldContentExampleFileName = "YYYY-MM-DD-my-first-post.md";
26
44
  this.cwd = cwd;
27
45
  this.args = args;
28
46
  }
29
47
  printHelp() {
30
48
  console.log(`\
31
- ${package_json_2.default.name} - version ${package_json_2.default.version}
32
- ${package_json_2.default.description}
33
-
34
49
  Usage:
35
50
  xertz COMMAND
36
51
 
@@ -49,47 +64,35 @@ Commands:
49
64
  const command = this.args[0] || "build";
50
65
  switch (command) {
51
66
  case "init":
52
- this.init(this.args[1]);
67
+ this.initCommand(this.args[1]);
53
68
  break;
54
69
  case "new":
55
70
  await this.checkForUpdates();
56
- this.newPost(this.args[1]);
71
+ this.newCommand(this.args[1]);
57
72
  break;
58
73
  case "build":
59
74
  await this.checkForUpdates();
60
- await this.build(this.args[1] || ".");
75
+ await this.build();
61
76
  break;
62
77
  case "serve":
63
78
  await this.checkForUpdates();
64
- this.serve(this.args[1]);
79
+ this.serveCommand(this.args[1]);
65
80
  break;
66
81
  case "update":
67
- await this.update();
82
+ await this.updateCommand();
68
83
  break;
69
84
  default:
70
85
  await this.checkForUpdates();
71
86
  this.printHelp();
72
87
  }
73
88
  }
74
- watchSignal() {
75
- process.on("SIGINT", function () {
76
- process.exit();
77
- });
78
- }
79
- async checkForUpdates() {
80
- const latestNpmPackageInfo = await package_json_1.default(package_json_2.default.name);
81
- const sitePackageInfo = JSON.parse(fse.readFileSync(path.join(this.cwd, "package.json"), "utf8"));
82
- if (latestNpmPackageInfo.version !=
83
- sitePackageInfo.dependencies[package_json_2.default.name]) {
84
- console.log("\x1b[33m%s", `New version is available (${latestNpmPackageInfo.version}). Run \`${package_json_2.default.name} update\` to update.`, "\x1b[0m");
85
- }
86
- }
87
- async init(targetDirectoryName) {
89
+ /* Commands */
90
+ async initCommand(targetDirectoryName) {
88
91
  if (!targetDirectoryName) {
89
92
  this.exitWithError("ERROR: target directory is required!");
90
93
  return;
91
94
  }
92
- console.log(`INIT: Start`);
95
+ console.log(`[init] Start`);
93
96
  const targetDirectoryPath = path.resolve(this.cwd, targetDirectoryName);
94
97
  if (fse.pathExistsSync(targetDirectoryPath)) {
95
98
  this.exitWithError(`ERROR: ${targetDirectoryPath} already exists.`);
@@ -102,27 +105,28 @@ Commands:
102
105
  }
103
106
  });
104
107
  // Add today's date in the example content file
105
- fse.renameSync(path.join(targetDirectoryPath, "posts", this.scaffoldContentExampleFileName), path.join(targetDirectoryPath, "posts", this.scaffoldContentExampleFileName.replace("YYYY-MM-DD", dateHelper_1.getCurrentDateInISOFormat())));
106
- // Configure package.json file
108
+ fse.renameSync(path.join(targetDirectoryPath, "posts", this.scaffoldContentExampleFileName), path.join(targetDirectoryPath, "posts", this.scaffoldContentExampleFileName.replace("YYYY-MM-DD", (0, dateHelper_1.getCurrentDateInISOFormat)())));
109
+ // Configure package.json file with name of latest version of xertz specified
107
110
  const scaffoldFile = path.join(scaffoldDirectory, "package.json");
108
111
  const scaffoldPackageContent = JSON.parse(fse.readFileSync(scaffoldFile, "utf8"));
109
112
  scaffoldPackageContent.name = targetDirectoryName;
110
- const latestPackageInfo = await package_json_1.default(package_json_2.default.name);
113
+ const latestPackageInfo = await (0, package_json_1.default)(package_json_2.default.name);
111
114
  scaffoldPackageContent.dependencies.xertz = latestPackageInfo.version;
112
115
  fse.writeFileSync(scaffoldFile, JSON.stringify(scaffoldPackageContent));
113
116
  // Run npm install
114
- console.log(`INIT: Installing packages...`);
115
- child_process_1.execSync(`npm install --silent`, { cwd: targetDirectoryPath, env: {} });
116
- console.log(`INIT: Done! Run \`cd ${targetDirectoryName} && npx xertz serve\` and start blogging.`);
117
+ console.log(`[init]: Installing packages...`);
118
+ (0, child_process_1.execSync)(`npm install --silent`, { cwd: targetDirectoryPath, env: {} });
119
+ console.log(`[init]: Done! Run \`cd ${targetDirectoryName} && npx xertz serve\` and start blogging.`);
117
120
  process.exit();
118
121
  }
119
- newPost(title) {
122
+ newCommand(title) {
123
+ console.log(`[new]: Start`);
120
124
  const postsPath = path.join(this.cwd, "posts");
121
125
  if (!title) {
122
126
  title = "My New Post";
123
127
  }
124
128
  const postSlug = title.toLocaleLowerCase().replace(/\s/g, "-");
125
- const postPath = path.join(postsPath, `${dateHelper_1.getCurrentDateInISOFormat()}-${postSlug}`);
129
+ const postPath = path.join(postsPath, `${(0, dateHelper_1.getCurrentDateInISOFormat)()}-${postSlug}`);
126
130
  fse.ensureDirSync(postPath);
127
131
  fse.writeFileSync(path.join(postPath, "index.md"), `\
128
132
  ---
@@ -133,19 +137,20 @@ This is a new post.
133
137
  `, {
134
138
  encoding: "utf-8"
135
139
  });
136
- console.log(`NEW: Done! Created ${postPath}`);
140
+ console.log(`[new]: Done! Created ${postPath}`);
137
141
  }
138
- async build(sourceDirectory, exit = true) {
139
- const builder = new builder_1.Builder(path.join(this.cwd, sourceDirectory));
140
- console.log(`BUILD: Start`);
142
+ async build(exit = true) {
143
+ console.log(`[build]: Start`);
144
+ const builder = new builder_1.Builder(this.cwd);
141
145
  await builder.start();
142
- console.log(`BUILD: Success!`);
146
+ console.log(`[build]: Success!`);
143
147
  if (exit) {
144
148
  process.exit();
145
149
  }
146
150
  }
147
- async serve(preferredPortNumber) {
148
- await this.build(".", false);
151
+ async serveCommand(preferredPortNumber) {
152
+ console.log(`[serve]: Start`);
153
+ await this.build(false);
149
154
  const distFolder = path.join(this.cwd, builder_1.Builder.distDirectoryName);
150
155
  chokidar
151
156
  .watch([path.join(this.cwd)], {
@@ -153,24 +158,40 @@ This is a new post.
153
158
  ignored: distFolder
154
159
  })
155
160
  .on("all", (event, path) => {
156
- console.log(`SERVE: Changed Detected`);
157
- this.build(".", false);
161
+ console.log(`[serve]: Changed Detected`);
162
+ this.build(false);
158
163
  });
159
164
  const expressApp = express();
160
165
  expressApp.use(express.static(distFolder));
161
166
  const portNumber = Number(preferredPortNumber) || 8080;
162
167
  expressApp.listen(portNumber);
163
- console.log(`SERVE: Listening on http://localhost:${portNumber}`);
168
+ console.log(`[serve]: Listening on http://localhost:${portNumber}`);
164
169
  }
165
- async update() {
166
- const latestNpmPackageInfo = await package_json_1.default(package_json_2.default.name);
170
+ async updateCommand() {
171
+ console.log(`[update]: Start`);
172
+ // Update xertz depedency to latest version in package.json
173
+ const latestNpmPackageInfo = await (0, package_json_1.default)(package_json_2.default.name);
167
174
  const packageFile = path.join(this.cwd, "package.json");
168
175
  const sitePackageInfo = JSON.parse(fse.readFileSync(packageFile, "utf8"));
169
176
  sitePackageInfo.dependencies[package_json_2.default.name] =
170
177
  latestNpmPackageInfo.version;
171
178
  fse.writeFileSync(packageFile, JSON.stringify(sitePackageInfo, null, 2));
172
- child_process_1.execSync(`npm install --silent`, { cwd: this.cwd });
173
- console.log(`Updated to ${latestNpmPackageInfo.version}!`);
179
+ (0, child_process_1.execSync)(`npm install --silent`, { cwd: this.cwd });
180
+ console.log(`[update]: Successfully updated ${package_json_2.default.name} to version ${latestNpmPackageInfo.version}.`);
181
+ }
182
+ /* Misc */
183
+ watchSignal() {
184
+ process.on("SIGINT", function () {
185
+ process.exit();
186
+ });
187
+ }
188
+ async checkForUpdates() {
189
+ const latestNpmPackageInfo = await (0, package_json_1.default)(package_json_2.default.name);
190
+ const sitePackageInfo = JSON.parse(fse.readFileSync(path.join(this.cwd, "package.json"), "utf8"));
191
+ if (latestNpmPackageInfo.version !=
192
+ sitePackageInfo.dependencies[package_json_2.default.name]) {
193
+ console.log("\x1b[33m%s", `New version is available (${latestNpmPackageInfo.version}). Run \`npx ${package_json_2.default.name} update\` to update.`, "\x1b[0m");
194
+ }
174
195
  }
175
196
  exitWithError(errorMessage) {
176
197
  console.error(errorMessage);
@@ -1,12 +1,29 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.loadConfigFile = void 0;
10
27
  const path = __importStar(require("path"));
11
28
  const fs = __importStar(require("fs"));
12
29
  const fse = __importStar(require("fs-extra"));
@@ -17,7 +34,7 @@ function loadConfigFile(sourceDirectory) {
17
34
  const configFilePath = path.join(sourceDirectory, "_config.yml");
18
35
  if (fse.existsSync(configFilePath)) {
19
36
  const configFileContent = fs.readFileSync(path.join(sourceDirectory, "_config.yml"), "utf-8");
20
- const config = yaml.safeLoad(configFileContent);
37
+ const config = yaml.load(configFileContent);
21
38
  cachedConfigFiles[sourceDirectory] = config;
22
39
  }
23
40
  else {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentDateInLocalTimezone = exports.getCurrentDateInISOFormat = void 0;
3
4
  function getCurrentDateInISOFormat(currentDate = new Date()) {
4
5
  let isoLocalDateString = getCurrentDateInLocalTimezone(currentDate).toISOString();
5
6
  return isoLocalDateString.substring(0, 10);
@@ -1,15 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
10
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
27
  };
12
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.AmpGenerator = void 0;
13
30
  const fs = __importStar(require("fs"));
14
31
  const path = __importStar(require("path"));
15
32
  const ampify_1 = __importDefault(require("@bradymholt/ampify"));
@@ -17,8 +34,12 @@ const ampify_1 = __importDefault(require("@bradymholt/ampify"));
17
34
  * Generates an AMP page given ITemplateData
18
35
  */
19
36
  class AmpGenerator {
37
+ static ampPageName = "amp.html";
38
+ ampLayout = "amp";
39
+ baseSourceDirectory;
40
+ baseDestDirectory;
41
+ templateManager;
20
42
  constructor(baseSourceDirectory, baseDestDirectory, templateManager) {
21
- this.ampLayout = "amp";
22
43
  this.baseSourceDirectory = baseSourceDirectory;
23
44
  this.baseDestDirectory = baseDestDirectory;
24
45
  this.templateManager = templateManager;
@@ -26,7 +47,7 @@ class AmpGenerator {
26
47
  async generate(pageConfig, templateData) {
27
48
  const applyTemplate = this.templateManager.getTemplate(this.ampLayout);
28
49
  const html = applyTemplate(Object.assign({}, pageConfig, templateData));
29
- let ampOutput = await ampify_1.default(html, {
50
+ let ampOutput = await (0, ampify_1.default)(html, {
30
51
  // TODO: We're passing the destination directory to ampify which it will read from. I'd
31
52
  // prefer to feed only source directory files in to any build time processing but this is easier. Circle back and re-evalulate this.
32
53
  cwd: this.baseDestDirectory
@@ -35,4 +56,3 @@ class AmpGenerator {
35
56
  }
36
57
  }
37
58
  exports.AmpGenerator = AmpGenerator;
38
- AmpGenerator.ampPageName = "amp.html";
@@ -1,19 +1,36 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
10
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
27
  };
12
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ContentGenerator = void 0;
13
30
  const fs = __importStar(require("fs"));
14
31
  const fse = __importStar(require("fs-extra"));
15
32
  const path = __importStar(require("path"));
16
- const marked_1 = __importDefault(require("marked"));
33
+ const marked_1 = require("marked");
17
34
  const gray_matter_1 = __importDefault(require("gray-matter"));
18
35
  const prismjs_1 = __importDefault(require("prismjs"));
19
36
  const configHelper_1 = require("../configHelper");
@@ -21,14 +38,25 @@ const templateGenerator_1 = require("./templateGenerator");
21
38
  const ampGenerator_1 = require("./ampGenerator");
22
39
  const templateManager_1 = require("../templateManager");
23
40
  class ContentGenerator {
41
+ // Options
42
+ renderAmpPages = true;
43
+ codeHighlight = true;
44
+ styles;
45
+ contentPageName = "index.html";
46
+ ignorePrefixes = [".", "_", "node_modules"];
47
+ contentExtensionsToInclude = ["md"];
48
+ assetIgnoreExtensions = ["md", "hbs"];
49
+ templateManager;
50
+ markedRender;
51
+ markedHighlighter;
52
+ baseConfig;
53
+ stylesDirectory;
54
+ baseSourceDirectory;
55
+ baseDestDirectory;
56
+ baseTemplateData;
57
+ templateGenerator;
58
+ ampGenerator;
24
59
  constructor(baseConfig, styles, stylesDirectory, layoutsDirectory, sourceDirectory, destDirectory) {
25
- // Options
26
- this.renderAmpPages = true;
27
- this.codeHighlight = true;
28
- this.contentPageName = "index.html";
29
- this.ignorePrefixes = [".", "_", "node_modules"];
30
- this.contentExtensionsToInclude = ["md"];
31
- this.assetIgnoreExtensions = ["md", "hbs"];
32
60
  this.styles = styles;
33
61
  this.stylesDirectory = stylesDirectory;
34
62
  this.templateManager = new templateManager_1.TemplateManager(layoutsDirectory);
@@ -46,7 +74,7 @@ class ContentGenerator {
46
74
  }
47
75
  async generate(config, sourceDirectory, destDirectory) {
48
76
  const originalDestDirectory = destDirectory;
49
- let sourceDirectoryConfig = configHelper_1.loadConfigFile(sourceDirectory);
77
+ let sourceDirectoryConfig = (0, configHelper_1.loadConfigFile)(sourceDirectory);
50
78
  // Merge any _config.yml file in current directory with baseConfig to gather config for current directory
51
79
  let currentDirectoryPageConfig = Object.assign({}, config, sourceDirectoryConfig);
52
80
  // If this directory contains an index.md file, it is designated as a content package directory.
@@ -183,7 +211,7 @@ class ContentGenerator {
183
211
  }
184
212
  parseContentFile(pageConfig) {
185
213
  const source = fs.readFileSync(pageConfig.source, { encoding: "utf-8" });
186
- const parsedMatter = gray_matter_1.default(source);
214
+ const parsedMatter = (0, gray_matter_1.default)(source);
187
215
  let markdownContent = parsedMatter.content;
188
216
  // Prepend relative image references with path
189
217
  markdownContent = markdownContent
@@ -213,7 +241,7 @@ class ContentGenerator {
213
241
  switch (fileExtension) {
214
242
  case "md":
215
243
  // Parse markdown
216
- html = marked_1.default(markdownContent, {
244
+ html = (0, marked_1.marked)(markdownContent, {
217
245
  smartypants: true,
218
246
  highlight: this.codeHighlight ? this.prismHighlighter : undefined,
219
247
  renderer: this.markedRender
@@ -263,7 +291,7 @@ class ContentGenerator {
263
291
  return prismjs_1.default.highlight(code, prismjs_1.default.languages[lang] || prismjs_1.default.languages.markup, "");
264
292
  }
265
293
  getMarkedRender() {
266
- const renderer = new marked_1.default.Renderer();
294
+ const renderer = new marked_1.marked.Renderer();
267
295
  renderer.code = function (code, language) {
268
296
  const options = this.options;
269
297
  var lang = (language || "markup").match(/\S*/)[0];
@@ -1,12 +1,29 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.StylesGenerator = void 0;
10
27
  const fs = __importStar(require("fs"));
11
28
  const fse = __importStar(require("fs-extra"));
12
29
  const path = __importStar(require("path"));
@@ -15,11 +32,9 @@ const sass = __importStar(require("node-sass"));
15
32
  * Generates CSS and compiles Sass
16
33
  */
17
34
  class StylesGenerator {
18
- constructor() {
19
- this.extensionsToInclude = ["scss", "sass", "css"];
20
- this.outFileExtension = "css";
21
- this.outputStyle = "compressed";
22
- }
35
+ extensionsToInclude = ["scss", "sass", "css"];
36
+ outFileExtension = "css";
37
+ outputStyle = "compressed";
23
38
  generate(sourceDirectory, destDirectory) {
24
39
  const styles = [];
25
40
  const baseDirFileNames = fs.readdirSync(sourceDirectory);
@@ -1,18 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.TemplateGenerator = void 0;
10
27
  const fs = __importStar(require("fs"));
11
28
  const fse = __importStar(require("fs-extra"));
12
29
  const path = __importStar(require("path"));
13
30
  class TemplateGenerator {
31
+ extensionsToInclude = ["hbs"];
32
+ baseTemplateData;
33
+ templateManager;
14
34
  constructor(baseTemplateData, templateManager) {
15
- this.extensionsToInclude = ["hbs"];
16
35
  this.baseTemplateData = baseTemplateData;
17
36
  this.templateManager = templateManager;
18
37
  }
@@ -1,15 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
10
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
27
  };
12
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.encodeURI = exports.group = exports.indent = exports.dateFormat = exports.iif = exports.filter = exports.limit = void 0;
13
30
  const handlebars = __importStar(require("handlebars"));
14
31
  const dateformat_1 = __importDefault(require("dateformat"));
15
32
  function register() {
@@ -51,7 +68,7 @@ function dateFormat(dateString, format = "mm/dd/yyyy") {
51
68
  // dateString had no time component (e.g. 2019-01-01) so we'll convert to UTC to make the date stable.
52
69
  format = "UTC:" + format;
53
70
  }
54
- return dateformat_1.default(date, format);
71
+ return (0, dateformat_1.default)(date, format);
55
72
  }
56
73
  exports.dateFormat = dateFormat;
57
74
  /**
@@ -68,7 +85,10 @@ function indent(input, width, indeentationChar) {
68
85
  ? " "
69
86
  : indeentationChar);
70
87
  // If newline is not preceeded by a zero width character (\u200b) then add indention
71
- const indented = input.replace(/[^\u200b]\n/g, match => match.replace(/\n/, `\n${intendation}`));
88
+ let indented = input.replace(/[^\u200b]\n/g, match => match.replace(/\n/, `\n${intendation}`));
89
+ // Remove zero width characters
90
+ indented = indented.replace(/\u200b\n/g, "\n");
91
+ //return indented;
72
92
  return indented;
73
93
  }
74
94
  exports.indent = indent;
@@ -1,22 +1,41 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __importStar = (this && this.__importStar) || function (mod) {
3
19
  if (mod && mod.__esModule) return mod;
4
20
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
7
23
  return result;
8
24
  };
9
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
10
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
27
  };
12
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.TemplateManager = void 0;
13
30
  const fs = __importStar(require("fs"));
14
31
  const path = __importStar(require("path"));
15
32
  const handlebars = __importStar(require("handlebars"));
16
33
  const hbs_helpers_1 = __importDefault(require("./hbs-helpers"));
17
34
  class TemplateManager {
35
+ layoutsDirectory;
36
+ layouts;
37
+ initialized = false;
18
38
  constructor(layoutDirectory) {
19
- this.initialized = false;
20
39
  this.layoutsDirectory = layoutDirectory;
21
40
  this.layouts = {};
22
41
  }
@@ -49,7 +68,7 @@ class TemplateManager {
49
68
  initialize() {
50
69
  if (!this.initialized) {
51
70
  this.registerTemplatePartials();
52
- hbs_helpers_1.default();
71
+ (0, hbs_helpers_1.default)();
53
72
  this.initialized = true;
54
73
  }
55
74
  }
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "xertz",
3
- "version": "0.51.0",
3
+ "version": "0.54.0",
4
4
  "description": "A static site generator written in TypeScript",
5
5
  "author": "Brady Holt",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
+ "engines": {
11
+ "node": ">=8.0.0 <=v12.22.1"
12
+ },
10
13
  "main": "index.js",
11
14
  "bin": "bin/start.js",
12
15
  "files": [
@@ -16,38 +19,38 @@
16
19
  ],
17
20
  "scripts": {
18
21
  "build_scaffold": "cd scaffold/ && npx ts-node --files ../bin/start.ts build",
19
- "test": "npx jest",
22
+ "test": "jest",
20
23
  "prepublishOnly": "tsc"
21
24
  },
22
25
  "dependencies": {
23
26
  "@bradymholt/ampify": "^1.2.0",
24
- "@types/package-json": "^5.0.1",
25
- "chokidar": "^3.1.1",
26
- "dateformat": "^3.0.3",
27
- "express": "^4.17.1",
28
- "fs-extra": "^8.1.0",
29
- "gray-matter": "^4.0.2",
30
- "handlebars": "^4.3.1",
31
- "js-yaml": "^3.13.1",
32
- "marked": "^0.7.0",
33
- "node-sass": "^4.12.0",
34
- "npm-check-updates": "^3.1.23",
27
+ "chokidar": "^3.5.3",
28
+ "dateformat": "^4.5.1",
29
+ "express": "^4.18.1",
30
+ "fs-extra": "^10.1.0",
31
+ "gray-matter": "^4.0.3",
32
+ "handlebars": "^4.7.7",
33
+ "js-yaml": "^4.1.0",
34
+ "marked": "^4.0.17",
35
35
  "package-json": "^6.5.0",
36
- "prismjs": "^1.17.1"
36
+ "node-sass": "^7.0.1",
37
+ "prismjs": "^1.28.0"
37
38
  },
38
39
  "devDependencies": {
39
- "@types/dateformat": "^3.0.1",
40
- "@types/express": "^4.17.1",
41
- "@types/fs-extra": "^8.0.0",
42
- "@types/jest": "^24.0.18",
43
- "@types/js-yaml": "^3.12.1",
44
- "@types/marked": "^0.6.5",
45
- "@types/node": "^12.7.8",
46
- "@types/node-sass": "^4.11.0",
47
- "@types/prismjs": "^1.16.0",
48
- "jest": "^24.9.0",
49
- "ts-jest": "^24.1.0",
50
- "ts-node": "^8.4.1",
51
- "typescript": "^3.6.3"
40
+ "@types/dateformat": "^5.0.0",
41
+ "@types/express": "^4.17.13",
42
+ "@types/fs-extra": "^9.0.13",
43
+ "@types/jest": "^28.1.2",
44
+ "@types/js-yaml": "^4.0.5",
45
+ "@types/marked": "^4.0.3",
46
+ "@types/node": "^18.0.0",
47
+ "@types/node-sass": "^4.11.2",
48
+ "@types/prismjs": "^1.26.0",
49
+ "@types/package-json": "^5.0.1",
50
+ "jest": "^28.1.1",
51
+ "npm-check-updates": "^14.0.1",
52
+ "ts-jest": "^28.0.5",
53
+ "ts-node": "^10.8.1",
54
+ "typescript": "^4.7.4"
52
55
  }
53
56
  }
@@ -1 +1 @@
1
- {"name":"tmp_init","version":"1.0.0","description":"A site built with xertz.","dependencies":{"xertz":"0.49.0"}}
1
+ {"name":"tmp_init","version":"1.0.0","description":"A site built with xertz.","dependencies":{"xertz":"0.53.0"}}