@haxtheweb/create 9.0.14 → 9.0.16

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/dist/create.js CHANGED
@@ -28,13 +28,13 @@ exec('git --version', error => {
28
28
  });
29
29
  async function main() {
30
30
  var commandRun = {};
31
- _commander.program.option('--').option('--v', 'Verbose output').option('--debug', 'Output for developers').option('--format <char>', 'Output format; json (default), yaml').option('--path <char>', 'where to perform operation').option('--npm-client <char>', 'npm client to use (must be installed) npm, yarn, pnpm', 'npm').option('--y', 'yes to all questions').option('--skip', 'skip frills like animations').option('--auto', 'yes to all questions, alias of y').option('--no-i', 'prevent interactions / sub-process, good for scripting')
31
+ _commander.program.option('--').option('--v', 'Verbose output').option('--debug', 'Output for developers').option('--format <char>', 'Output format; json (default), yaml').option('--path <char>', 'where to perform operation').option('--npm-client <char>', 'npm client to use (must be installed) npm, yarn, pnpm', 'npm').option('--y', 'yes to all questions').option('--skip', 'skip frills like animations').option('--quiet', 'remove console logging').option('--auto', 'yes to all questions, alias of y').option('--no-i', 'prevent interactions / sub-process, good for scripting').option('--to-file <char>', 'redirect command output to a file')
32
32
 
33
33
  // options for webcomponent
34
34
  .option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element')
35
35
 
36
36
  // options for site
37
- .option('--import-site <char>', 'URL of site to import').option('--import-structure <char>', `import method to use:\n\rpressbooksToSite\n\relmslnToSite\n\rhaxcmsToSite\n\rnotionToSite\n\rgitbookToSite\n\revolutionToSite\n\rhtmlToSite\n\rdocxToSite`).option('--node-op <char>', 'node operation to perform').option('--item-id <char>', 'node ID to operate on').option('--name <char>', 'name of the project').option('--domain <char>', 'published domain name').helpCommand(true);
37
+ .option('--import-site <char>', 'URL of site to import').option('--import-structure <char>', `import method to use:\n\rpressbooksToSite\n\relmslnToSite\n\rhaxcmsToSite\n\rnotionToSite\n\rgitbookToSite\n\revolutionToSite\n\rhtmlToSite\n\rdocxToSite`).option('--node-op <char>', 'node operation to perform').option('--item-id <char>', 'node ID to operate on').option('--name <char>', 'name of the project').option('--domain <char>', 'published domain name').option('--title-scrape <char>', 'CSS Selector for `title` in resource').option('--content-scrape <char>', 'CSS Selector for `body` in resource').option('--items-import <char>', 'import items from a file / site').helpCommand(true);
38
38
 
39
39
  // default command which runs interactively
40
40
  _commander.program.command('start').description('Interactive program to pick options').action(() => {
@@ -61,7 +61,7 @@ async function main() {
61
61
  commandRun.arguments.action = action;
62
62
  commandRun.options.skip = true;
63
63
  }
64
- }).option('--path <char>', 'path the project should be created in').option('--import-site <char>', 'URL of site to import').option('--import-structure <char>', `import method to use:\n\rpressbooksToSite\n\relmslnToSite\n\rhaxcmsToSite\n\rnotionToSite\n\rgitbookToSite\n\revolutionToSite\n\rhtmlToSite\n\rdocxToSite`).option('--name <char>', 'name of the site (when creating a new one)').option('--domain <char>', 'published domain name').option('--node-op <char>', 'node operation to perform').option('--no-i', 'prevent interactions / sub-process, good for scripting').version(await HAXCMS.getHAXCMSVersion());
64
+ }).option('--path <char>', 'path the project should be created in').option('--import-site <char>', 'URL of site to import').option('--import-structure <char>', `import method to use:\n\rpressbooksToSite\n\relmslnToSite\n\rhaxcmsToSite\n\rnotionToSite\n\rgitbookToSite\n\revolutionToSite\n\rhtmlToSite\n\rdocxToSite`).option('--name <char>', 'name of the site (when creating a new one)').option('--domain <char>', 'published domain name').option('--node-op <char>', 'node operation to perform').option('--no-i', 'prevent interactions / sub-process, good for scripting').option('--to-file <char>', 'redirect command output to a file').option('--item-import <char>', 'import items from a file / site').version(await HAXCMS.getHAXCMSVersion());
65
65
  let siteNodeOps = (0, _site.siteNodeOperations)();
66
66
  for (var i in siteNodeOps) {
67
67
  _commander.program.option(`--${(0, _utils.camelToDash)(siteNodeOps[i].value)} <char>`, `${siteNodeOps[i].label}`);
@@ -80,7 +80,7 @@ async function main() {
80
80
  commandRun.arguments.name = name;
81
81
  commandRun.options.skip = true;
82
82
  }
83
- }).option('--path <char>', 'path the project should be created in').option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element').option('--no-i', 'prevent interactions / sub-process, good for scripting');
83
+ }).option('--path <char>', 'path the project should be created in').option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element').option('--to-file <char>', 'redirect command output to a file').option('--no-i', 'prevent interactions / sub-process, good for scripting');
84
84
  // process program arguments
85
85
  _commander.program.parse();
86
86
  commandRun.options = {
@@ -88,7 +88,7 @@ async function main() {
88
88
  ..._commander.program.opts()
89
89
  };
90
90
  if (commandRun.options.debug) {
91
- console.log(commandRun);
91
+ (0, _statements.log)(commandRun);
92
92
  }
93
93
  // auto and y assume same thing
94
94
  if (commandRun.options.y || commandRun.options.auto) {
@@ -101,9 +101,13 @@ async function main() {
101
101
  let value = await exec(`git config user.name`);
102
102
  author = value.stdout.trim();
103
103
  } catch (e) {
104
- console.log('git user name not configured. Run the following to do this:');
105
- console.log('git config --global user.name "namehere"');
106
- console.log('git config --global user.email "email@here');
104
+ (0, _statements.log)('git user name not configured. Run the following to do this:');
105
+ (0, _statements.log)('git config --global user.name "namehere"');
106
+ (0, _statements.log)('git config --global user.email "email@here');
107
+ }
108
+ // bridge to log so we can respect this setting
109
+ if (commandRun.options.quiet) {
110
+ process.haxquiet = true;
107
111
  }
108
112
  // only set path if not already set
109
113
  if (!commandRun.options.path && commandRun.options.skip) {
@@ -142,7 +146,9 @@ async function main() {
142
146
  }
143
147
  // see if we're in a monorepo
144
148
  if (packageData.useWorkspaces && packageData.workspaces && packageData.workspaces.packages && packageData.workspaces.packages[0]) {
145
- p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` Monorepo detected : Setting relative defaults `))}`);
149
+ if (!commandRun.options.quiet) {
150
+ p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` Monorepo detected : Setting relative defaults `))}`);
151
+ }
146
152
  commandRun.options.isMonorepo = true;
147
153
  commandRun.options.auto = true;
148
154
  // assumed if monorepo
@@ -160,7 +166,7 @@ async function main() {
160
166
  }
161
167
  }
162
168
  if (commandRun.options.debug) {
163
- console.log(packageData);
169
+ (0, _statements.log)(packageData);
164
170
  }
165
171
  // CLI works within context of the site if one is detected, otherwise we can do other thingss
