@haxtheweb/create 9.0.13 → 9.0.15
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 +37 -19
- package/dist/lib/programs/site.js +338 -107
- package/dist/lib/programs/webcomponent.js +39 -23
- package/dist/lib/statements.js +7 -0
- package/dist/templates/webcomponent/hax/_gitignore +26 -0
- package/dist/templates/webcomponent/hax/_npmignore +1 -0
- package/package.json +2 -2
- /package/dist/templates/webcomponent/hax/{.editorconfig → _editorconfig} +0 -0
- /package/dist/templates/webcomponent/hax/{.github → _github}/workflows/main.yml +0 -0
- /package/dist/templates/webcomponent/hax/{.nojekyll → _nojekyll} +0 -0
- /package/dist/templates/webcomponent/hax/{.surgeignore → _surgeignore} +0 -0
- /package/dist/templates/webcomponent/hax/{.travis.yml → _travis.yml} +0 -0
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('--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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
(
|
|
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
|
-
|
|
223
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -376,8 +390,10 @@ async function main() {
|
|
|
376
390
|
}
|
|
377
391
|
}, {
|
|
378
392
|
onCancel: () => {
|
|
379
|
-
|
|
380
|
-
|
|
393
|
+
if (!commandRun.options.quiet) {
|
|
394
|
+
p.cancel('🧙🪄 Merlin: Canceling CLI.. HAX ya later');
|
|
395
|
+
(0, _statements.communityStatement)();
|
|
396
|
+
}
|
|
381
397
|
process.exit(0);
|
|
382
398
|
}
|
|
383
399
|
});
|
|
@@ -418,7 +434,9 @@ async function main() {
|
|
|
418
434
|
}
|
|
419
435
|
}
|
|
420
436
|
}
|
|
421
|
-
(
|
|
437
|
+
if (!commandRun.options.quiet) {
|
|
438
|
+
(0, _statements.communityStatement)();
|
|
439
|
+
}
|
|
422
440
|
}
|
|
423
441
|
}
|
|
424
442
|
main().catch(console.error);
|
|
@@ -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 }; }
|
|
@@ -32,6 +33,7 @@ globalThis.MicroFrontendRegistryConfig = {
|
|
|
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;
|
|
@@ -68,37 +70,46 @@ class Res {
|
|
|
68
70
|
function siteActions() {
|
|
69
71
|
return [{
|
|
70
72
|
value: 'start',
|
|
71
|
-
label: "Launch site (http://localhost)"
|
|
73
|
+
label: "Launch site in browser (http://localhost)"
|
|
72
74
|
}, {
|
|
73
75
|
value: 'node:stats',
|
|
74
|
-
label: "Node
|
|
76
|
+
label: "Node Stats / data"
|
|
75
77
|
}, {
|
|
76
78
|
value: 'node:add',
|
|
77
|
-
label: "
|
|
79
|
+
label: "Add a new page"
|
|
78
80
|
}, {
|
|
79
81
|
value: 'node:edit',
|
|
80
|
-
label: "
|
|
82
|
+
label: "Edit a page"
|
|
81
83
|
}, {
|
|
82
84
|
value: 'node:delete',
|
|
83
|
-
label: "
|
|
85
|
+
label: "Delete a page"
|
|
84
86
|
}, {
|
|
85
|
-
value: '
|
|
86
|
-
label: "Site
|
|
87
|
+
value: 'site:stats',
|
|
88
|
+
label: "Site Status / stats"
|
|
87
89
|
}, {
|
|
88
|
-
value: '
|
|
89
|
-
label: "Site
|
|
90
|
+
value: 'site:items',
|
|
91
|
+
label: "Site items"
|
|
92
|
+
}, {
|
|
93
|
+
value: 'site:items-import',
|
|
94
|
+
label: "Import items (JOS / site.json)"
|
|
95
|
+
}, {
|
|
96
|
+
value: 'site:list-files',
|
|
97
|
+
label: "List site files"
|
|
90
98
|
}, {
|
|
91
|
-
value: '
|
|
92
|
-
label: "
|
|
99
|
+
value: 'site:theme',
|
|
100
|
+
label: "Change theme"
|
|
93
101
|
}, {
|
|
94
102
|
value: 'site:html',
|
|
95
|
-
label: "
|
|
103
|
+
label: "Full site as HTML"
|
|
96
104
|
}, {
|
|
97
105
|
value: 'site:md',
|
|
98
|
-
label: "
|
|
106
|
+
label: "Full site as Markdown"
|
|
99
107
|
}, {
|
|
100
|
-
value: '
|
|
101
|
-
label: "
|
|
108
|
+
value: 'site:schema',
|
|
109
|
+
label: "Full site as HAXElementSchema"
|
|
110
|
+
}, {
|
|
111
|
+
value: 'site:sync',
|
|
112
|
+
label: "Sync git repo"
|
|
102
113
|
}];
|
|
103
114
|
}
|
|
104
115
|
async function siteCommandDetected(commandRun) {
|
|
@@ -107,9 +118,11 @@ async function siteCommandDetected(commandRun) {
|
|
|
107
118
|
if (!commandRun.arguments.action) {
|
|
108
119
|
commandRun.arguments.action = 'status';
|
|
109
120
|
}
|
|
110
|
-
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Site detected `))}`);
|
|
111
121
|
commandRun.command = "site";
|
|
112
|
-
|
|
122
|
+
if (!commandRun.options.y && commandRun.options.i && !commandRun.options.quiet) {
|
|
123
|
+
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Site detected `))}`);
|
|
124
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Name: ${activeHaxsite.name} `))}`);
|
|
125
|
+
}
|
|
113
126
|
// defaults if nothing set via CLI
|
|
114
127
|
let operation = {
|
|
115
128
|
...commandRun.arguments,
|
|
@@ -126,8 +139,8 @@ async function siteCommandDetected(commandRun) {
|
|
|
126
139
|
let actions = siteActions();
|
|
127
140
|
if (sysSurge) {
|
|
128
141
|
actions.push({
|
|
129
|
-
value: 'surge',
|
|
130
|
-
label: "Publish site
|
|
142
|
+
value: 'site:surge',
|
|
143
|
+
label: "Publish site to Surge.sh"
|
|
131
144
|
});
|
|
132
145
|
}
|
|
133
146
|
actions.push({
|
|
@@ -151,28 +164,173 @@ async function siteCommandDetected(commandRun) {
|
|
|
151
164
|
})
|
|
152
165
|
}, {
|
|
153
166
|
onCancel: () => {
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
if (!commandRun.options.quiet) {
|
|
168
|
+
p.cancel('🧙 Merlin: Canceling CLI.. HAX ya later 🪄');
|
|
169
|
+
(0, _statements.communityStatement)();
|
|
170
|
+
}
|
|
156
171
|
process.exit(0);
|
|
157
172
|
}
|
|
158
173
|
});
|
|
159
174
|
}
|
|
160
175
|
switch (operation.action) {
|
|
161
|
-
case "
|
|
162
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Title: ${activeHaxsite.manifest.title} `))}`);
|
|
163
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Description: ${activeHaxsite.manifest.description} `))}`);
|
|
164
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Theme: ${activeHaxsite.manifest.metadata.theme.name} (${activeHaxsite.manifest.metadata.theme.element})`))}`);
|
|
165
|
-
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Pages: ${activeHaxsite.manifest.items.length} `))}`);
|
|
176
|
+
case "site:stats":
|
|
166
177
|
const date = new Date(activeHaxsite.manifest.metadata.site.updated * 1000);
|
|
167
|
-
|
|
178
|
+
let siteItems = [];
|
|
179
|
+
if (commandRun.options.itemId != null) {
|
|
180
|
+
siteItems = activeHaxsite.manifest.findBranch(commandRun.options.itemId);
|
|
181
|
+
} else {
|
|
182
|
+
siteItems = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
|
|
183
|
+
}
|
|
184
|
+
let els = {};
|
|
185
|
+
for (var i in siteItems) {
|
|
186
|
+
let page = activeHaxsite.loadNode(siteItems[i].id);
|
|
187
|
+
let html = await activeHaxsite.getPageContent(page);
|
|
188
|
+
let dom = (0, _nodeHtmlParser.parse)(`<div id="fullpage">${html}</div>`);
|
|
189
|
+
for (var j in dom.querySelector('#fullpage').childNodes) {
|
|
190
|
+
let node = dom.querySelector('#fullpage').childNodes[j];
|
|
191
|
+
if (node && node.getAttribute) {
|
|
192
|
+
let haxel = await nodeToHaxElement(node, null);
|
|
193
|
+
if (!els[haxel.tag]) {
|
|
194
|
+
els[haxel.tag] = 0;
|
|
195
|
+
}
|
|
196
|
+
els[haxel.tag]++;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
let siteStats = {
|
|
201
|
+
title: activeHaxsite.manifest.title,
|
|
202
|
+
description: activeHaxsite.manifest.description,
|
|
203
|
+
themeName: activeHaxsite.manifest.metadata.theme.name,
|
|
204
|
+
themeElement: activeHaxsite.manifest.metadata.theme.element,
|
|
205
|
+
pageCount: activeHaxsite.manifest.items.length,
|
|
206
|
+
lastUpdated: date.toLocaleDateString("en-US"),
|
|
207
|
+
tagUsage: els
|
|
208
|
+
};
|
|
209
|
+
if (!commandRun.options.format && !commandRun.options.quiet) {
|
|
210
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Title: ${siteStats.title} `))}`);
|
|
211
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Description: ${siteStats.description} `))}`);
|
|
212
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Theme: ${siteStats.themeName} (${siteStats.themeElement})`))}`);
|
|
213
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Pages: ${siteStats.pageCount} `))}`);
|
|
214
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Last updated: ${siteStats.lastUpdated} `))}`);
|
|
215
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Tags used: ${JSON.stringify(siteStats.tagUsage, null, 2)} `))}`);
|
|
216
|
+
} else if (commandRun.options.format === 'yaml') {
|
|
217
|
+
(0, _statements.log)((0, _jsYaml.dump)(siteStats));
|
|
218
|
+
} else {
|
|
219
|
+
(0, _statements.log)(siteStats);
|
|
220
|
+
}
|
|
221
|
+
// simple redirecting to file
|
|
222
|
+
if (commandRun.options.toFile) {
|
|
223
|
+
if (commandRun.options.format === 'yaml') {
|
|
224
|
+
fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(siteStats));
|
|
225
|
+
} else {
|
|
226
|
+
fs.writeFileSync(commandRun.options.toFile, JSON.stringify(siteStats, null, 2));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
case "site:items":
|
|
231
|
+
let siteitems = [];
|
|
232
|
+
if (commandRun.options.itemId != null) {
|
|
233
|
+
siteitems = activeHaxsite.manifest.findBranch(commandRun.options.itemId);
|
|
234
|
+
} else {
|
|
235
|
+
siteitems = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
|
|
236
|
+
}
|
|
237
|
+
for (let i in siteitems) {
|
|
238
|
+
let page = await activeHaxsite.loadNode(siteitems[i].id);
|
|
239
|
+
siteitems[i].content = await activeHaxsite.getPageContent(page);
|
|
240
|
+
}
|
|
241
|
+
// simple redirecting to file if asked for
|
|
242
|
+
if (commandRun.options.toFile) {
|
|
243
|
+
let contents = '';
|
|
244
|
+
if (commandRun.options.format === 'yaml') {
|
|
245
|
+
contents = (0, _jsYaml.dump)(siteitems);
|
|
246
|
+
} else {
|
|
247
|
+
contents = JSON.stringify(siteitems, null, 2);
|
|
248
|
+
}
|
|
249
|
+
fs.writeFileSync(commandRun.options.toFile, contents);
|
|
250
|
+
} else {
|
|
251
|
+
if (commandRun.options.format === 'yaml') {
|
|
252
|
+
(0, _statements.log)((0, _jsYaml.dump)(siteitems));
|
|
253
|
+
} else {
|
|
254
|
+
(0, _statements.log)(siteitems);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
case "site:items-import":
|
|
259
|
+
// need source, then resolve what it is
|
|
260
|
+
if (commandRun.options.itemsImport) {
|
|
261
|
+
let location = commandRun.options.itemsImport;
|
|
262
|
+
let josImport = new JSONOutlineSchema();
|
|
263
|
+
var itemsImport = [];
|
|
264
|
+
// support for address, as in import from some place else
|
|
265
|
+
if (location.startsWith('https://') || location.startsWith('http://')) {
|
|
266
|
+
if (location.endsWith('/site.json')) {
|
|
267
|
+
location = location.replace('/site.json', '');
|
|
268
|
+
} else if (!location.endsWith('/')) {
|
|
269
|
+
location = location + '/';
|
|
270
|
+
}
|
|
271
|
+
let f = await fetch(`${location}site.json`).then(d => d.ok ? d.json() : null);
|
|
272
|
+
if (f && f.items) {
|
|
273
|
+
josImport.items = f.items;
|
|
274
|
+
} else {
|
|
275
|
+
// invalid data
|
|
276
|
+
process.exit(0);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// look on prem
|
|
280
|
+
else if (fs.existsSync(location)) {
|
|
281
|
+
let fileContents = await fs.readFileSync(location);
|
|
282
|
+
if (location.endsWith('.json')) {
|
|
283
|
+
josImport.items = JSON.parse(fileContents);
|
|
284
|
+
} else if (location.endsWith('.yaml')) {
|
|
285
|
+
josImport.items = await (0, _jsYaml.load)(fileContents);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
// allows for filtering
|
|
289
|
+
if (commandRun.options.itemId) {
|
|
290
|
+
itemsImport = josImport.findBranch(commandRun.options.itemId);
|
|
291
|
+
} else {
|
|
292
|
+
itemsImport = josImport.items;
|
|
293
|
+
}
|
|
294
|
+
for (let i in josImport.items) {
|
|
295
|
+
if (josImport.items[i].location && !josImport.items[i].content) {
|
|
296
|
+
josImport.items[i].content = await fetch(`${location}${josImport.items[i].location}`).then(d => d.ok ? d.text() : '');
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
let itemIdMap = {};
|
|
300
|
+
for (let i in josImport.items) {
|
|
301
|
+
// if we have a parent set by force to append this structure to
|
|
302
|
+
// then see if parent = null (implying top level in full site import)
|
|
303
|
+
// or match on itemId to imply that it's the top (no matter parent status)
|
|
304
|
+
if (commandRun.options.parentId) {
|
|
305
|
+
if (josImport.items[i].parent === null || josImport.items[i].id === commandRun.options.itemId) {
|
|
306
|
+
josImport.items[i].parent = commandRun.options.parentId;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// see if map has an entry that is already set
|
|
310
|
+
if (itemIdMap[josImport.items[i].parent]) {
|
|
311
|
+
// remaps the parent of this item bc the thing imported has changed ID
|
|
312
|
+
josImport.items[i].parent = itemIdMap[josImport.items[i].parent];
|
|
313
|
+
}
|
|
314
|
+
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);
|
|
315
|
+
// set in the map for future translations
|
|
316
|
+
itemIdMap[josImport.items[i].id] = tmpAddedItem.id;
|
|
317
|
+
}
|
|
318
|
+
if (!commandRun.options.quiet) {
|
|
319
|
+
(0, _statements.log)(`${josImport.items.length} nodes imported`);
|
|
320
|
+
}
|
|
321
|
+
} else if (!commandRun.options.quiet) {
|
|
322
|
+
(0, _statements.log)('Must specify --item-import as path to valid item export file or URL', 'error');
|
|
323
|
+
}
|
|
168
324
|
break;
|
|
169
325
|
case "start":
|
|
170
326
|
try {
|
|
171
|
-
|
|
172
|
-
|
|
327
|
+
if (!commandRun.options.quiet) {
|
|
328
|
+
p.intro(`Starting server.. `);
|
|
329
|
+
p.intro(`⌨️ To stop server, press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}`);
|
|
330
|
+
}
|
|
173
331
|
await exec(`cd ${activeHaxsite.directory} && npx @haxtheweb/haxcms-nodejs`);
|
|
174
332
|
} catch (e) {
|
|
175
|
-
|
|
333
|
+
(0, _statements.log)(e.stderr);
|
|
176
334
|
}
|
|
177
335
|
break;
|
|
178
336
|
case "node:stats":
|
|
@@ -204,10 +362,28 @@ async function siteCommandDetected(commandRun) {
|
|
|
204
362
|
if (commandRun.options.nodeOp && siteNodeStatsOperations(commandRun.options.nodeOp)) {
|
|
205
363
|
switch (commandRun.options.nodeOp) {
|
|
206
364
|
case 'details':
|
|
207
|
-
|
|
365
|
+
if (commandRun.options.format === 'yaml') {
|
|
366
|
+
(0, _statements.log)((0, _jsYaml.dump)(page));
|
|
367
|
+
} else {
|
|
368
|
+
(0, _statements.log)(page);
|
|
369
|
+
}
|
|
370
|
+
// simple redirecting to file
|
|
371
|
+
if (commandRun.options.toFile) {
|
|
372
|
+
if (commandRun.options.format === 'yaml') {
|
|
373
|
+
fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(page));
|
|
374
|
+
} else {
|
|
375
|
+
fs.writeFileSync(commandRun.options.toFile, JSON.stringify(page, null, 2));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
208
378
|
break;
|
|
209
379
|
case 'html':
|
|
210
|
-
|
|
380
|
+
let itemHTML = await activeHaxsite.getPageContent(page);
|
|
381
|
+
// simple redirecting to file
|
|
382
|
+
if (commandRun.options.toFile) {
|
|
383
|
+
fs.writeFileSync(commandRun.options.toFile, itemHTML);
|
|
384
|
+
} else {
|
|
385
|
+
(0, _statements.log)(itemHTML);
|
|
386
|
+
}
|
|
211
387
|
break;
|
|
212
388
|
case 'schema':
|
|
213
389
|
// next up
|
|
@@ -220,20 +396,38 @@ async function siteCommandDetected(commandRun) {
|
|
|
220
396
|
els.push(await nodeToHaxElement(node, null));
|
|
221
397
|
}
|
|
222
398
|
}
|
|
223
|
-
|
|
399
|
+
// simple redirecting to file
|
|
400
|
+
if (commandRun.options.toFile) {
|
|
401
|
+
if (commandRun.options.format === 'yaml') {
|
|
402
|
+
fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(els));
|
|
403
|
+
} else {
|
|
404
|
+
fs.writeFileSync(commandRun.options.toFile, JSON.stringify(els, null, 2));
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
if (commandRun.options.format === 'yaml') {
|
|
408
|
+
(0, _statements.log)((0, _jsYaml.dump)(els));
|
|
409
|
+
} else {
|
|
410
|
+
(0, _statements.log)(els);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
224
413
|
break;
|
|
225
414
|
case 'md':
|
|
226
415
|
let resp = await openApiBroker('@core', 'htmlToMd', {
|
|
227
416
|
html: await activeHaxsite.getPageContent(page)
|
|
228
417
|
});
|
|
229
|
-
|
|
418
|
+
// simple redirecting to file
|
|
419
|
+
if (commandRun.options.toFile) {
|
|
420
|
+
fs.writeFileSync(commandRun.options.toFile, resp.res.data.data);
|
|
421
|
+
} else {
|
|
422
|
+
(0, _statements.log)(resp.res.data.data);
|
|
423
|
+
}
|
|
230
424
|
break;
|
|
231
425
|
}
|
|
232
426
|
}
|
|
233
427
|
}
|
|
234
428
|
} catch (e) {
|
|
235
|
-
|
|
236
|
-
|
|
429
|
+
(0, _statements.log)(e.stderr);
|
|
430
|
+
(0, _statements.log)(e);
|
|
237
431
|
}
|
|
238
432
|
break;
|
|
239
433
|
case "node:add":
|
|
@@ -258,11 +452,11 @@ async function siteCommandDetected(commandRun) {
|
|
|
258
452
|
}
|
|
259
453
|
});
|
|
260
454
|
if (commandRun.options.v) {
|
|
261
|
-
|
|
455
|
+
(0, _statements.log)(resp.res.data);
|
|
262
456
|
}
|
|
263
|
-
|
|
457
|
+
(0, _statements.log)(`"${commandRun.options.title}" added to site`);
|
|
264
458
|
} catch (e) {
|
|
265
|
-
|
|
459
|
+
(0, _statements.log)(e.stderr);
|
|
266
460
|
}
|
|
267
461
|
break;
|
|
268
462
|
case "node:edit":
|
|
@@ -345,7 +539,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
345
539
|
if (typeof commandRun.options[commandRun.options.nodeOp] !== "undefined") {
|
|
346
540
|
if (commandRun.options.nodeOp === 'content') {
|
|
347
541
|
if (commandRun.options.content && (await page.writeLocation(commandRun.options.content))) {
|
|
348
|
-
|
|
542
|
+
(0, _statements.log)(`node:edit success updated page content: "${page.id}`);
|
|
349
543
|
} else {
|
|
350
544
|
console.warn(`node:edit failure to write page content : ${page.id}`);
|
|
351
545
|
}
|
|
@@ -360,13 +554,13 @@ async function siteCommandDetected(commandRun) {
|
|
|
360
554
|
}
|
|
361
555
|
let resp = await activeHaxsite.updateNode(page);
|
|
362
556
|
if (commandRun.options.v) {
|
|
363
|
-
|
|
557
|
+
(0, _statements.log)(resp);
|
|
364
558
|
}
|
|
365
559
|
}
|
|
366
560
|
}
|
|
367
561
|
}
|
|
368
562
|
} catch (e) {
|
|
369
|
-
|
|
563
|
+
(0, _statements.log)(e.stderr);
|
|
370
564
|
}
|
|
371
565
|
break;
|
|
372
566
|
case "node:delete":
|
|
@@ -402,25 +596,25 @@ async function siteCommandDetected(commandRun) {
|
|
|
402
596
|
if (resp.res.data === 500) {
|
|
403
597
|
console.warn(`node:delete failed "${commandRun.options.itemId} not found`);
|
|
404
598
|
} else {
|
|
405
|
-
|
|
599
|
+
(0, _statements.log)(`"${commandRun.options.itemId}" deleted`);
|
|
406
600
|
}
|
|
407
601
|
} else {
|
|
408
|
-
|
|
602
|
+
(0, _statements.log)(`Delete operation canceled`);
|
|
409
603
|
}
|
|
410
604
|
}
|
|
411
605
|
} catch (e) {
|
|
412
|
-
|
|
606
|
+
(0, _statements.log)(e.stderr);
|
|
413
607
|
}
|
|
414
608
|
break;
|
|
415
|
-
case "sync":
|
|
609
|
+
case "site:sync":
|
|
416
610
|
// @todo git sync might need other arguments / be combined with publishing
|
|
417
611
|
try {
|
|
418
612
|
await exec(`cd ${activeHaxsite.directory} && git pull && git push`);
|
|
419
613
|
} catch (e) {
|
|
420
|
-
|
|
614
|
+
(0, _statements.log)(e.stderr);
|
|
421
615
|
}
|
|
422
616
|
break;
|
|
423
|
-
case "theme":
|
|
617
|
+
case "site:theme":
|
|
424
618
|
try {
|
|
425
619
|
//theme
|
|
426
620
|
let list = await siteThemeList();
|
|
@@ -440,10 +634,10 @@ async function siteCommandDetected(commandRun) {
|
|
|
440
634
|
}
|
|
441
635
|
}
|
|
442
636
|
} catch (e) {
|
|
443
|
-
|
|
637
|
+
(0, _statements.log)(e.stderr);
|
|
444
638
|
}
|
|
445
639
|
break;
|
|
446
|
-
case "surge":
|
|
640
|
+
case "site:surge":
|
|
447
641
|
try {
|
|
448
642
|
if (!commandRun.options.domain) {
|
|
449
643
|
commandRun.options.domain = await p.text({
|
|
@@ -458,25 +652,26 @@ async function siteCommandDetected(commandRun) {
|
|
|
458
652
|
});
|
|
459
653
|
}
|
|
460
654
|
let execOutput = await exec(`cd ${activeHaxsite.directory} && surge . ${commandRun.options.domain}`);
|
|
461
|
-
|
|
655
|
+
(0, _statements.log)(execOutput.stdout.trim());
|
|
462
656
|
} catch (e) {
|
|
463
|
-
|
|
657
|
+
(0, _statements.log)(e.stderr);
|
|
464
658
|
}
|
|
465
659
|
break;
|
|
466
|
-
case "file
|
|
660
|
+
case "site:file-list":
|
|
467
661
|
let res = new Res();
|
|
468
662
|
await hax.RoutesMap.get.listFiles({
|
|
469
663
|
query: activeHaxsite.name,
|
|
470
664
|
filename: commandRun.options.filename
|
|
471
665
|
}, res);
|
|
472
666
|
if (commandRun.options.format === 'yaml') {
|
|
473
|
-
|
|
667
|
+
(0, _statements.log)((0, _jsYaml.dump)(res.data));
|
|
474
668
|
} else {
|
|
475
|
-
|
|
669
|
+
(0, _statements.log)(res.data);
|
|
476
670
|
}
|
|
477
671
|
break;
|
|
478
672
|
case "site:html":
|
|
479
673
|
case "site:md":
|
|
674
|
+
case "site:schema":
|
|
480
675
|
let siteContent = '';
|
|
481
676
|
activeHaxsite = await hax.systemStructureContext();
|
|
482
677
|
let items = [];
|
|
@@ -485,18 +680,58 @@ async function siteCommandDetected(commandRun) {
|
|
|
485
680
|
} else {
|
|
486
681
|
items = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
|
|
487
682
|
}
|
|
488
|
-
|
|
489
|
-
let
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
683
|
+
if (operation.action === 'site:schema') {
|
|
684
|
+
let els = [];
|
|
685
|
+
for (var i in items) {
|
|
686
|
+
let page = activeHaxsite.loadNode(items[i].id);
|
|
687
|
+
let html = await activeHaxsite.getPageContent(page);
|
|
688
|
+
let dom = (0, _nodeHtmlParser.parse)(`<div id="fullpage">${html}</div>`);
|
|
689
|
+
els.push({
|
|
690
|
+
tag: "h1",
|
|
691
|
+
properties: {
|
|
692
|
+
"data-jos-item-id": items[i].id
|
|
693
|
+
},
|
|
694
|
+
content: `${items[i].title}`
|
|
695
|
+
});
|
|
696
|
+
for (var j in dom.querySelector('#fullpage').childNodes) {
|
|
697
|
+
let node = dom.querySelector('#fullpage').childNodes[j];
|
|
698
|
+
if (node && node.getAttribute) {
|
|
699
|
+
els.push(await nodeToHaxElement(node, null));
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
// simple redirecting to file
|
|
704
|
+
if (commandRun.options.toFile) {
|
|
705
|
+
if (commandRun.options.format === 'yaml') {
|
|
706
|
+
fs.writeFileSync(commandRun.options.toFile, (0, _jsYaml.dump)(els));
|
|
707
|
+
} else {
|
|
708
|
+
fs.writeFileSync(commandRun.options.toFile, JSON.stringify(els, null, 2));
|
|
709
|
+
}
|
|
710
|
+
} else {
|
|
711
|
+
if (commandRun.options.format === 'yaml') {
|
|
712
|
+
(0, _statements.log)((0, _jsYaml.dump)(els));
|
|
713
|
+
} else {
|
|
714
|
+
(0, _statements.log)(els);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
498
717
|
} else {
|
|
499
|
-
|
|
718
|
+
for (var i in items) {
|
|
719
|
+
let page = activeHaxsite.loadNode(items[i].id);
|
|
720
|
+
siteContent += `<h1>${items[i].title}</h1>\n\r`;
|
|
721
|
+
siteContent += `<div data-jos-item-id="${items[i].id}">\n\r${await activeHaxsite.getPageContent(page)}\n\r</div>\n\r`;
|
|
722
|
+
}
|
|
723
|
+
if (operation.action === 'site:md') {
|
|
724
|
+
let resp = await openApiBroker('@core', 'htmlToMd', {
|
|
725
|
+
html: siteContent
|
|
726
|
+
});
|
|
727
|
+
if (commandRun.options.toFile) {
|
|
728
|
+
fs.writeFileSync(commandRun.options.toFile, resp.res.data.data);
|
|
729
|
+
} else {
|
|
730
|
+
(0, _statements.log)(resp.res.data.data);
|
|
731
|
+
}
|
|
732
|
+
} else {
|
|
733
|
+
(0, _statements.log)(siteContent);
|
|
734
|
+
}
|
|
500
735
|
}
|
|
501
736
|
break;
|
|
502
737
|
case "quit":
|
|
@@ -509,7 +744,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
509
744
|
}
|
|
510
745
|
operation.action = null;
|
|
511
746
|
}
|
|
512
|
-
(
|
|
747
|
+
if (!commandRun.options.quiet) {
|
|
748
|
+
(0, _statements.communityStatement)();
|
|
749
|
+
}
|
|
513
750
|
}
|
|
514
751
|
function siteNodeStatsOperations(search = null) {
|
|
515
752
|
let obj = [{
|
|
@@ -602,14 +839,16 @@ async function openApiBroker(scope, call, body) {
|
|
|
602
839
|
// process site creation
|
|
603
840
|
async function siteProcess(commandRun, project, port = '3000') {
|
|
604
841
|
// auto select operations to perform if requested
|
|
842
|
+
var s = p.spinner();
|
|
605
843
|
if (!project.extras) {
|
|
606
844
|
project.extras = [];
|
|
607
845
|
if (commandRun.options.i) {
|
|
608
846
|
project.extras = ['launch'];
|
|
609
847
|
}
|
|
610
848
|
}
|
|
611
|
-
|
|
612
|
-
|
|
849
|
+
if (!commandRun.options.quiet) {
|
|
850
|
+
s.start((0, _statements.merlinSays)(`Creating new site: ${project.name}`));
|
|
851
|
+
}
|
|
613
852
|
let siteRequest = {
|
|
614
853
|
"site": {
|
|
615
854
|
"name": project.name,
|
|
@@ -654,13 +893,15 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
654
893
|
}, res);
|
|
655
894
|
if (commandRun.options.v) {
|
|
656
895
|
if (commandRun.options.format === 'yaml') {
|
|
657
|
-
|
|
896
|
+
(0, _statements.log)((0, _jsYaml.dump)(res.data));
|
|
658
897
|
} else {
|
|
659
|
-
|
|
898
|
+
(0, _statements.log)(res.data);
|
|
660
899
|
}
|
|
661
900
|
}
|
|
662
|
-
|
|
663
|
-
|
|
901
|
+
if (!commandRun.options.quiet) {
|
|
902
|
+
s.stop((0, _statements.merlinSays)(`${project.name} created!`));
|
|
903
|
+
await (0, _promises.setTimeout)(500);
|
|
904
|
+
}
|
|
664
905
|
if (project.gitRepo && !commandRun.options.isMonorepo) {
|
|
665
906
|
try {
|
|
666
907
|
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}` : ''}`);
|
|
@@ -668,35 +909,24 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
668
909
|
}
|
|
669
910
|
// options for install, git and other extras
|
|
670
911
|
// can't launch if we didn't install first so launch implies installation
|
|
671
|
-
if (project.extras.includes('launch') || project.extras.includes('install')) {
|
|
672
|
-
s.start((0, _statements.merlinSays)(`Installation magic (${commandRun.options.npmClient} install)`));
|
|
673
|
-
try {
|
|
674
|
-
// monorepos install from top but then still need to launch from local location
|
|
675
|
-
if (!commandRun.options.isMonorepo) {
|
|
676
|
-
await exec(`cd ${project.path}/${project.name} && ${commandRun.options.npmClient} install`);
|
|
677
|
-
}
|
|
678
|
-
} catch (e) {
|
|
679
|
-
console.log(e);
|
|
680
|
-
}
|
|
681
|
-
s.stop((0, _statements.merlinSays)(`Everything is installed. It's go time`));
|
|
682
|
-
}
|
|
683
|
-
// autolaunch if default was selected
|
|
684
912
|
if (project.extras.includes('launch')) {
|
|
685
913
|
let optionPath = `${project.path}/${project.name}`;
|
|
686
914
|
let command = `npx @haxtheweb/haxcms-nodejs`;
|
|
687
|
-
|
|
915
|
+
if (!commandRun.options.quiet) {
|
|
916
|
+
p.note(`${(0, _statements.merlinSays)(`I have summoned a sub-process daemon 👹`)}
|
|
688
917
|
|
|
689
|
-
|
|
690
|
-
|
|
918
|
+
🚀 Running your ${_picocolors.default.bold(project.type)} ${_picocolors.default.bold(project.name)}:
|
|
919
|
+
${_picocolors.default.underline(_picocolors.default.cyan(`http://localhost:${port}`))}
|
|
691
920
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
921
|
+
🏠 Launched: ${_picocolors.default.underline(_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${optionPath}`))))}
|
|
922
|
+
💻 Folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`cd ${optionPath}`)))}
|
|
923
|
+
📂 Open folder: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`open ${optionPath}`)))}
|
|
924
|
+
📘 VS Code Project: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`code ${optionPath}`)))}
|
|
925
|
+
🚧 Launch later: ${_picocolors.default.bold(_picocolors.default.yellow(_picocolors.default.bgBlack(`${command}`)))}
|
|
697
926
|
|
|
698
|
-
|
|
699
|
-
|
|
927
|
+
⌨️ To resume 🧙 Merlin press: ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgRed(` CTRL + C `)))}
|
|
928
|
+
`);
|
|
929
|
+
}
|
|
700
930
|
// at least a second to see the message print at all
|
|
701
931
|
await (0, _promises.setTimeout)(1000);
|
|
702
932
|
try {
|
|
@@ -704,24 +934,25 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
704
934
|
} catch (e) {
|
|
705
935
|
// don't log bc output is weird
|
|
706
936
|
}
|
|
707
|
-
} else {
|
|
708
|
-
let nextSteps = `cd ${project.path}/${project.name} &&
|
|
709
|
-
p.note(`${project.name} is ready to go. Run the following to start
|
|
937
|
+
} else if (!commandRun.options.quiet) {
|
|
938
|
+
let nextSteps = `cd ${project.path}/${project.name} && hax start`;
|
|
939
|
+
p.note(`${project.name} is ready to go. Run the following to start working with it:`);
|
|
710
940
|
p.outro(nextSteps);
|
|
711
941
|
}
|
|
712
942
|
}
|
|
713
943
|
async function siteItemsOptionsList(activeHaxsite, skipId = null) {
|
|
714
|
-
let items =
|
|
715
|
-
|
|
944
|
+
let items = activeHaxsite.manifest.orderTree(activeHaxsite.manifest.items);
|
|
945
|
+
let optionItems = [];
|
|
946
|
+
for (var i in items) {
|
|
716
947
|
// ensure we remove self if operation is about page in question like parent selector
|
|
717
|
-
if (
|
|
718
|
-
|
|
719
|
-
value:
|
|
720
|
-
label:
|
|
948
|
+
if (items[i].id !== skipId) {
|
|
949
|
+
optionItems.push({
|
|
950
|
+
value: items[i].id,
|
|
951
|
+
label: ` ${'-'.repeat(parseInt(items[i].indent))}${items[i].title}`
|
|
721
952
|
});
|
|
722
953
|
}
|
|
723
954
|
}
|
|
724
|
-
return
|
|
955
|
+
return optionItems;
|
|
725
956
|
}
|
|
726
957
|
async function siteThemeList() {
|
|
727
958
|
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
|
-
|
|
263
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
388
|
+
(0, _statements.log)(`schema written to: ./lib/${declarations.tagName}.haxProperties.json`);
|
|
373
389
|
});
|
|
374
390
|
});
|
|
375
391
|
}
|
package/dist/lib/statements.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "9.0.15",
|
|
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
|
|
27
|
+
"haxcms-nodejs": "haxcms-nodejs"
|
|
28
28
|
},
|
|
29
29
|
"bin": {
|
|
30
30
|
"create-haxtheweb": "./dist/create.js",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|