@haxtheweb/create 9.0.12 → 9.0.14
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 +7 -5
- package/dist/lib/programs/site.js +263 -54
- package/package.json +2 -2
package/dist/create.js
CHANGED
|
@@ -28,7 +28,7 @@ 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')
|
|
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')
|
|
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')
|
|
@@ -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').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').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');
|
|
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');
|
|
84
84
|
// process program arguments
|
|
85
85
|
_commander.program.parse();
|
|
86
86
|
commandRun.options = {
|
|
@@ -198,7 +198,7 @@ async function main() {
|
|
|
198
198
|
project = {
|
|
199
199
|
type: commandRun.command
|
|
200
200
|
};
|
|
201
|
-
} else {
|
|
201
|
+
} else if (commandRun.options.i) {
|
|
202
202
|
project = await p.group({
|
|
203
203
|
type: ({
|
|
204
204
|
results
|
|
@@ -224,6 +224,8 @@ async function main() {
|
|
|
224
224
|
process.exit(0);
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
|
+
} else if (!commandRun.options.i) {
|
|
228
|
+
process.exit(0);
|
|
227
229
|
}
|
|
228
230
|
// detect being in a haxcms scaffold. easiest way is _sites being in this directory
|
|
229
231
|
// set the path automatically so we skip the question
|
|
@@ -334,7 +336,7 @@ async function main() {
|
|
|
334
336
|
extras: ({
|
|
335
337
|
results
|
|
336
338
|
}) => {
|
|
337
|
-
if (!commandRun.options.auto) {
|
|
339
|
+
if (!commandRun.options.auto && commandRun.options.i) {
|
|
338
340
|
let options = [];
|
|
339
341
|
let initialValues = [];
|
|
340
342
|
if (commandRun.command === "webcomponent" || results.type === "webcomponent") {
|
|
@@ -17,6 +17,7 @@ var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
|
17
17
|
var _jsYaml = require("js-yaml");
|
|
18
18
|
var _nodeHtmlParser = require("node-html-parser");
|
|
19
19
|
var _statements = require("../statements.js");
|
|
20
|
+
var _utils = require("../utils.js");
|
|
20
21
|
var _microFrontendRegistry = require("../micro-frontend-registry.js");
|
|
21
22
|
var haxcmsNodejsCli = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs/dist/cli.js"));
|
|
22
23
|
var hax = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs"));
|
|
@@ -30,7 +31,7 @@ globalThis.MicroFrontendRegistryConfig = {
|
|
|
30
31
|
base: `@haxtheweb/open-apis/`
|
|
31
32
|
};
|
|
32
33
|
// emable HAXcms routes so we have name => path just like on frontend!
|
|
33
|
-
_microFrontendRegistry.MicroFrontendRegistry.enableServices(['haxcms']);
|
|
34
|
+
_microFrontendRegistry.MicroFrontendRegistry.enableServices(['core', 'haxcms', 'experimental']);
|
|
34
35
|
const HAXCMS = hax.HAXCMS;
|
|
35
36
|
const exec = util.promisify(child_process.exec);
|
|
36
37
|
var sysSurge = true;
|
|
@@ -56,6 +57,10 @@ class Res {
|
|
|
56
57
|
this.statusCode = status;
|
|
57
58
|
return this;
|
|
58
59
|
}
|
|
60
|
+
json(data) {
|
|
61
|
+
this.data = JSON.parse(JSON.stringify(data));
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
59
64
|
setHeader() {
|
|
60
65
|
return this;
|
|
61
66
|
}
|
|
@@ -63,31 +68,43 @@ class Res {
|
|
|
63
68
|
function siteActions() {
|
|
64
69
|
return [{
|
|
65
70
|
value: 'start',
|
|
66
|
-
label: "
|
|
67
|
-
}, {
|
|
68
|
-
value: 'status',
|
|
69
|
-
label: "Status"
|
|
70
|
-
}, {
|
|
71
|
-
value: 'sync',
|
|
72
|
-
label: "Sync git"
|
|
73
|
-
}, {
|
|
74
|
-
value: 'theme',
|
|
75
|
-
label: "Change theme"
|
|
71
|
+
label: "Launch site in browser (http://localhost)"
|
|
76
72
|
}, {
|
|
77
73
|
value: 'node:stats',
|
|
78
|
-
label: "
|
|
74
|
+
label: "Node Stats / data"
|
|
79
75
|
}, {
|
|
80
76
|
value: 'node:add',
|
|
81
|
-
label: "Add page"
|
|
77
|
+
label: "Add a new page"
|
|
82
78
|
}, {
|
|
83
79
|
value: 'node:edit',
|
|
84
|
-
label: "Edit page"
|
|
80
|
+
label: "Edit a page"
|
|
85
81
|
}, {
|
|
86
82
|
value: 'node:delete',
|
|
87
|
-
label: "Delete page"
|
|
83
|
+
label: "Delete a page"
|
|
84
|
+
}, {
|
|
85
|
+
value: 'site:stats',
|
|
86
|
+
label: "Site Status / stats"
|
|
87
|
+
}, {
|
|
88
|
+
value: 'site:items',
|
|
89
|
+
label: "Site items"
|
|
88
90
|
}, {
|
|
89
|
-
value: '
|
|
90
|
-
label: "List files"
|
|
91
|
+
value: 'site:list-files',
|
|
92
|
+
label: "List site files"
|
|
93
|
+
}, {
|
|
94
|
+
value: 'site:theme',
|
|
95
|
+
label: "Change theme"
|
|
96
|
+
}, {
|
|
97
|
+
value: 'site:html',
|
|
98
|
+
label: "Full site as HTML"
|
|
99
|
+
}, {
|
|
100
|
+
value: 'site:md',
|
|
101
|
+
label: "Full site as Markdown"
|
|
102
|
+
}, {
|
|
103
|
+
value: 'site:schema',
|
|
104
|
+
label: "Full site as HAXElementSchema"
|
|
105
|
+
}, {
|
|
106
|
+
value: 'site:sync',
|
|
107
|
+
label: "Sync git repo"
|
|
91
108
|
}];
|
|
92
109
|
}
|
|
93
110
|
async function siteCommandDetected(commandRun) {
|
|
@@ -96,9 +113,11 @@ async function siteCommandDetected(commandRun) {
|
|
|
96
113
|
if (!commandRun.arguments.action) {
|
|
97
114
|
commandRun.arguments.action = 'status';
|
|
98
115
|
}
|
|
99
|
-
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Site detected `))}`);
|
|
100
116
|
commandRun.command = "site";
|
|
101
|
-
|
|
117
|
+
if (!commandRun.options.y && commandRun.options.i) {
|
|
118
|
+
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Site detected `))}`);
|
|
119
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Name: ${activeHaxsite.name} `))}`);
|
|
120
|
+
}
|
|
102
121
|
// defaults if nothing set via CLI
|
|
103
122
|
let operation = {
|
|
104
123
|
...commandRun.arguments,
|
|
@@ -115,8 +134,8 @@ async function siteCommandDetected(commandRun) {
|
|
|
115
134
|
let actions = siteActions();
|
|
116
135
|
if (sysSurge) {
|
|
117
136
|
actions.push({
|
|
118
|
-
value: 'surge',
|
|
119
|
-
label: "Publish site
|
|
137
|
+
value: 'site:surge',
|
|
138
|
+
label: "Publish site to Surge.sh"
|
|
120
139
|
});
|
|
121
140
|
}
|
|
122
141
|
actions.push({
|
|
@@ -147,13 +166,58 @@ async function siteCommandDetected(commandRun) {
|
|
|
147
166
|
});
|
|
148
167
|
}
|
|
149
168
|
switch (operation.action) {
|
|
150
|
-
case "
|
|
151
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Title: ${activeHaxsite.manifest.title} `))}`);
|
|
152
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Description: ${activeHaxsite.manifest.description} `))}`);
|
|
153
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Theme: ${activeHaxsite.manifest.metadata.theme.name} (${activeHaxsite.manifest.metadata.theme.element})`))}`);
|
|
154
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Pages: ${activeHaxsite.manifest.items.length} `))}`);
|
|
169
|
+
case "site:stats":
|
|
155
170
|
const date = new Date(activeHaxsite.manifest.metadata.site.updated * 1000);
|
|
156
|
-
|
|
171
|
+
let siteItems = [];
|
|
172
|
+
if (commandRun.options.itemId != null) {
|
|
173
|
+
siteItems = activeHaxsite.manifest.findBranch(commandRun.options.itemId);
|
|
174
|
+
} else {
|
|
175
|
+
siteItems = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
|
|
176
|
+
}
|
|
177
|
+
let els = {};
|
|
178
|
+
for (var i in siteItems) {
|
|
179
|
+
let page = activeHaxsite.loadNode(siteItems[i].id);
|
|
180
|
+
let html = await activeHaxsite.getPageContent(page);
|
|
181
|
+
let dom = (0, _nodeHtmlParser.parse)(`<div id="fullpage">${html}</div>`);
|
|
182
|
+
for (var j in dom.querySelector('#fullpage').childNodes) {
|
|
183
|
+
let node = dom.querySelector('#fullpage').childNodes[j];
|
|
184
|
+
if (node && node.getAttribute) {
|
|
185
|
+
let haxel = await nodeToHaxElement(node, null);
|
|
186
|
+
if (!els[haxel.tag]) {
|
|
187
|
+
els[haxel.tag] = 0;
|
|
188
|
+
}
|
|
189
|
+
els[haxel.tag]++;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
let siteStats = {
|
|
194
|
+
title: activeHaxsite.manifest.title,
|
|
195
|
+
description: activeHaxsite.manifest.description,
|
|
196
|
+
themeName: activeHaxsite.manifest.metadata.theme.name,
|
|
197
|
+
themeElement: activeHaxsite.manifest.metadata.theme.element,
|
|
198
|
+
pageCount: activeHaxsite.manifest.items.length,
|
|
199
|
+
lastUpdated: date.toLocaleDateString("en-US"),
|
|
200
|
+
tagUsage: els
|
|
201
|
+
};
|
|
202
|
+
if (!commandRun.options.format) {
|
|
203
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Title: ${siteStats.title} `))}`);
|
|
204
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Description: ${siteStats.description} `))}`);
|
|
205
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Theme: ${siteStats.themeName} (${siteStats.themeElement})`))}`);
|
|
206
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Pages: ${siteStats.pageCount} `))}`);
|
|
207
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Last updated: ${siteStats.lastUpdated} `))}`);
|
|
208
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Tags used: ${JSON.stringify(siteStats.tagUsage, null, 2)} `))}`);
|
|
209
|
+
} else if (commandRun.options.format === 'yaml') {
|
|
210
|
+
console.log((0, _jsYaml.dump)(siteStats));
|
|
211
|
+
} else {
|
|
212
|
+
console.log(siteStats);
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case "site:items":
|
|
216
|
+
if (commandRun.options.format === 'yaml') {
|
|
217
|
+
console.log((0, _jsYaml.dump)(activeHaxsite.manifest.items));
|
|
218
|
+
} else {
|
|
219
|
+
console.log(activeHaxsite.manifest.items);
|
|
220
|
+
}
|
|
157
221
|
break;
|
|
158
222
|
case "start":
|
|
159
223
|
try {
|
|
@@ -201,17 +265,28 @@ async function siteCommandDetected(commandRun) {
|
|
|
201
265
|
case 'schema':
|
|
202
266
|
// next up
|
|
203
267
|
let html = await activeHaxsite.getPageContent(page);
|
|
204
|
-
let dom = (0, _nodeHtmlParser.parse)(html);
|
|
205
|
-
|
|
268
|
+
let dom = (0, _nodeHtmlParser.parse)(`<div id="fullpage">${html}</div>`);
|
|
269
|
+
let els = [];
|
|
270
|
+
for (var i in dom.querySelector('#fullpage').childNodes) {
|
|
271
|
+
let node = dom.querySelector('#fullpage').childNodes[i];
|
|
272
|
+
if (node && node.getAttribute) {
|
|
273
|
+
els.push(await nodeToHaxElement(node, null));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
console.log(els);
|
|
206
277
|
break;
|
|
207
278
|
case 'md':
|
|
208
|
-
|
|
279
|
+
let resp = await openApiBroker('@core', 'htmlToMd', {
|
|
280
|
+
html: await activeHaxsite.getPageContent(page)
|
|
281
|
+
});
|
|
282
|
+
console.log(resp.res.data.data);
|
|
209
283
|
break;
|
|
210
284
|
}
|
|
211
285
|
}
|
|
212
286
|
}
|
|
213
287
|
} catch (e) {
|
|
214
288
|
console.log(e.stderr);
|
|
289
|
+
console.log(e);
|
|
215
290
|
}
|
|
216
291
|
break;
|
|
217
292
|
case "node:add":
|
|
@@ -390,7 +465,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
390
465
|
console.log(e.stderr);
|
|
391
466
|
}
|
|
392
467
|
break;
|
|
393
|
-
case "sync":
|
|
468
|
+
case "site:sync":
|
|
394
469
|
// @todo git sync might need other arguments / be combined with publishing
|
|
395
470
|
try {
|
|
396
471
|
await exec(`cd ${activeHaxsite.directory} && git pull && git push`);
|
|
@@ -398,7 +473,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
398
473
|
console.log(e.stderr);
|
|
399
474
|
}
|
|
400
475
|
break;
|
|
401
|
-
case "theme":
|
|
476
|
+
case "site:theme":
|
|
402
477
|
try {
|
|
403
478
|
//theme
|
|
404
479
|
let list = await siteThemeList();
|
|
@@ -421,7 +496,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
421
496
|
console.log(e.stderr);
|
|
422
497
|
}
|
|
423
498
|
break;
|
|
424
|
-
case "surge":
|
|
499
|
+
case "site:surge":
|
|
425
500
|
try {
|
|
426
501
|
if (!commandRun.options.domain) {
|
|
427
502
|
commandRun.options.domain = await p.text({
|
|
@@ -441,7 +516,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
441
516
|
console.log(e.stderr);
|
|
442
517
|
}
|
|
443
518
|
break;
|
|
444
|
-
case "file
|
|
519
|
+
case "site:file-list":
|
|
445
520
|
let res = new Res();
|
|
446
521
|
await hax.RoutesMap.get.listFiles({
|
|
447
522
|
query: activeHaxsite.name,
|
|
@@ -453,6 +528,54 @@ async function siteCommandDetected(commandRun) {
|
|
|
453
528
|
console.log(res.data);
|
|
454
529
|
}
|
|
455
530
|
break;
|
|
531
|
+
case "site:html":
|
|
532
|
+
case "site:md":
|
|
533
|
+
case "site:schema":
|
|
534
|
+
let siteContent = '';
|
|
535
|
+
activeHaxsite = await hax.systemStructureContext();
|
|
536
|
+
let items = [];
|
|
537
|
+
if (commandRun.options.itemId != null) {
|
|
538
|
+
items = activeHaxsite.manifest.findBranch(commandRun.options.itemId);
|
|
539
|
+
} else {
|
|
540
|
+
items = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
|
|
541
|
+
}
|
|
542
|
+
if (operation.action === 'site:schema') {
|
|
543
|
+
let els = [];
|
|
544
|
+
for (var i in items) {
|
|
545
|
+
let page = activeHaxsite.loadNode(items[i].id);
|
|
546
|
+
let html = await activeHaxsite.getPageContent(page);
|
|
547
|
+
let dom = (0, _nodeHtmlParser.parse)(`<div id="fullpage">${html}</div>`);
|
|
548
|
+
els.push({
|
|
549
|
+
tag: "h1",
|
|
550
|
+
properties: {
|
|
551
|
+
"data-jos-item-id": items[i].id
|
|
552
|
+
},
|
|
553
|
+
content: `${items[i].title}`
|
|
554
|
+
});
|
|
555
|
+
for (var j in dom.querySelector('#fullpage').childNodes) {
|
|
556
|
+
let node = dom.querySelector('#fullpage').childNodes[j];
|
|
557
|
+
if (node && node.getAttribute) {
|
|
558
|
+
els.push(await nodeToHaxElement(node, null));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
console.log(els);
|
|
563
|
+
} else {
|
|
564
|
+
for (var i in items) {
|
|
565
|
+
let page = activeHaxsite.loadNode(items[i].id);
|
|
566
|
+
siteContent += `<h1>${items[i].title}</h1>\n\r`;
|
|
567
|
+
siteContent += `<div data-jos-item-id="${items[i].id}">\n\r${await activeHaxsite.getPageContent(page)}\n\r</div>\n\r`;
|
|
568
|
+
}
|
|
569
|
+
if (operation.action === 'site:md') {
|
|
570
|
+
let resp = await openApiBroker('@core', 'htmlToMd', {
|
|
571
|
+
html: siteContent
|
|
572
|
+
});
|
|
573
|
+
console.log(resp.res.data.data);
|
|
574
|
+
} else {
|
|
575
|
+
console.log(siteContent);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
break;
|
|
456
579
|
case "quit":
|
|
457
580
|
// quit
|
|
458
581
|
process.exit(0);
|
|
@@ -531,8 +654,8 @@ function siteNodeOperations(search = null) {
|
|
|
531
654
|
|
|
532
655
|
// broker a call to the open-api repo which is an express based wrapper for vercel (originally)
|
|
533
656
|
// this ensures the calls are identical and yet are converted to something the CLI can leverage
|
|
534
|
-
async function openApiBroker(call, body) {
|
|
535
|
-
let mfItem = _microFrontendRegistry.MicroFrontendRegistry.get(
|
|
657
|
+
async function openApiBroker(scope, call, body) {
|
|
658
|
+
let mfItem = _microFrontendRegistry.MicroFrontendRegistry.get(`${scope}/${call}`);
|
|
536
659
|
// ensure we have a MFR record to do the connection
|
|
537
660
|
// fun thing is this is local file access directly via import()
|
|
538
661
|
if (mfItem) {
|
|
@@ -557,8 +680,10 @@ async function openApiBroker(call, body) {
|
|
|
557
680
|
async function siteProcess(commandRun, project, port = '3000') {
|
|
558
681
|
// auto select operations to perform if requested
|
|
559
682
|
if (!project.extras) {
|
|
560
|
-
|
|
561
|
-
|
|
683
|
+
project.extras = [];
|
|
684
|
+
if (commandRun.options.i) {
|
|
685
|
+
project.extras = ['launch'];
|
|
686
|
+
}
|
|
562
687
|
}
|
|
563
688
|
let s = p.spinner();
|
|
564
689
|
s.start((0, _statements.merlinSays)(`Creating new site: ${project.name}`));
|
|
@@ -587,7 +712,7 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
587
712
|
}
|
|
588
713
|
// verify this is a valid way to do an import
|
|
589
714
|
if (commandRun.options.importStructure && _microFrontendRegistry.MicroFrontendRegistry.get(`@haxcms/${commandRun.options.importStructure}`)) {
|
|
590
|
-
let resp = await openApiBroker(commandRun.options.importStructure, {
|
|
715
|
+
let resp = await openApiBroker('@haxcms', commandRun.options.importStructure, {
|
|
591
716
|
repoUrl: commandRun.options.importSite
|
|
592
717
|
});
|
|
593
718
|
if (resp.res.data && resp.res.data.data && resp.res.data.data.items) {
|
|
@@ -620,19 +745,6 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
620
745
|
}
|
|
621
746
|
// options for install, git and other extras
|
|
622
747
|
// can't launch if we didn't install first so launch implies installation
|
|
623
|
-
if (project.extras.includes('launch') || project.extras.includes('install')) {
|
|
624
|
-
s.start((0, _statements.merlinSays)(`Installation magic (${commandRun.options.npmClient} install)`));
|
|
625
|
-
try {
|
|
626
|
-
// monorepos install from top but then still need to launch from local location
|
|
627
|
-
if (!commandRun.options.isMonorepo) {
|
|
628
|
-
await exec(`cd ${project.path}/${project.name} && ${commandRun.options.npmClient} install`);
|
|
629
|
-
}
|
|
630
|
-
} catch (e) {
|
|
631
|
-
console.log(e);
|
|
632
|
-
}
|
|
633
|
-
s.stop((0, _statements.merlinSays)(`Everything is installed. It's go time`));
|
|
634
|
-
}
|
|
635
|
-
// autolaunch if default was selected
|
|
636
748
|
if (project.extras.includes('launch')) {
|
|
637
749
|
let optionPath = `${project.path}/${project.name}`;
|
|
638
750
|
let command = `npx @haxtheweb/haxcms-nodejs`;
|
|
@@ -657,8 +769,8 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
657
769
|
// don't log bc output is weird
|
|
658
770
|
}
|
|
659
771
|
} else {
|
|
660
|
-
let nextSteps = `cd ${project.path}/${project.name} &&
|
|
661
|
-
p.note(`${project.name} is ready to go. Run the following to start
|
|
772
|
+
let nextSteps = `cd ${project.path}/${project.name} && hax start`;
|
|
773
|
+
p.note(`${project.name} is ready to go. Run the following to start working with it:`);
|
|
662
774
|
p.outro(nextSteps);
|
|
663
775
|
}
|
|
664
776
|
}
|
|
@@ -685,4 +797,101 @@ async function siteThemeList() {
|
|
|
685
797
|
});
|
|
686
798
|
}
|
|
687
799
|
return items;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// @fork of the hax core util for this so that we avoid api difference between real dom and parse nodejs dom
|
|
803
|
+
async function nodeToHaxElement(node, eventName = "insert-element") {
|
|
804
|
+
if (!node) {
|
|
805
|
+
return null;
|
|
806
|
+
}
|
|
807
|
+
// build out the properties to send along
|
|
808
|
+
var props = {};
|
|
809
|
+
// support basic styles
|
|
810
|
+
if (typeof node.getAttribute("style") !== typeof undefined) {
|
|
811
|
+
props.style = node.getAttribute("style");
|
|
812
|
+
}
|
|
813
|
+
// don't set a null style
|
|
814
|
+
if (props.style === null || props.style === "null") {
|
|
815
|
+
delete props.style;
|
|
816
|
+
}
|
|
817
|
+
// test if a class exists, not everything scopes
|
|
818
|
+
if (typeof node.getAttribute('class') !== typeof undefined) {
|
|
819
|
+
props.class = node.getAttribute('class').replace("hax-active", "");
|
|
820
|
+
}
|
|
821
|
+
// test if a id exists as its a special case in attributes... of course
|
|
822
|
+
if (typeof node.getAttribute('id') !== typeof undefined) {
|
|
823
|
+
props.id = node.getAttribute("id");
|
|
824
|
+
}
|
|
825
|
+
let tmpProps;
|
|
826
|
+
// weak fallback
|
|
827
|
+
if (typeof tmpProps === typeof undefined) {
|
|
828
|
+
tmpProps = node.__data;
|
|
829
|
+
}
|
|
830
|
+
// complex elements need complex support
|
|
831
|
+
if (typeof tmpProps !== typeof undefined) {
|
|
832
|
+
// run through attributes, though non-reflected props won't be here
|
|
833
|
+
// run through props, we always defer to property values
|
|
834
|
+
for (var property in tmpProps) {
|
|
835
|
+
// make sure we only set things that have a value
|
|
836
|
+
if (property != "class" && property != "style" && tmpProps.hasOwnProperty(property) && typeof node[property] !== undefined && node[property] != null && node[property] != "") {
|
|
837
|
+
props[property] = node[property];
|
|
838
|
+
}
|
|
839
|
+
// special support for false boolean
|
|
840
|
+
else if (node[property] === false) {
|
|
841
|
+
props[property] = false;
|
|
842
|
+
} else if (node[property] === true) {
|
|
843
|
+
props[property] = true;
|
|
844
|
+
} else if (node[property] === 0) {
|
|
845
|
+
props[property] = 0;
|
|
846
|
+
} else {
|
|
847
|
+
// unknown prop setting / ignored
|
|
848
|
+
//console.warn(node[property], property);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
for (var attribute in node._attrs) {
|
|
852
|
+
// make sure we only set things that have a value
|
|
853
|
+
if (typeof node._attrs[attribute] !== typeof undefined && attribute != "class" && attribute != "style" && attribute != "id" && typeof node._attrs[attribute] !== undefined && node._attrs[attribute] != null && node._attrs[attribute] != "") {
|
|
854
|
+
props[attribute] = node._attrs[attribute];
|
|
855
|
+
} else if (node._attrs[attribute] == "0") {
|
|
856
|
+
props[attribute] = node._attrs[attribute];
|
|
857
|
+
} else {
|
|
858
|
+
// note: debug here if experiencing attributes that won't bind
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
} else {
|
|
862
|
+
// much easier case, usually just in primatives
|
|
863
|
+
for (var attribute in node._attrs) {
|
|
864
|
+
// make sure we only set things that have a value
|
|
865
|
+
if (typeof node._attrs[attribute] !== typeof undefined && attribute != "class" && attribute != "style" && attribute != "id" && typeof node._attrs[attribute] !== undefined && node._attrs[attribute] != null && node._attrs[attribute] != "") {
|
|
866
|
+
props[attribute] = node._attrs[attribute];
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
// support sandboxed environments which
|
|
871
|
+
// will hate iframe tags but love webview
|
|
872
|
+
let tag = node.tagName.toLowerCase();
|
|
873
|
+
if (globalThis.HaxStore && globalThis.HaxStore.instance && globalThis.HaxStore.instance._isSandboxed && tag === "iframe") {
|
|
874
|
+
tag = "webview";
|
|
875
|
+
}
|
|
876
|
+
let slotContent = '';
|
|
877
|
+
// if hax store around, allow it to get slot content of the node
|
|
878
|
+
if (globalThis.HaxStore && globalThis.HaxStore.instance) {
|
|
879
|
+
slotContent = await globalThis.HaxStore.instance.getHAXSlot(node);
|
|
880
|
+
} else {
|
|
881
|
+
// if HAX isn't around, just return the innerHTML as a string for asignment to content
|
|
882
|
+
slotContent = node.innerHTML;
|
|
883
|
+
}
|
|
884
|
+
// support fallback on inner text if there were no nodes
|
|
885
|
+
if (slotContent == "") {
|
|
886
|
+
slotContent = node.innerText;
|
|
887
|
+
}
|
|
888
|
+
let element = {
|
|
889
|
+
tag: tag,
|
|
890
|
+
properties: props,
|
|
891
|
+
content: slotContent
|
|
892
|
+
};
|
|
893
|
+
if (eventName !== null) {
|
|
894
|
+
element.eventName = eventName;
|
|
895
|
+
}
|
|
896
|
+
return element;
|
|
688
897
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haxtheweb/create",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.14",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@clack/core": "0.3.4",
|
|
44
44
|
"@clack/prompts": "0.7.0",
|
|
45
|
-
"@haxtheweb/haxcms-nodejs": "^9.0.
|
|
45
|
+
"@haxtheweb/haxcms-nodejs": "^9.0.18",
|
|
46
46
|
"@haxtheweb/open-apis": "^9.0.11",
|
|
47
47
|
"commander": "12.1.0",
|
|
48
48
|
"node-html-parser": "6.1.13",
|