166
172
  if (await hax.systemStructureContext()) {
@@ -172,7 +178,7 @@ async function main() {
172
178
  commandRun.options.skip = true;
173
179
  await (0, _webcomponent.webcomponentCommandDetected)(commandRun, packageData);
174
180
  } else {
175
- if (commandRun.command === 'start' && !commandRun.options.y && !commandRun.options.auto && !commandRun.options.skip) {
181
+ if (commandRun.command === 'start' && !commandRun.options.y && !commandRun.options.auto && !commandRun.options.skip && !commandRun.options.quiet) {
176
182
  await (0, _statements.haxIntro)();
177
183
  }
178
184
  let activeProject = null;
@@ -181,10 +187,14 @@ async function main() {
181
187
  };
182
188
  while (project.type !== 'quit') {
183
189
  if (activeProject) {
184
- p.note(` 🧙🪄 BE GONE ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgGreen(activeProject)))} sub-process daemon! 🪄 + ✨ 👹 = 💀 `);
190
+ if (!commandRun.options.quiet) {
191
+ p.note(` 🧙🪄 BE GONE ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgGreen(activeProject)))} sub-process daemon! 🪄 + ✨ 👹 = 💀 `);
192
+ }
185
193
  // ensure if we were automatically running the command we end
186
194
  if (commandRun.options.y) {
187
- (0, _statements.communityStatement)();
195
+ if (!commandRun.options.quiet) {
196
+ (0, _statements.communityStatement)();
197
+ }
188
198
  process.exit(0);
189
199
  }
190
200
  // otherwise null to reset the program to run again
@@ -219,8 +229,10 @@ async function main() {
219
229
  })
220
230
  }, {
221
231
  onCancel: () => {
222
- p.cancel('🧙🪄 Merlin: Leaving so soon? HAX ya later');
223
- (0, _statements.communityStatement)();
232
+ if (!commandRun.options.quiet) {
233
+ p.cancel('🧙🪄 Merlin: Leaving so soon? HAX ya later');
234
+ (0, _statements.communityStatement)();
235
+ }
224
236
  process.exit(0);
225
237
  }
226
238
  });
@@ -230,7 +242,9 @@ async function main() {
230
242
  // detect being in a haxcms scaffold. easiest way is _sites being in this directory
231
243
  // set the path automatically so we skip the question
232
244
  if (commandRun.command === "site" && fs.existsSync(`${process.cwd()}/_sites`)) {
233
- p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXcms detected : Path set automatically `))}`);
245
+ if (!commandRun.options.quiet) {
246
+ p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXcms detected : Path set automatically `))}`);
247
+ }
234
248
  commandRun.options.path = `${process.cwd()}/_sites`;
235
249
  }
236
250
  activeProject = project.type;
@@ -333,6 +347,24 @@ async function main() {
333
347
  });
334
348
  }
335
349
  },
350
+ theme: async ({
351
+ results
352
+ }) => {
353
+ let themes = await (0, _site.siteThemeList)();
354
+ if (!commandRun.options.theme) {
355
+ // support having no theme but autoselecting
356
+ if (!commandRun.options.auto && !commandRun.options.skip) {
357
+ commandRun.options.theme = themes[0];
358
+ } else {
359
+ return p.select({
360
+ message: "Theme:",
361
+ required: false,
362
+ options: themes,
363
+ initialValue: themes[0]
364
+ });
365
+ }
366
+ }
367
+ },
336
368
  extras: ({
337
369
  results
338
370
  }) => {
@@ -376,8 +408,10 @@ async function main() {
376
408
  }
377
409
  }, {
378
410
  onCancel: () => {
379
- p.cancel('🧙🪄 Merlin: Canceling CLI.. HAX ya later');
380
- (0, _statements.communityStatement)();
411
+ if (!commandRun.options.quiet) {
412
+ p.cancel('🧙🪄 Merlin: Canceling CLI.. HAX ya later');
413
+ (0, _statements.communityStatement)();
414
+ }
381
415
  process.exit(0);
382
416
  }
383
417
  });
@@ -418,7 +452,9 @@ async function main() {
418
452
  }
419
453
  }
420
454
  }
421
- (0, _statements.communityStatement)();
455
+ if (!commandRun.options.quiet) {
456
+ (0, _statements.communityStatement)();
457
+ }
422
458
  }
423
459
  }
424
460
  main().catch(console.error);
@@ -8,6 +8,7 @@ exports.enableCoreServices = enableCoreServices;
8
8
  exports.enableExperimentalServices = enableExperimentalServices;
9
9
  exports.enableHAXcmsServices = enableHAXcmsServices;
10
10
  exports.enableServices = enableServices;
11
+ var _statements = require("./statements.js");
11
12
  // because node hates mixing modern web at times this is a fork of @haxtheweb/micro-frontend-registry
12
13
  // and can fall out of date
13
14
  /**
@@ -50,8 +51,8 @@ const MicroFrontendRegCapabilities = function (SuperClass) {
50
51
  */
51
52
  define(item) {
52
53
  if (!(item instanceof MicroFrontend)) {
53
- console.warn("MicroFrontendRegistry: use class MicroFrontend instance but if keys match it will register still.");
54
- console.warn(item);
54
+ (0, _statements.log)("MicroFrontendRegistry: use class MicroFrontend instance but if keys match it will register still.", 'warn');
55
+ (0, _statements.log)(item, 'warn');
55
56
  }
56
57
  // validate item has all keys we care about
57
58
  if (Object.keys(item).every(key => MicroFrontendKeys.includes(key))) {
@@ -102,7 +103,7 @@ const MicroFrontendRegCapabilities = function (SuperClass) {
102
103
  }
103
104
  }
104
105
  if (!testOnly) {
105
- console.error(`call for ${name} but not found in micro-frontend-registry`);
106
+ (0, _statements.log)(`call for ${name} but not found in micro-frontend-registry`, 'error');
106
107
  }
107
108
  return null;
108
109
  }
@@ -170,7 +171,7 @@ const MicroFrontendRegCapabilities = function (SuperClass) {
170
171
  data: null
171
172
  };
