@haxtheweb/create 9.0.23 → 9.0.25
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 +5 -6
- package/dist/lib/logging.js +2 -2
- package/dist/lib/programs/site.js +42 -22
- package/dist/lib/programs/webcomponent.js +2 -1
- package/package.json +1 -1
package/dist/create.js
CHANGED
|
@@ -35,10 +35,10 @@ async function main() {
|
|
|
35
35
|
.option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element')
|
|
36
36
|
|
|
37
37
|
// options for site
|
|
38
|
-
.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').version(await HAXCMS.getHAXCMSVersion()).helpCommand(true);
|
|
38
|
+
.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').option('--recipe <char>', 'path to recipe file').version(await HAXCMS.getHAXCMSVersion()).helpCommand(true);
|
|
39
39
|
|
|
40
40
|
// default command which runs interactively
|
|
41
|
-
_commander.program.command('start').description('
|
|
41
|
+
_commander.program.command('start').description('Select which hax sub-program to run').action(() => {
|
|
42
42
|
commandRun = {
|
|
43
43
|
command: 'start',
|
|
44
44
|
arguments: {},
|
|
@@ -51,8 +51,7 @@ async function main() {
|
|
|
51
51
|
(0, _site.siteActions)().forEach(action => {
|
|
52
52
|
strActions += `${action.value} - ${action.label}` + "\n\r";
|
|
53
53
|
});
|
|
54
|
-
let siteProg = _commander.program.command('site')
|
|
55
|
-
siteProg.argument('[action]', 'Actions to perform on site include:' + "\n\r" + strActions).action(action => {
|
|
54
|
+
let siteProg = _commander.program.command('site').description('create or administer a HAXsite').argument('[action]', 'Actions to perform on site include:' + "\n\r" + strActions).action(action => {
|
|
56
55
|
commandRun = {
|
|
57
56
|
command: 'site',
|
|
58
57
|
arguments: {},
|
|
@@ -62,7 +61,7 @@ async function main() {
|
|
|
62
61
|
commandRun.arguments.action = action;
|
|
63
62
|
commandRun.options.skip = true;
|
|
64
63
|
}
|
|
65
|
-
}).option('--
|
|
64
|
+
}).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').option('--no-extras', 'skip all extra / automatic command processing').option('--root <char>', 'root location to execute the command from').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('--title-scrape <char>', 'CSS Selector for `title` in resource').option('--content-scrape <char>', 'CSS Selector for `body` in resource').option('--item-import <char>', 'import items from a file / site').option('--recipe <char>', 'path to recipe file').version(await HAXCMS.getHAXCMSVersion());
|
|
66
65
|
let siteNodeOps = (0, _site.siteNodeOperations)();
|
|
67
66
|
for (var i in siteNodeOps) {
|
|
68
67
|
_commander.program.option(`--${(0, _utils.camelToDash)(siteNodeOps[i].value)} <char>`, `${siteNodeOps[i].label}`);
|
|
@@ -367,7 +366,7 @@ async function main() {
|
|
|
367
366
|
if (results.type === "site" && !commandRun.options.theme) {
|
|
368
367
|
// support having no theme but autoselecting
|
|
369
368
|
if (commandRun.options.auto && commandRun.options.skip) {
|
|
370
|
-
commandRun.options.theme = themes[0];
|
|
369
|
+
commandRun.options.theme = themes[0].value;
|
|
371
370
|
} else {
|
|
372
371
|
return p.select({
|
|
373
372
|
message: "Theme:",
|
package/dist/lib/logging.js
CHANGED
|
@@ -35,7 +35,7 @@ const logger = exports.logger = winston.createLogger({
|
|
|
35
35
|
transports: [consoleTransport, logFile]
|
|
36
36
|
});
|
|
37
37
|
function haxCliEnvOptions() {
|
|
38
|
-
return ['skip', 'npmClient', 'i', 'extras', 'root', 'path', 'org', 'author'];
|
|
38
|
+
return ['skip', 'npmClient', 'i', 'extras', 'root', 'path', 'org', 'author', 'y', 'auto'];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// wrapper so we can silence all log messages at the same time
|
|
@@ -52,7 +52,7 @@ function commandString(commandRun) {
|
|
|
52
52
|
} else if (key === false) {
|
|
53
53
|
comStr += ` --no-${(0, _utils.camelToDash)(key)}`;
|
|
54
54
|
} else {
|
|
55
|
-
comStr += ` --${(0, _utils.camelToDash)(key)}
|
|
55
|
+
comStr += ` --${(0, _utils.camelToDash)(key)} "${commandRun.options[key]}"`;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -46,6 +46,9 @@ exec('surge --version', error => {
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
const siteRecipeFile = 'create-cli.recipe';
|
|
49
|
+
const siteLoggingName = 'cli';
|
|
50
|
+
const logLevels = {};
|
|
51
|
+
logLevels[siteLoggingName] = 0;
|
|
49
52
|
|
|
50
53
|
// fake response class so we can capture the response from the headless route as opposed to print to console
|
|
51
54
|
// this way we can handle as data or if use is requesting output format to change we can respond
|
|
@@ -132,10 +135,8 @@ async function siteCommandDetected(commandRun) {
|
|
|
132
135
|
filename: recipeFileName
|
|
133
136
|
});
|
|
134
137
|
const recipe = winston.createLogger({
|
|
135
|
-
levels:
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
level: 'hax',
|
|
138
|
+
levels: logLevels,
|
|
139
|
+
level: siteLoggingName,
|
|
139
140
|
transports: [recipeLogTransport],
|
|
140
141
|
format: winston.format.simple()
|
|
141
142
|
});
|
|
@@ -343,7 +344,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
343
344
|
if (!commandRun.options.quiet) {
|
|
344
345
|
(0, _logging.log)(`${josImport.items.length} nodes imported`);
|
|
345
346
|
}
|
|
346
|
-
recipe.log(
|
|
347
|
+
recipe.log(siteLoggingName, (0, _logging.commandString)(commandRun));
|
|
347
348
|
} else if (!commandRun.options.quiet) {
|
|
348
349
|
(0, _logging.log)('Must specify --item-import as path to valid item export file or URL', 'error');
|
|
349
350
|
}
|
|
@@ -525,7 +526,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
525
526
|
createNodeBody.node.contents = locationContent;
|
|
526
527
|
}
|
|
527
528
|
let resp = await haxcmsNodejsCli.cliBridge('createNode', createNodeBody);
|
|
528
|
-
recipe.log(
|
|
529
|
+
recipe.log(siteLoggingName, (0, _logging.commandString)(commandRun));
|
|
529
530
|
if (commandRun.options.v) {
|
|
530
531
|
(0, _logging.log)(resp.res.data, 'silly');
|
|
531
532
|
}
|
|
@@ -658,7 +659,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
658
659
|
}
|
|
659
660
|
// if we have content (meaning it's not blank) then try to write the page location
|
|
660
661
|
if (locationContent && (await page.writeLocation(locationContent))) {
|
|
661
|
-
recipe.log(
|
|
662
|
+
recipe.log(siteLoggingName, (0, _logging.commandString)(commandRun));
|
|
662
663
|
if (!commandRun.options.quiet) {
|
|
663
664
|
(0, _logging.log)(`node:edit success updated page content: "${page.id}`);
|
|
664
665
|
}
|
|
@@ -675,7 +676,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
675
676
|
page[commandRun.options.nodeOp] = commandRun.options[commandRun.options.nodeOp];
|
|
676
677
|
}
|
|
677
678
|
let resp = await activeHaxsite.updateNode(page);
|
|
678
|
-
recipe.log(
|
|
679
|
+
recipe.log(siteLoggingName, (0, _logging.commandString)(commandRun));
|
|
679
680
|
if (commandRun.options.v) {
|
|
680
681
|
(0, _logging.log)(resp, 'silly');
|
|
681
682
|
}
|
|
@@ -719,7 +720,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
719
720
|
if (resp.res.data === 500) {
|
|
720
721
|
console.warn(`node:delete failed "${commandRun.options.itemId} not found`);
|
|
721
722
|
} else {
|
|
722
|
-
recipe.log(
|
|
723
|
+
recipe.log(siteLoggingName, (0, _logging.commandString)(commandRun));
|
|
723
724
|
(0, _logging.log)(`"${commandRun.options.itemId}" deleted`);
|
|
724
725
|
}
|
|
725
726
|
} else {
|
|
@@ -755,7 +756,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
755
756
|
if (themes && commandRun.options.theme && themes[commandRun.options.theme]) {
|
|
756
757
|
activeHaxsite.manifest.metadata.theme = themes[commandRun.options.theme];
|
|
757
758
|
activeHaxsite.manifest.save(false);
|
|
758
|
-
recipe.log(
|
|
759
|
+
recipe.log(siteLoggingName, (0, _logging.commandString)(commandRun));
|
|
759
760
|
}
|
|
760
761
|
}
|
|
761
762
|
} catch (e) {
|
|
@@ -885,9 +886,8 @@ async function siteCommandDetected(commandRun) {
|
|
|
885
886
|
case "recipe:read":
|
|
886
887
|
// just print the recipe out
|
|
887
888
|
if (fs.existsSync(path.join(process.cwd(), `${siteRecipeFile}`))) {
|
|
888
|
-
let recContents = await fs.readFileSync(path.join(process.cwd(), `${siteRecipeFile}`));
|
|
889
|
+
let recContents = await fs.readFileSync(path.join(process.cwd(), `${siteRecipeFile}`), 'utf8');
|
|
889
890
|
console.log(recContents);
|
|
890
|
-
(0, _logging.log)(recContents);
|
|
891
891
|
}
|
|
892
892
|
break;
|
|
893
893
|
case "recipe:play":
|
|
@@ -897,14 +897,37 @@ async function siteCommandDetected(commandRun) {
|
|
|
897
897
|
commandRun.options.recipe = await p.text({
|
|
898
898
|
message: `Select recipe:`,
|
|
899
899
|
defaultValue: process.cwd(),
|
|
900
|
-
initialValue: process.cwd()
|
|
900
|
+
initialValue: process.cwd(),
|
|
901
|
+
validate: val => {
|
|
902
|
+
if (!val.endsWith('.recipe')) {
|
|
903
|
+
return 'HAX Recipe files must end in .recipe';
|
|
904
|
+
}
|
|
905
|
+
}
|
|
901
906
|
});
|
|
902
907
|
}
|
|
903
908
|
if (fs.existsSync(commandRun.options.recipe)) {
|
|
904
|
-
let recContents = await fs.readFileSync(commandRun.options.recipe);
|
|
909
|
+
let recContents = await fs.readFileSync(commandRun.options.recipe, 'utf8');
|
|
905
910
|
// split into commands
|
|
906
|
-
let commandList = recContents.
|
|
907
|
-
|
|
911
|
+
let commandList = recContents.replaceAll('cli: ', '').split("\n");
|
|
912
|
+
// confirm each command or allow --y so that it auto applies
|
|
913
|
+
for (var i in commandList) {
|
|
914
|
+
// verify every command starts this way for safety
|
|
915
|
+
if (commandList[i].startsWith('hax site')) {
|
|
916
|
+
let confirmation;
|
|
917
|
+
if (commandRun.options.y) {
|
|
918
|
+
confirmation = true;
|
|
919
|
+
} else {
|
|
920
|
+
confirmation = await p.confirm({
|
|
921
|
+
message: `Do you want to run ${commandList[i]}? (This cannot be undone)`,
|
|
922
|
+
initialValue: true
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
// confirmed; let's run!
|
|
926
|
+
if (confirmation) {
|
|
927
|
+
await exec(`${commandList[i]} --y --no-i --auto --quiet`);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
908
931
|
}
|
|
909
932
|
break;
|
|
910
933
|
case "quit":
|
|
@@ -1144,22 +1167,19 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1144
1167
|
}, res);
|
|
1145
1168
|
// path different for this one as it's on the fly produced
|
|
1146
1169
|
const recipeFileName = path.join(project.path, '/', project.name, `${siteRecipeFile}`);
|
|
1147
|
-
console.log(recipeFileName);
|
|
1148
1170
|
const recipeLogTransport = new winston.transports.File({
|
|
1149
1171
|
filename: recipeFileName
|
|
1150
1172
|
});
|
|
1151
1173
|
const recipe = winston.createLogger({
|
|
1152
|
-
levels:
|
|
1153
|
-
|
|
1154
|
-
},
|
|
1155
|
-
level: 'hax',
|
|
1174
|
+
levels: logLevels,
|
|
1175
|
+
level: siteLoggingName,
|
|
1156
1176
|
transports: [recipeLogTransport],
|
|
1157
1177
|
format: winston.format.simple()
|
|
1158
1178
|
});
|
|
1159
1179
|
// matching the common object elsewhere tho different reference in this command since it creates from nothing
|
|
1160
1180
|
// capture this if use input on the fly
|
|
1161
1181
|
commandRun.options.theme = project.theme;
|
|
1162
|
-
recipe.log(
|
|
1182
|
+
recipe.log(siteLoggingName, (0, _logging.commandString)(commandRun));
|
|
1163
1183
|
if (commandRun.options.v) {
|
|
1164
1184
|
if (commandRun.options.format === 'yaml') {
|
|
1165
1185
|
(0, _logging.log)((0, _jsYaml.dump)(res.data), 'silly');
|
|
@@ -138,7 +138,8 @@ class HAXWiring {
|
|
|
138
138
|
async function webcomponentProcess(commandRun, project, port = "8000") {
|
|
139
139
|
// auto select operations to perform if requested
|
|
140
140
|
if (!project.extras) {
|
|
141
|
-
|
|
141
|
+
console.log(commandRun.options.extras);
|
|
142
|
+
if (commandRun.options.extras === false) {
|
|
142
143
|
project.extras = [];
|
|
143
144
|
} else {
|
|
144
145
|
let extras = ['launch', 'install', 'git'];
|