172
173
  }).catch((e, d) => {
173
- console.warn("Request failed", e);
174
+ (0, _statements.log)("Request failed", 'warn');
174
175
  // this is endpoint completely failed to respond
175
176
  return {
176
177
  status: 500,
@@ -190,7 +191,7 @@ const MicroFrontendRegCapabilities = function (SuperClass) {
190
191
  data: null
191
192
  };
192
193
  }).catch((e, d) => {
193
- console.warn("Request failed", e);
194
+ (0, _statements.log)("Request failed", 'warn');
194
195
  // this is endpoint completely failed to respond
195
196
  return {
196
197
  status: 500,
@@ -12,15 +12,16 @@ exports.siteNodeStatsOperations = siteNodeStatsOperations;
12
12
  exports.siteProcess = siteProcess;
13
13
  exports.siteThemeList = siteThemeList;
14
14
  var _promises = require("node:timers/promises");
15
+ var fs = _interopRequireWildcard(require("node:fs"));
15
16
  var p = _interopRequireWildcard(require("@clack/prompts"));
16
17
  var _picocolors = _interopRequireDefault(require("picocolors"));
17
18
  var _jsYaml = require("js-yaml");
18
19
  var _nodeHtmlParser = require("node-html-parser");
19
20
  var _statements = require("../statements.js");
20
- var _utils = require("../utils.js");
21
21
  var _microFrontendRegistry = require("../micro-frontend-registry.js");
22
22
  var haxcmsNodejsCli = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs/dist/cli.js"));
23
23
  var hax = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs"));
24
+ var josfile = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs/dist/lib/JSONOutlineSchema.js"));
24
25
  var child_process = _interopRequireWildcard(require("child_process"));
25
26
  var util = _interopRequireWildcard(require("node:util"));
26
27
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -28,10 +29,11 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
28
29
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
30
  // trick MFR into giving local paths
30
31
  globalThis.MicroFrontendRegistryConfig = {
31
- base: `@haxtheweb/open-apis/`
32
+ base: `@haxtheweb/open-apis`
32
33
  };
33
34
  // emable HAXcms routes so we have name => path just like on frontend!
34
35
  _microFrontendRegistry.MicroFrontendRegistry.enableServices(['core', 'haxcms', 'experimental']);
36
+ const JSONOutlineSchema = josfile.default;
35
37
  const HAXCMS = hax.HAXCMS;
36
38
  const exec = util.promisify(child_process.exec);
37
39
  var sysSurge = true;
@@ -87,6 +89,9 @@ function siteActions() {
87
89
  }, {
88
90
  value: 'site:items',
89
91
  label: "Site items"
92
+ }, {
93
+ value: 'site:items-import',
94
+ label: "Import items (JOS / site.json)"
90
95
  }, {
91
96
  value: 'site:list-files',
92
97
  label: "List site files"
@@ -105,6 +110,9 @@ function siteActions() {
105
110
  }, {
106
111
  value: 'site:sync',
107
112
  label: "Sync git repo"
113
+ }, {
114
+ value: 'site:surge',
115
+ label: "Publish site to Surge.sh"
108
116
  }];
109
117
  }
110
118
  async function siteCommandDetected(commandRun) {
@@ -114,7 +122,7 @@ async function siteCommandDetected(commandRun) {
114
122
  commandRun.arguments.action = 'status';
115
123
  }
116
124
  commandRun.command = "site";
117
- if (!commandRun.options.y && commandRun.options.i) {
125
+ if (!commandRun.options.y && commandRun.options.i && !commandRun.options.quiet) {
118
126
  p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Site detected `))}`);
119
127
  p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Name: ${activeHaxsite.name} `))}`);
120
128
  }
@@ -132,12 +140,6 @@ async function siteCommandDetected(commandRun) {
132
140
  // infinite loop until quitting the cli
133
141
  while (operation.action !== 'quit') {
134
142
  let actions = siteActions();
135
- if (sysSurge) {
136
- actions.push({
137
- value: 'site:surge',
138
- label: "Publish site to Surge.sh"
139
- });
140
- }
141
143
  actions.push({
142
144
  value: 'quit',
143
145
  label: "🚪 Quit"
@@ -159,8 +161,10 @@ async function siteCommandDetected(commandRun) {
159
161
  })
160
162
  }, {
161
163
  onCancel: () => {
162
- p.cancel('🧙 Merlin: Canceling CLI.. HAX ya later 🪄');
163
- (0, _statements.communityStatement)();
164
+ if (!commandRun.options.quiet) {
165
+ p.cancel('🧙 Merlin: Canceling CLI.. HAX ya later 🪄');
166
+ (0, _statements.communityStatement)();
167
+ }
164
168
  process.exit(0);
165
169
  }
166
170
  });
@@ -199,7 +203,7 @@ async function siteCommandDetected(commandRun) {
199
203
  lastUpdated: date.toLocaleDateString("en-US"),
200
204
  tagUsage: els
201
205
  };
202
- if (!commandRun.options.format) {
206
+ if (!commandRun.options.format && !commandRun.options.quiet) {
203
207
  p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Title: ${siteStats.title} `))}`);
204
208
  p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Description: ${siteStats.description} `))}`);
205
209
  p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Theme: ${siteStats.themeName} (${siteStats.themeElement})`))}`);
@@ -207,25 +211,123 @@ async function siteCommandDetected(commandRun) {
207
211
  p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Last updated: ${siteStats.lastUpdated} `))}`);
208
212
  p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Tags used: ${JSON.stringify(siteStats.tagUsage, null, 2)} `))}`);
209
213
  } else if (commandRun.options.format === 'yaml') {
210
- console.log((0, _jsYaml.dump)(siteStats));
214
+ (0, _statements.log)((0, _jsYaml.dump)(siteStats));
211
215
  } else {
212
- console.log(siteStats);
216
+ (0, _statements.log)(siteStats);
217
+ }
218
+ // simple redirecting to file
219
+ if (commandRun.options.toFile) {
220
+ if (commandRun.options.format === 'yaml') {
221
+ fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(siteStats));
222
+ } else {
223
+ fs.writeFileSync(commandRun.options.toFile, JSON.stringify(siteStats, null, 2));
224
+ }
213
225
  }
214
226
  break;
215
227
  case "site:items":
216
- if (commandRun.options.format === 'yaml') {
217
- console.log((0, _jsYaml.dump)(activeHaxsite.manifest.items));
228
+ let siteitems = [];
229
+ if (commandRun.options.itemId != null) {
230
+ siteitems = activeHaxsite.manifest.findBranch(commandRun.options.itemId);
231
+ } else {
232
+ siteitems = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
233
+ }
234
+ for (let i in siteitems) {
235
+ let page = await activeHaxsite.loadNode(siteitems[i].id);
236
+ siteitems[i].content = await activeHaxsite.getPageContent(page);
237
+ }
238
+ // simple redirecting to file if asked for
239
+ if (commandRun.options.toFile) {
240
+ let contents = '';
241
+ if (commandRun.options.format === 'yaml') {
242
+ contents = (0, _jsYaml.dump)(siteitems);
243
+ } else {
244
+ contents = JSON.stringify(siteitems, null, 2);
245
+ }
246
+ fs.writeFileSync(commandRun.options.toFile, contents);
218
247
  } else {
219
- console.log(activeHaxsite.manifest.items);
248
+ if (commandRun.options.format === 'yaml') {
249
+ (0, _statements.log)((0, _jsYaml.dump)(siteitems));
250
+ } else {
251
+ (0, _statements.log)(siteitems);
252
+ }
253
+ }
254
+ break;
255
+ case "site:items-import":
256
+ // need source, then resolve what it is
257
+ if (commandRun.options.itemsImport) {
258
+ let location = commandRun.options.itemsImport;
259
+ let josImport = new JSONOutlineSchema();
260
+ var itemsImport = [];
261
+ // support for address, as in import from some place else
262
+ if (location.startsWith('https://') || location.startsWith('http://')) {
263
+ if (location.endsWith('/site.json')) {
264
+ location = location.replace('/site.json', '');
265
+ } else if (!location.endsWith('/')) {
266
+ location = location + '/';
267
+ }
268
+ let f = await fetch(`${location}site.json`).then(d => d.ok ? d.json() : null);
269
+ if (f && f.items) {
270
+ josImport.items = f.items;
271
+ } else {
272
+ // invalid data
273
+ process.exit(0);
274
+ }
275
+ }
276
+ // look on prem
277
+ else if (fs.existsSync(location)) {
278
+ let fileContents = await fs.readFileSync(location);
279
+ if (location.endsWith('.json')) {
280
+ josImport.items = JSON.parse(fileContents);
281
+ } else if (location.endsWith('.yaml')) {
282
+ josImport.items = await (0, _jsYaml.load)(fileContents);
283
+ }
284
+ }
285
+ // allows for filtering
286
+ if (commandRun.options.itemId) {
287
+ itemsImport = josImport.findBranch(commandRun.options.itemId);
288
+ } else {
289
+ itemsImport = josImport.items;
290
+ }
291
+ for (let i in josImport.items) {
292
+ if (josImport.items[i].location && !josImport.items[i].content) {
293
+ josImport.items[i].content = await fetch(`${location}${josImport.items[i].location}`).then(d => d.ok ? d.text() : '');
294
+ }
295
+ }
296
+ let itemIdMap = {};
297
+ for (let i in josImport.items) {
298
+ // if we have a parent set by force to append this structure to
299
+ // then see if parent = null (implying top level in full site import)
300
+ // or match on itemId to imply that it's the top (no matter parent status)
301
+ if (commandRun.options.parentId) {
302
+ if (josImport.items[i].parent === null || josImport.items[i].id === commandRun.options.itemId) {
303
+ josImport.items[i].parent = commandRun.options.parentId;
304
+ }
305
+ }
306
+ // see if map has an entry that is already set
307
+ if (itemIdMap[josImport.items[i].parent]) {
308
+ // remaps the parent of this item bc the thing imported has changed ID
309
+ josImport.items[i].parent = itemIdMap[josImport.items[i].parent];
310
+ }
311
+ let tmpAddedItem = await activeHaxsite.addPage(josImport.items[i].parent, josImport.items[i].title, 'html', josImport.items[i].slug, null, josImport.items[i].indent, josImport.items[i].content, josImport.items[i].order, josImport.items[i].metadata);
312
+ // set in the map for future translations
313
+ itemIdMap[josImport.items[i].id] = tmpAddedItem.id;
314
+ }
315
+ if (!commandRun.options.quiet) {
316
+ (0, _statements.log)(`${josImport.items.length} nodes imported`);
317
+ }
318
+ } else if (!commandRun.options.quiet) {
319
+ (0, _statements.log)('Must specify --item-import as path to valid item export file or URL', 'error');
220
320
  }
221
321
  break;
222
322
  case "start":
223
323
  try {
224
- p.intro(`Starting server.. `);
225
- p.intro(`⌨️ To stop server, press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}`);
324
+ if (!commandRun.options.quiet) {
325
+ p.intro(`Starting server.. `);
326
+ p.intro(`⌨️ To stop server, press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}`);
327
+ }
226
328
  await exec(`cd ${activeHaxsite.directory} && npx @haxtheweb/haxcms-nodejs`);
227
329
  } catch (e) {
228
- console.log(e.stderr);
330
+ (0, _statements.log)(e.stderr);
229
331
  }
230
332
  break;
231
333
  case "node:stats":
@@ -257,10 +359,28 @@ async function siteCommandDetected(commandRun) {
257
359
  if (commandRun.options.nodeOp && siteNodeStatsOperations(commandRun.options.nodeOp)) {
258
360
  switch (commandRun.options.nodeOp) {
259
361
  case 'details':
260
- console.log(page);
362
+ if (commandRun.options.format === 'yaml') {
363
+ (0, _statements.log)((0, _jsYaml.dump)(page));
364
+ } else {
365
+ (0, _statements.log)(page);
366
+ }
367
+ // simple redirecting to file
368
+ if (commandRun.options.toFile) {
369
+ if (commandRun.options.format === 'yaml') {
370
+ fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(page));
371
+ } else {
372
+ fs.writeFileSync(commandRun.options.toFile, JSON.stringify(page, null, 2));
373
+ }
374
+ }
261
375
  break;
262
376
  case 'html':
263
- console.log(await activeHaxsite.getPageContent(page));
377
+ let itemHTML = await activeHaxsite.getPageContent(page);
378
+ // simple redirecting to file
379
+ if (commandRun.options.toFile) {
380
+ fs.writeFileSync(commandRun.options.toFile, itemHTML);
381
+ } else {
382
+ (0, _statements.log)(itemHTML);
383
+ }
264
384
  break;
265
385
  case 'schema':
266
386
  // next up
@@ -273,25 +393,42 @@ async function siteCommandDetected(commandRun) {
273
393
  els.push(await nodeToHaxElement(node, null));
274
394
  }
275
395
  }
276
- console.log(els);
396
+ // simple redirecting to file
397
+ if (commandRun.options.toFile) {
398
+ if (commandRun.options.format === 'yaml') {
399
+ fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(els));
400
+ } else {
401
+ fs.writeFileSync(commandRun.options.toFile, JSON.stringify(els, null, 2));
402
+ }
403
+ } else {
404
+ if (commandRun.options.format === 'yaml') {
405
+ (0, _statements.log)((0, _jsYaml.dump)(els));
406
+ } else {
407
+ (0, _statements.log)(els);
408
+ }
409
+ }
277
410
  break;
278
411
  case 'md':
279
412
  let resp = await openApiBroker('@core', 'htmlToMd', {
280
413
  html: await activeHaxsite.getPageContent(page)
281
414
  });
282
- console.log(resp.res.data.data);
415
+ // simple redirecting to file
416
+ if (commandRun.options.toFile) {
417
+ fs.writeFileSync(commandRun.options.toFile, resp.res.data.data);
418
+ } else {
419
+ (0, _statements.log)(resp.res.data.data);
420
+ }
283
421
  break;
284
422
  }
285
423
  }
286
424
  }
287
425
  } catch (e) {
288
- console.log(e.stderr);
289
- console.log(e);
426
+ (0, _statements.log)(e.stderr);
427
+ (0, _statements.log)(e);
290
428
  }
291
429
  break;
292
430
  case "node:add":
293
431
  try {
294
- // @todo accept title if not supplied
295
432
  if (!commandRun.options.title) {
296
433
  commandRun.options.title = await p.text({
297
434
  message: `Title for this page`,
@@ -304,18 +441,68 @@ async function siteCommandDetected(commandRun) {
304
441
  }
305
442
  });
306
443
  }
307
- let resp = await haxcmsNodejsCli.cliBridge('createNode', {
444
+ var createNodeBody = {
308
445
  site: activeHaxsite,
309
446
  node: {
310
447
  title: commandRun.options.title
311
448
  }
312
- });
449
+ };
450
+ // this would be odd but could be direct with no format specified
451
+ if (commandRun.options.content && !commandRun.options.format) {
452
+ // only API where it's called contents and already out there {facepalm}
453
+ // but user already has commands where it's --content as arg
454
+ createNodeBody.node.contents = commandRun.options.content;
455
+ } else if (commandRun.options.content && commandRun.options.format) {
456
+ let locationContent = '';
457
+ // if we have format set, then we need to interpret content as a url
458
+ let location = commandRun.options.content;
459
+ // support for address, as in import from some place else
460
+ if (location.startsWith('https://') || location.startsWith('http://')) {
461
+ locationContent = await fetch(location).then(d => d.ok ? d.text() : '');
462
+ }
463
+ // look on prem
464
+ else if (fs.existsSync(location)) {
465
+ locationContent = await fs.readFileSync(location);
466
+ }
467
+ // format dictates additional processing; html is default
468
+ switch (commandRun.options.format) {
469
+ case 'json':
470
+ locationContent = JSON.parse(locationContent);
471
+ break;
472
+ case 'yaml':
473
+ locationContent = await (0, _jsYaml.load)(locationContent);
474
+ break;
475
+ case 'md':
476
+ let resp = await openApiBroker('@core', 'mdToHtml', {
477
+ md: locationContent,
478
+ raw: true
479
+ });
480
+ if (resp.res.data) {
481
+ locationContent = resp.res.data;
482
+ }
483
+ break;
484
+ }
485
+ // support for scraper mode to find title from the content responsee
486
+ if (commandRun.options.titleScrape) {
487
+ let dom = (0, _nodeHtmlParser.parse)(`${locationContent}`);
488
+ createNodeBody.node.title = dom.querySelector(`${commandRun.options.titleScrape}`).textContent;
489
+ }
490
+ // support scraper mode which targets a wrapper for the actual content
491
+ if (commandRun.options.contentScrape) {
492
+ let dom = (0, _nodeHtmlParser.parse)(`${locationContent}`);
493
+ locationContent = dom.querySelector(`${commandRun.options.contentScrape}`).innerHTML;
494
+ }
495
+ createNodeBody.node.contents = locationContent;
496
+ }
497
+ let resp = await haxcmsNodejsCli.cliBridge('createNode', createNodeBody);
313
498
  if (commandRun.options.v) {
314
- console.log(resp.res.data);
499
+ (0, _statements.log)(resp.res.data);
500
+ }
501
+ if (!commandRun.options.quiet) {
502
+ (0, _statements.log)(`"${createNodeBody.node.title}" added to site`);
315
503
  }
316
- console.log(`"${commandRun.options.title}" added to site`);
317
504
  } catch (e) {
318
- console.log(e.stderr);
505
+ (0, _statements.log)(e.stderr);
319
506
  }
320
507
  break;
321
508
  case "node:edit":
@@ -397,8 +584,52 @@ async function siteCommandDetected(commandRun) {
397
584
  // ensure we set empty values, just not completely undefined values
398
585
  if (typeof commandRun.options[commandRun.options.nodeOp] !== "undefined") {
399
586
  if (commandRun.options.nodeOp === 'content') {
400
- if (commandRun.options.content && (await page.writeLocation(commandRun.options.content))) {
401
- console.log(`node:edit success updated page content: "${page.id}`);
587
+ let locationContent = '';
588
+ // this would be odd but could be direct with no format specified
589
+ if (commandRun.options.content && !commandRun.options.format) {
590
+ locationContent = commandRun.options.content;
591
+ }
592
+ // this implies what we were given needs processing as a file / url
593
+ else if (commandRun.options.content && commandRun.options.format) {
594
+ // if we have format set, then we need to interpret content as a url
595
+ let location = commandRun.options.content;
596
+ // support for address, as in import from some place else
597
+ if (location.startsWith('https://') || location.startsWith('http://')) {
598
+ locationContent = await fetch(location).then(d => d.ok ? d.text() : '');
599
+ }
600
+ // look on prem
601
+ else if (fs.existsSync(location)) {
602
+ locationContent = await fs.readFileSync(location);
603
+ }
604
+ // format dictates additional processing; html is default
605
+ switch (commandRun.options.format) {
606
+ case 'json':
607
+ locationContent = JSON.parse(locationContent);
608
+ break;
609
+ case 'yaml':
610
+ locationContent = await (0, _jsYaml.load)(locationContent);
611
+ break;
612
+ case 'md':
613
+ let resp = await openApiBroker('@core', 'mdToHtml', {
614
+ md: locationContent,
615
+ raw: true
616
+ });
617
+ if (resp.res.data) {
618
+ locationContent = resp.res.data;
619
+ }
620
+ break;
621
+ }
622
+ // support scraper mode which targets a wrapper for the actual content
623
+ if (commandRun.options.contentScrape) {
624
+ let dom = (0, _nodeHtmlParser.parse)(`${locationContent}`);
625
+ locationContent = dom.querySelector(`${commandRun.options.contentScrape}`).innerHTML;
626
+ }
627
+ }
628
+ // if we have content (meaning it's not blank) then try to write the page location
629
+ if (locationContent && (await page.writeLocation(locationContent))) {
630
+ if (!commandRun.options.quiet) {
631
+ (0, _statements.log)(`node:edit success updated page content: "${page.id}`);
632
+ }
402
633
  } else {
403
634
  console.warn(`node:edit failure to write page content : ${page.id}`);
404
635
  }
@@ -413,13 +644,13 @@ async function siteCommandDetected(commandRun) {
413
644
  }
414
645
  let resp = await activeHaxsite.updateNode(page);
415
646
  if (commandRun.options.v) {
416
- console.log(resp);
647
+ (0, _statements.log)(resp);
417
648
  }
418
649
  }
419
650
  }
420
651
  }
421
652
  } catch (e) {
422
- console.log(e.stderr);
653
+ (0, _statements.log)(e.stderr);
423
654
  }
424
655
  break;
425
656
  case "node:delete":
@@ -455,14 +686,14 @@ async function siteCommandDetected(commandRun) {
455
686
  if (resp.res.data === 500) {
456
687
  console.warn(`node:delete failed "${commandRun.options.itemId} not found`);
457
688
  } else {
458
- console.log(`"${commandRun.options.itemId}" deleted`);
689
+ (0, _statements.log)(`"${commandRun.options.itemId}" deleted`);
459
690
  }
460
691
  } else {
461
- console.log(`Delete operation canceled`);
692
+ (0, _statements.log)(`Delete operation canceled`);
462
693
  }
463
694
  }
464
695
  } catch (e) {
465
- console.log(e.stderr);
696
+ (0, _statements.log)(e.stderr);
466
697
  }
467
698
  break;
468
699
  case "site:sync":
@@ -470,7 +701,7 @@ async function siteCommandDetected(commandRun) {
470
701
  try {
471
702
  await exec(`cd ${activeHaxsite.directory} && git pull && git push`);
472
703
  } catch (e) {
473
- console.log(e.stderr);
704
+ (0, _statements.log)(e.stderr);
474
705
  }
475
706
  break;
476
707
  case "site:theme":
@@ -493,14 +724,25 @@ async function siteCommandDetected(commandRun) {
493
724
  }
494
725
  }
495
726
  } catch (e) {
496
- console.log(e.stderr);
727
+ (0, _statements.log)(e.stderr);
497
728
  }
498
729
  break;
499
730
  case "site:surge":
500
731
  try {
732
+ // attempt to install; implies they asked to publish with surge but
733
+ // system test did not see it globally
734
+ if (!sysSurge) {
735
+ let s = p.spinner();
736
+ s.start((0, _statements.merlinSays)('Installing Surge.sh globally so we can publish'));
737
+ let execOutput = await exec(`npm install --global surge`);
738
+ s.stop((0, _statements.merlinSays)('surge.sh installed globally'));
739
+ (0, _statements.log)(execOutput.stdout.trim());
740
+ sysSurge = true;
741
+ }
501
742
  if (!commandRun.options.domain) {
502
743
  commandRun.options.domain = await p.text({
503
744
  message: `Domain for surge`,
745
+ initialValue: `haxcli-${activeHaxsite.name}.surge.sh`,
504
746
  defaultValue: `haxcli-${activeHaxsite.name}.surge.sh`,
505
747
  required: true,
506
748
  validate: value => {
@@ -511,9 +753,10 @@ async function siteCommandDetected(commandRun) {
511
753
  });
512
754
  }
513
755
  let execOutput = await exec(`cd ${activeHaxsite.directory} && surge . ${commandRun.options.domain}`);
514
- console.log(execOutput.stdout.trim());
756
+ (0, _statements.log)(execOutput.stdout.trim());
757
+ (0, _statements.log)(`Site published: https://${commandRun.options.domain}`);
515
758
  } catch (e) {
516
- console.log(e.stderr);
759
+ (0, _statements.log)(e.stderr);
517
760
  }
518
761
  break;
519
762
  case "site:file-list":
@@ -523,9 +766,9 @@ async function siteCommandDetected(commandRun) {
523
766
  filename: commandRun.options.filename
524
767
  }, res);
525
768
  if (commandRun.options.format === 'yaml') {
526
- console.log((0, _jsYaml.dump)(res.data));
769
+ (0, _statements.log)((0, _jsYaml.dump)(res.data));
527
770
  } else {
528
- console.log(res.data);
771
+ (0, _statements.log)(res.data);
529
772
  }
530
773
  break;
531
774
  case "site:html":
@@ -559,7 +802,20 @@ async function siteCommandDetected(commandRun) {
559
802
  }
560
803
  }
561
804
  }
562
- console.log(els);
805
+ // simple redirecting to file
806
+ if (commandRun.options.toFile) {
807
+ if (commandRun.options.format === 'yaml') {
808
+ fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(els));
809
+ } else {
810
+ fs.writeFileSync(commandRun.options.toFile, JSON.stringify(els, null, 2));
811
+ }
812
+ } else {
813
+ if (commandRun.options.format === 'yaml') {
814
+ (0, _statements.log)((0, _jsYaml.dump)(els));
815
+ } else {
816
+ (0, _statements.log)(els);
817
+ }
818
+ }
563
819
  } else {
564
820
  for (var i in items) {
565
821
  let page = activeHaxsite.loadNode(items[i].id);
@@ -570,9 +826,23 @@ async function siteCommandDetected(commandRun) {
570
826
  let resp = await openApiBroker('@core', 'htmlToMd', {
571
827
  html: siteContent
572
828
  });
573
- console.log(resp.res.data.data);
829
+ if (commandRun.options.toFile) {
830
+ fs.writeFileSync(commandRun.options.toFile, resp.res.data.data);
831
+ if (!commandRun.options.quiet) {
832
+ (0, _statements.log)(`${commandRun.options.toFile} written`);
833
+ }
834
+ } else {
835
+ (0, _statements.log)(resp.res.data.data);
836
+ }
574
837
  } else {
575
- console.log(siteContent);
838
+ if (commandRun.options.toFile) {
839
+ fs.writeFileSync(commandRun.options.toFile, siteContent);
840
+ if (!commandRun.options.quiet) {
841
+ (0, _statements.log)(`${commandRun.options.toFile} written`);
842
+ }
843
+ } else {
844
+ (0, _statements.log)(siteContent);
845
+ }
576
846
  }
577
847
  }
578
848
  break;
@@ -581,12 +851,15 @@ async function siteCommandDetected(commandRun) {
581
851
  process.exit(0);
582
852
  break;
583
853
  }
584
- if (commandRun.options.y) {
854
+ // y or noi need to act like it ran and finish instead of looping options
855
+ if (commandRun.options.y || !commandRun.options.i) {
585
856
  process.exit(0);
586
857
  }
587
858
  operation.action = null;
588
859
  }
589
- (0, _statements.communityStatement)();
860
+ if (!commandRun.options.quiet) {
861
+ (0, _statements.communityStatement)();
862
+ }
590
863
  }
591
864
  function siteNodeStatsOperations(search = null) {
592
865
  let obj = [{
@@ -679,19 +952,21 @@ async function openApiBroker(scope, call, body) {
679
952
  // process site creation
680
953
  async function siteProcess(commandRun, project, port = '3000') {
681
954
  // auto select operations to perform if requested
955
+ var s = p.spinner();
682
956
  if (!project.extras) {
683
957
  project.extras = [];
684
958
  if (commandRun.options.i) {
685
959
  project.extras = ['launch'];
686
960
  }
687
961
  }
688
- let s = p.spinner();
689
- s.start((0, _statements.merlinSays)(`Creating new site: ${project.name}`));
962
+ if (!commandRun.options.quiet) {
963
+ s.start((0, _statements.merlinSays)(`Creating new site: ${project.name}`));
964
+ }
690
965
  let siteRequest = {
691
966
  "site": {
692
967
  "name": project.name,
693
968
  "description": "own course",
694
- "theme": commandRun.options.theme ? commandRun.options.theme : "clean-one"
969
+ "theme": commandRun.options.theme ? commandRun.options.theme : project.theme ? project.theme : "clean-one"
695
970
  },
696
971
  "build": {
697
972
  "type": "own",
@@ -723,6 +998,82 @@ async function siteProcess(commandRun, project, port = '3000') {
723
998
  siteRequest.build.files = resp.res.data.data.files;
724
999
  }
725
1000
  }
1001
+ // hidden import methodologies
1002
+ else if (commandRun.options.importStructure) {
1003
+ if (commandRun.options.importStructure === 'drupal7-book-print-html') {
1004
+ let siteContent = await fetch(commandRun.options.importSite).then(d => d.ok ? d.text() : '');
1005
+ if (siteContent) {
1006
+ // @todo refactor to support 9 levels of heirarchy as this is technically what Drupal supports
1007
+ let dom = (0, _nodeHtmlParser.parse)(siteContent);
1008
+ // pull all of level 1 of hierarchy
1009
+ let depth;
1010
+ let order = 0;
1011
+ let parent = null;
1012
+ let items = [];
1013
+ for (let branch1 of dom.querySelectorAll('.section-2')) {
1014
+ parent = null;
1015
+ depth = 0;
1016
+ let itemID = branch1.getAttribute('id');
1017
+ let item = {
1018
+ id: itemID,
1019
+ order: order,
1020
+ indent: depth,
1021
+ title: branch1.querySelector('h1').innerText,
1022
+ slug: itemID.replace('-', '/'),
1023
+ contents: branch1.querySelector(`.field.field-name-body .field-item`).innerHTML,
1024
+ parent: parent
1025
+ };
1026
+ items.push(item);
1027
+ order++;
1028
+ depth = 1;
1029
+ let parent2 = itemID;
1030
+ let order2 = 0;
1031
+ for (let branch2 of branch1.querySelectorAll('.section-3')) {
1032
+ itemID = branch2.getAttribute('id');
1033
+ let item = {
1034
+ id: itemID,
1035
+ order: order2,
1036
+ indent: depth,
1037
+ title: branch2.querySelector('h1').innerText,
1038
+ slug: itemID.replace('-', '/'),
1039
+ contents: branch2.querySelector(`.field.field-name-body .field-item`).innerHTML,
1040
+ parent: parent2
1041
+ };
1042
+ items.push(item);
1043
+ order2++;
1044
+ depth = 2;
1045
+ let parent3 = itemID;
1046
+ let order3 = 0;
1047
+ for (let branch3 of branch2.querySelectorAll('.section-4')) {
1048
+ itemID = branch3.getAttribute('id');
1049
+ let item = {
1050
+ id: itemID,
1051
+ order: order3,
1052
+ indent: depth,
1053
+ title: branch3.querySelector('h1').innerText,
1054
+ slug: itemID.replace('-', '/'),
1055
+ contents: branch3.querySelector(`.field.field-name-body .field-item`).innerHTML,
1056
+ parent: parent3
1057
+ };
1058
+ items.push(item);
1059
+ order3++;
1060
+ }
1061
+ }
1062
+ // obtain all images on the system to bring along with additional spider request
1063
+ let location = new URL(commandRun.options.importSite).origin;
1064
+ var files = {};
1065
+ for (let image of dom.querySelectorAll("img[src^='/']")) {
1066
+ if (!image.getAttribute('src').startsWith('//')) {
1067
+ files[image.getAttribute('src')] = `${location}${image.getAttribute('src')}`;
1068
+ }
1069
+ }
1070
+ siteRequest.build.files = files;
1071
+ }
1072
+ siteRequest.build.structure = 'import';
1073
+ siteRequest.build.items = items;
1074
+ }
1075
+ }
1076
+ }
726
1077
  }
727
1078
  HAXCMS.cliWritePath = `${project.path}`;
728
1079
  let res = new Res();
@@ -731,13 +1082,15 @@ async function siteProcess(commandRun, project, port = '3000') {
731
1082
  }, res);
732
1083
  if (commandRun.options.v) {
733
1084
  if (commandRun.options.format === 'yaml') {
734
- console.log((0, _jsYaml.dump)(res.data));
1085
+ (0, _statements.log)((0, _jsYaml.dump)(res.data));
735
1086
  } else {
736
- console.log(res.data);
1087
+ (0, _statements.log)(res.data);
737
1088
  }
738
1089
  }
739
- s.stop((0, _statements.merlinSays)(`${project.name} created!`));
740
- await (0, _promises.setTimeout)(500);
1090
+ if (!commandRun.options.quiet) {
1091
+ s.stop((0, _statements.merlinSays)(`${project.name} created!`));
1092
+ await (0, _promises.setTimeout)(500);
1093
+ }
741
1094
  if (project.gitRepo && !commandRun.options.isMonorepo) {
742
1095
  try {
743
1096
  await exec(`cd ${project.path}/${project.name} && git init && git add -A && git commit -m "first commit" && git branch -M main${project.gitRepo ? ` && git remote add origin ${project.gitRepo}` : ''}`);
@@ -748,19 +1101,21 @@ async function siteProcess(commandRun, project, port = '3000') {
748
1101
  if (project.extras.includes('launch')) {
749
1102
  let optionPath = `${project.path}/${project.name}`;
750
1103
  let command = `npx @haxtheweb/haxcms-nodejs`;
751
- p.note(`${(0, _statements.merlinSays)(`I have summoned a sub-process daemon 👹`)}
1104
+ if (!commandRun.options.quiet) {
1105
+ p.note(`${(0, _statements.merlinSays)(`I have summoned a sub-process daemon 👹`)}
752
1106
 
753
- 🚀 Running your ${_picocolors.default.bold(project.type)} ${_picocolors.default.bold(project.name)}:
754
- ${_picocolors.default.underline(_picocolors.default.cyan(`http://localhost:${port}`))}
1107
+ 🚀 Running your ${_picocolors.default.bold(project.type)} ${_picocolors.default.bold(project.name)}:
1108
+ ${_picocolors.default.underline(_picocolors.default.cyan(`http://localhost:${port}`))}
755
1109
 
756
- 🏠 Launched: ${_picocolors.default.underline(_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${optionPath}`))))}
757
- 💻 Folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`cd ${optionPath}`)))}
758
- 📂 Open folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`open ${optionPath}`)))}
759
- 📘 VS Code Project: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`code ${optionPath}`)))}
760
- 🚧 Launch later: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${command}`)))}
1110
+ 🏠 Launched: ${_picocolors.default.underline(_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${optionPath}`))))}
1111
+ 💻 Folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`cd ${optionPath}`)))}
1112
+ 📂 Open folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`open ${optionPath}`)))}
1113
+ 📘 VS Code Project: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`code ${optionPath}`)))}
1114
+ 🚧 Launch later: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${command}`)))}
761
1115
 
762
- ⌨️ To resume 🧙 Merlin press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}
763
- `);
1116
+ ⌨️ To resume 🧙 Merlin press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}
1117
+ `);
1118
+ }
764
1119
  // at least a second to see the message print at all
765
1120
  await (0, _promises.setTimeout)(1000);
766
1121
  try {
@@ -768,24 +1123,25 @@ async function siteProcess(commandRun, project, port = '3000') {
768
1123
  } catch (e) {
769
1124
  // don't log bc output is weird
770
1125
  }
771
- } else {
1126
+ } else if (!commandRun.options.quiet) {
772
1127
  let nextSteps = `cd ${project.path}/${project.name} && hax start`;
773
1128
  p.note(`${project.name} is ready to go. Run the following to start working with it:`);
774
1129
  p.outro(nextSteps);
775
1130
  }
776
1131
  }
777
1132
  async function siteItemsOptionsList(activeHaxsite, skipId = null) {
778
- let items = [];
779
- for (var i in activeHaxsite.manifest.items) {
1133
+ let items = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
1134
+ let optionItems = [];
1135
+ for (var i in items) {
780
1136
  // ensure we remove self if operation is about page in question like parent selector
781
- if (activeHaxsite.manifest.items[i].id !== skipId) {
782
- items.push({
783
- value: activeHaxsite.manifest.items[i].id,
784
- label: activeHaxsite.manifest.items[i].title
1137
+ if (items[i].id !== skipId) {
1138
+ optionItems.push({
1139
+ value: items[i].id,
1140
+ label: ` ${'-'.repeat(parseInt(items[i].indent))}${items[i].title}`
785
1141
  });
786
1142
  }
787
1143
  }
788
- return items;
1144
+ return optionItems;
789
1145
  }
790
1146
  async function siteThemeList() {
791
1147
  let themes = await HAXCMS.getThemes();
@@ -175,6 +175,14 @@ async function webcomponentProcess(commandRun, project, port = "8000") {
175
175
  s.start((0, _statements.merlinSays)('Copying project files'));
176
176
  // leverage this little helper from HAXcms
177
177
  await HAXCMS.recurseCopy(`${process.mainModule.path}/templates/${project.type}/hax/`, `${project.path}/${project.name}`);
178
+ // rename gitignore to improve copy cross platform compat
179
+ await fs.renameSync(`${project.path}/${project.name}/_github`, `${project.path}/${project.name}/.github`);
180
+ await fs.renameSync(`${project.path}/${project.name}/_editorconfig`, `${project.path}/${project.name}/.editorconfig`);
181
+ await fs.renameSync(`${project.path}/${project.name}/_gitignore`, `${project.path}/${project.name}/.gitignore`);
182
+ await fs.renameSync(`${project.path}/${project.name}/_nojekyll`, `${project.path}/${project.name}/.nojekyll`);
183
+ await fs.renameSync(`${project.path}/${project.name}/_npmignore`, `${project.path}/${project.name}/.npmignore`);
184
+ await fs.renameSync(`${project.path}/${project.name}/_surgeignore`, `${project.path}/${project.name}/.surgeignore`);
185
+ await fs.renameSync(`${project.path}/${project.name}/_travis.yml`, `${project.path}/${project.name}/.travis.yml`);
178
186
  // rename paths that are of the element name in question
179
187
  await fs.renameSync(`${project.path}/${project.name}/lib/webcomponent.haxProperties.json`, `${project.path}/${project.name}/lib/${project.name}.haxProperties.json`);
180
188
  // loop through and rename all the localization files
@@ -250,7 +258,7 @@ ${_picocolors.default.underline(_picocolors.default.cyan(`http://localhost:${por
250
258
  } catch (e) {
251
259
  // don't log bc output is weird
252
260
  }
253
- } else {
261
+ } else if (!commandRun.options.quiet) {
254
262
  let nextSteps = `cd ${project.path}/${project.name} && ${project.extras.includes('install') ? '' : `${commandRun.options.npmClient} install && `}${commandRun.options.npmClient} start`;
255
263
  p.note(`${project.name} is ready to go. Run the following to start development:`);
256
264
  p.outro(nextSteps);
@@ -259,33 +267,41 @@ ${_picocolors.default.underline(_picocolors.default.cyan(`http://localhost:${por
259
267
 
260
268
  // autodetect webcomponent
261
269
  async function webcomponentCommandDetected(commandRun, packageData = {}, port = "8000") {
262
- p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Webcomponent detected `))}`);
263
- p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Web component name: ${packageData.name} `))}`);
270
+ if (!commandRun.options.quiet) {
271
+ p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Webcomponent detected `))}`);
272
+ p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Web component name: ${packageData.name} `))}`);
273
+ }
264
274
  // if we support customElement analyzer (hax wcs do) then generate if asked
265
275
  if (commandRun.options.writeHaxProperties && packageData.customElements) {
266
276
  webcomponentGenerateHAXSchema(commandRun, packageData);
267
277
  } else {
268
- p.note(`${(0, _statements.merlinSays)(`I have summoned a sub-process daemon 👹`)}
269
-
270
- 🚀 Running your ${_picocolors.default.bold('webcomponent')} ${_picocolors.default.bold(packageData.name)}:
271
- ${_picocolors.default.underline(_picocolors.default.cyan(`http://localhost:${port}`))}
272
-
273
- 🏠 Launched: ${_picocolors.default.underline(_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${process.cwd()}`))))}
274
- 💻 Folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`cd ${process.cwd()}`)))}
275
- 📂 Open folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`open ${process.cwd()}`)))}
276
- 📘 VS Code Project: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`code ${process.cwd()}`)))}
277
- 🚧 Launch later: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${commandRun.options.npmClient} start`)))}
278
-
279
- ⌨️ To exit 🧙 Merlin press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}
280
- `);
278
+ if (!commandRun.options.quiet) {
279
+ p.note(`${(0, _statements.merlinSays)(`I have summoned a sub-process daemon 👹`)}
280
+
281
+ 🚀 Running your ${_picocolors.default.bold('webcomponent')} ${_picocolors.default.bold(packageData.name)}:
282
+ ${_picocolors.default.underline(_picocolors.default.cyan(`http://localhost:${port}`))}
283
+
284
+ 🏠 Launched: ${_picocolors.default.underline(_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${process.cwd()}`))))}
285
+ 💻 Folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`cd ${process.cwd()}`)))}
286
+ 📂 Open folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`open ${process.cwd()}`)))}
287
+ 📘 VS Code Project: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`code ${process.cwd()}`)))}
288
+ 🚧 Launch later: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${commandRun.options.npmClient} start`)))}
289
+
290
+ ⌨️ To exit 🧙 Merlin press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}
291
+ `);
292
+ }
281
293
  try {
282
294
  // ensure it's installed first, unless it's a monorepo. basic check for node_modules
283
295
  // folder as far as if already installed so we don't double install needlessly
284
296
  if (!commandRun.options.isMonorepo && !fs.existsSync("./node_modules")) {
285
- let s = p.spinner();
286
- s.start((0, _statements.merlinSays)(`Installation magic (${commandRun.options.npmClient} install)`));
287
- await exec(`${commandRun.options.npmClient} install`);
288
- s.stop((0, _statements.merlinSays)(`Everything is installed. It's go time`));
297
+ if (!commandRun.options.quiet) {
298
+ let s = p.spinner();
299
+ s.start((0, _statements.merlinSays)(`Installation magic (${commandRun.options.npmClient} install)`));
300
+ await exec(`${commandRun.options.npmClient} install`);
301
+ s.stop((0, _statements.merlinSays)(`Everything is installed. It's go time`));
302
+ } else {
303
+ await exec(`${commandRun.options.npmClient} install`);
304
+ }
289
305
  }
290
306
  await exec(`${commandRun.options.npmClient} start`);
291
307
  } catch (e) {
@@ -310,7 +326,7 @@ async function webcomponentGenerateHAXSchema(commandRun, packageData) {
310
326
  });
311
327
  let wiring = new HAXWiring();
312
328
  if (commandRun.options.debug) {
313
- console.log(ceFileData);
329
+ (0, _statements.log)(ceFileData);
314
330
  }
315
331
  if (ceFileData) {
316
332
  let ce = JSON.parse(ceFileData);
@@ -366,10 +382,10 @@ async function webcomponentGenerateHAXSchema(commandRun, packageData) {
366
382
  }
367
383
  });
368
384
  if (commandRun.options.v) {
369
- console.log(JSON.stringify(props, null, 2));
385
+ (0, _statements.log)(JSON.stringify(props, null, 2));
370
386
  }
371
387
  fs.writeFileSync(`./lib/${declarations.tagName}.haxProperties.json`, JSON.stringify(props, null, 2));
372
- console.log(`schema written to: ./lib/${declarations.tagName}.haxProperties.json`);
388
+ (0, _statements.log)(`schema written to: ./lib/${declarations.tagName}.haxProperties.json`);
373
389
  });
374
390
  });
375
391
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.communityStatement = communityStatement;
7
7
  exports.haxIntro = haxIntro;
8
+ exports.log = log;
8
9
  exports.merlinSays = merlinSays;
9
10
  var _art = require("./art.js");
10
11
  var p = _interopRequireWildcard(require("@clack/prompts"));
@@ -13,6 +14,12 @@ var _promises = require("node:timers/promises");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ // wrapper so we can silence all log messages at the same time
18
+ function log(msg, level = 'log') {
19
+ if (!process.haxquiet) {
20
+ console[level](msg);
21
+ }
22
+ }
16
23
  async function haxIntro() {
17
24
  console.clear();
18
25
  await (0, _promises.setTimeout)(10);
@@ -0,0 +1,26 @@
1
+ ## editors
2
+ /.idea
3
+ /.vscode
4
+
5
+ ## system files
6
+ .DS_Store
7
+
8
+ ## npm
9
+ /node_modules/
10
+ /npm-debug.log
11
+
12
+ ## testing
13
+ /coverage/
14
+
15
+ ## temp folders
16
+ /.tmp/
17
+
18
+ # build
19
+ /_site/
20
+ /dist/
21
+ /out-tsc/
22
+ /public/
23
+
24
+ storybook-static
25
+ custom-elements.json
26
+ .vercel
@@ -0,0 +1 @@
1
+ node_modules
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haxtheweb/create",
3
- "version": "9.0.14",
3
+ "version": "9.0.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,7 +24,7 @@
24
24
  "release": "npm run build && commit-and-tag-version && git push --follow-tags origin main && npm publish",
25
25
  "hax": "hax",
26
26
  "dev": "nodemon --watch src",
27
- "haxcms-nodejs-cli": "haxcms-nodejs-cli"
27
+ "haxcms-nodejs": "haxcms-nodejs"
28
28
  },
29
29
  "bin": {
30
30
  "create-haxtheweb": "./dist/create.js",
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "@clack/core": "0.3.4",
44
44
  "@clack/prompts": "0.7.0",
45
- "@haxtheweb/haxcms-nodejs": "^9.0.18",
46
- "@haxtheweb/open-apis": "^9.0.11",
45
+ "@haxtheweb/haxcms-nodejs": "^9.0.20",
46
+ "@haxtheweb/open-apis": "^9.0.12",
47
47
  "commander": "12.1.0",
48
48
  "node-html-parser": "6.1.13",
49
49
  "ejs": "3.1.10",