@haxtheweb/create 9.0.22 → 9.0.23
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 +27 -14
- package/dist/lib/logging.js +60 -0
- package/dist/lib/programs/site.js +123 -43
- package/dist/lib/programs/webcomponent.js +7 -6
- package/dist/lib/statements.js +0 -7
- package/package.json +3 -2
package/dist/create.js
CHANGED
|
@@ -7,6 +7,7 @@ var path = _interopRequireWildcard(require("node:path"));
|
|
|
7
7
|
var p = _interopRequireWildcard(require("@clack/prompts"));
|
|
8
8
|
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
9
9
|
var _statements = require("./lib/statements.js");
|
|
10
|
+
var _logging = require("./lib/logging.js");
|
|
10
11
|
var _webcomponent = require("./lib/programs/webcomponent.js");
|
|
11
12
|
var _site = require("./lib/programs/site.js");
|
|
12
13
|
var _utils = require("./lib/utils.js");
|
|
@@ -28,7 +29,7 @@ exec('git --version', error => {
|
|
|
28
29
|
});
|
|
29
30
|
async function main() {
|
|
30
31
|
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('--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')
|
|
32
|
+
_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').option('--no-extras', 'skip all extra / automatic command processing').option('--root <char>', 'root location to execute the command from')
|
|
32
33
|
|
|
33
34
|
// options for webcomponent
|
|
34
35
|
.option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element')
|
|
@@ -61,13 +62,12 @@ async function main() {
|
|
|
61
62
|
commandRun.arguments.action = action;
|
|
62
63
|
commandRun.options.skip = true;
|
|
63
64
|
}
|
|
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('--title-scrape <char>', 'CSS Selector for `title` in resource').option('--content-scrape <char>', 'CSS Selector for `body` in resource').option('--to-file <char>', 'redirect command output to a file').option('--no-extras', 'skip all extra / automatic command processing').option('--item-import <char>', 'import items from a file / site').version(await HAXCMS.getHAXCMSVersion());
|
|
65
|
+
}).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('--title-scrape <char>', 'CSS Selector for `title` in resource').option('--content-scrape <char>', 'CSS Selector for `body` in resource').option('--to-file <char>', 'redirect command output to a file').option('--no-extras', 'skip all extra / automatic command processing').option('--item-import <char>', 'import items from a file / site').option('--root <char>', 'root location to execute the command from').version(await HAXCMS.getHAXCMSVersion());
|
|
65
66
|
let siteNodeOps = (0, _site.siteNodeOperations)();
|
|
66
67
|
for (var i in siteNodeOps) {
|
|
67
68
|
_commander.program.option(`--${(0, _utils.camelToDash)(siteNodeOps[i].value)} <char>`, `${siteNodeOps[i].label}`);
|
|
68
69
|
siteProg.option(`--${(0, _utils.camelToDash)(siteNodeOps[i].value)} <char>`, `${siteNodeOps[i].label}`);
|
|
69
70
|
}
|
|
70
|
-
|
|
71
71
|
// webcomponent program
|
|
72
72
|
_commander.program.command('webcomponent').description('Create Lit based web components, with HAX recommendations').argument('[name]', 'name of the project').action(name => {
|
|
73
73
|
commandRun = {
|
|
@@ -80,15 +80,32 @@ 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('--to-file <char>', 'redirect command output to a file').option('--no-extras', 'skip all extra / automatic command processing').option('--no-i', 'prevent interactions / sub-process, good for scripting').version(await HAXCMS.getHAXCMSVersion());
|
|
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-extras', 'skip all extra / automatic command processing').option('--no-i', 'prevent interactions / sub-process, good for scripting').option('--root <char>', 'root location to execute the command from').version(await HAXCMS.getHAXCMSVersion());
|
|
84
84
|
// process program arguments
|
|
85
85
|
_commander.program.parse();
|
|
86
86
|
commandRun.options = {
|
|
87
87
|
...commandRun.options,
|
|
88
88
|
..._commander.program.opts()
|
|
89
89
|
};
|
|
90
|
+
// this is a false positive bc of the no-extras flag. no-extras does not imply true if not there
|
|
91
|
+
// but that's how the CLI works. This then bombs things downstream. Its good to be false but NOT
|
|
92
|
+
// good to be true since we need an array of options
|
|
93
|
+
if (commandRun.options.extras === true) {
|
|
94
|
+
delete commandRun.options.extras;
|
|
95
|
+
}
|
|
96
|
+
// allow execution of the command from a different location
|
|
97
|
+
if (commandRun.options.root) {
|
|
98
|
+
process.chdir(commandRun.options.root);
|
|
99
|
+
}
|
|
100
|
+
// bridge to log so we can respect this setting
|
|
101
|
+
if (commandRun.options.quiet) {
|
|
102
|
+
process.haxquiet = true;
|
|
103
|
+
// don't output to the console any messages on this run since told to be silent
|
|
104
|
+
// logging still happens to log files
|
|
105
|
+
_logging.logger.remove(_logging.consoleTransport);
|
|
106
|
+
}
|
|
90
107
|
if (commandRun.options.debug) {
|
|
91
|
-
(0,
|
|
108
|
+
(0, _logging.log)(commandRun, 'debug');
|
|
92
109
|
}
|
|
93
110
|
// auto and y assume same thing
|
|
94
111
|
if (commandRun.options.y || commandRun.options.auto) {
|
|
@@ -101,15 +118,11 @@ async function main() {
|
|
|
101
118
|
let value = await exec(`git config user.name`);
|
|
102
119
|
author = value.stdout.trim();
|
|
103
120
|
} catch (e) {
|
|
104
|
-
(0,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// bridge to log so we can respect this setting
|
|
109
|
-
if (commandRun.options.quiet) {
|
|
110
|
-
process.haxquiet = true;
|
|
121
|
+
(0, _logging.log)(`
|
|
122
|
+
git user name not configured. Run the following to do this:\n
|
|
123
|
+
git config --global user.name "namehere"\n
|
|
124
|
+
git config --global user.email "email@here`, 'debug');
|
|
111
125
|
}
|
|
112
|
-
// only set path if not already set
|
|
113
126
|
if (!commandRun.options.path && commandRun.options.skip) {
|
|
114
127
|
commandRun.options.path = process.cwd();
|
|
115
128
|
}
|
|
@@ -166,7 +179,7 @@ async function main() {
|
|
|
166
179
|
}
|
|
167
180
|
}
|
|
168
181
|
if (commandRun.options.debug) {
|
|
169
|
-
(0,
|
|
182
|
+
(0, _logging.log)(packageData, 'debug');
|
|
170
183
|
}
|
|
171
184
|
// CLI works within context of the site if one is detected, otherwise we can do other thingss
|
|
172
185
|
if (await hax.systemStructureContext()) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.commandString = commandString;
|
|
7
|
+
exports.consoleTransport = void 0;
|
|
8
|
+
exports.haxCliEnvOptions = haxCliEnvOptions;
|
|
9
|
+
exports.log = log;
|
|
10
|
+
exports.logger = exports.logFile = void 0;
|
|
11
|
+
var _nodeOs = require("node:os");
|
|
12
|
+
var path = _interopRequireWildcard(require("node:path"));
|
|
13
|
+
var winston = _interopRequireWildcard(require("winston"));
|
|
14
|
+
var _utils = require("./utils.js");
|
|
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); }
|
|
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
|
+
const logFileName = path.join((0, _nodeOs.homedir)(), '.haxtheweb', 'create.log');
|
|
18
|
+
const consoleTransport = exports.consoleTransport = new winston.transports.Console({
|
|
19
|
+
format: winston.format.simple()
|
|
20
|
+
});
|
|
21
|
+
const logFile = exports.logFile = new winston.transports.File({
|
|
22
|
+
filename: logFileName,
|
|
23
|
+
level: 'info',
|
|
24
|
+
// so we don't store everything else
|
|
25
|
+
format: winston.format.combine(winston.format.timestamp({
|
|
26
|
+
format: 'YYYY-MM-DD HH:mm:ss'
|
|
27
|
+
}), winston.format.errors({
|
|
28
|
+
stack: true
|
|
29
|
+
}), winston.format.splat(), winston.format.json()),
|
|
30
|
+
maxsize: 100000,
|
|
31
|
+
maxFiles: 10,
|
|
32
|
+
tailable: true
|
|
33
|
+
});
|
|
34
|
+
const logger = exports.logger = winston.createLogger({
|
|
35
|
+
transports: [consoleTransport, logFile]
|
|
36
|
+
});
|
|
37
|
+
function haxCliEnvOptions() {
|
|
38
|
+
return ['skip', 'npmClient', 'i', 'extras', 'root', 'path', 'org', 'author'];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// wrapper so we can silence all log messages at the same time
|
|
42
|
+
function log(msg, level = 'info', extra = null) {
|
|
43
|
+
logger.log(level, msg, extra);
|
|
44
|
+
}
|
|
45
|
+
function commandString(commandRun) {
|
|
46
|
+
let comStr = `hax ${commandRun.command} ${commandRun.arguments.action}`;
|
|
47
|
+
for (const key of Object.keys(commandRun.options)) {
|
|
48
|
+
// ignore environment centric calls
|
|
49
|
+
if (!haxCliEnvOptions().includes(key)) {
|
|
50
|
+
if (key === true) {
|
|
51
|
+
comStr += ` --${(0, _utils.camelToDash)(key)}`;
|
|
52
|
+
} else if (key === false) {
|
|
53
|
+
comStr += ` --no-${(0, _utils.camelToDash)(key)}`;
|
|
54
|
+
} else {
|
|
55
|
+
comStr += ` --${(0, _utils.camelToDash)(key)}="${commandRun.options[key]}"`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return comStr;
|
|
60
|
+
}
|
|
@@ -13,11 +13,14 @@ exports.siteProcess = siteProcess;
|
|
|
13
13
|
exports.siteThemeList = siteThemeList;
|
|
14
14
|
var _promises = require("node:timers/promises");
|
|
15
15
|
var fs = _interopRequireWildcard(require("node:fs"));
|
|
16
|
+
var path = _interopRequireWildcard(require("node:path"));
|
|
16
17
|
var p = _interopRequireWildcard(require("@clack/prompts"));
|
|
17
18
|
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
18
19
|
var _jsYaml = require("js-yaml");
|
|
20
|
+
var winston = _interopRequireWildcard(require("winston"));
|
|
19
21
|
var _nodeHtmlParser = require("node-html-parser");
|
|
20
22
|
var _statements = require("../statements.js");
|
|
23
|
+
var _logging = require("../logging.js");
|
|
21
24
|
var _microFrontendRegistry = require("../micro-frontend-registry.js");
|
|
22
25
|
var haxcmsNodejsCli = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs/dist/cli.js"));
|
|
23
26
|
var hax = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs"));
|
|
@@ -42,6 +45,7 @@ exec('surge --version', error => {
|
|
|
42
45
|
sysSurge = false;
|
|
43
46
|
}
|
|
44
47
|
});
|
|
48
|
+
const siteRecipeFile = 'create-cli.recipe';
|
|
45
49
|
|
|
46
50
|
// fake response class so we can capture the response from the headless route as opposed to print to console
|
|
47
51
|
// this way we can handle as data or if use is requesting output format to change we can respond
|
|
@@ -113,13 +117,33 @@ function siteActions() {
|
|
|
113
117
|
}, {
|
|
114
118
|
value: 'site:surge',
|
|
115
119
|
label: "Publish site to Surge.sh"
|
|
120
|
+
}, {
|
|
121
|
+
value: 'recipe:read',
|
|
122
|
+
label: "Read recipe file"
|
|
123
|
+
}, {
|
|
124
|
+
value: 'recipe:play',
|
|
125
|
+
label: "Play recipe file"
|
|
116
126
|
}];
|
|
117
127
|
}
|
|
118
128
|
async function siteCommandDetected(commandRun) {
|
|
119
129
|
var activeHaxsite = await hax.systemStructureContext();
|
|
130
|
+
const recipeFileName = path.join(process.cwd(), siteRecipeFile);
|
|
131
|
+
const recipeLogTransport = new winston.transports.File({
|
|
132
|
+
filename: recipeFileName
|
|
133
|
+
});
|
|
134
|
+
const recipe = winston.createLogger({
|
|
135
|
+
levels: {
|
|
136
|
+
hax: 0
|
|
137
|
+
},
|
|
138
|
+
level: 'hax',
|
|
139
|
+
transports: [recipeLogTransport],
|
|
140
|
+
format: winston.format.simple()
|
|
141
|
+
});
|
|
142
|
+
let actionAssigned = false;
|
|
120
143
|
// default to status unless already set so we don't issue a create in a create
|
|
121
144
|
if (!commandRun.arguments.action) {
|
|
122
|
-
|
|
145
|
+
actionAssigned = true;
|
|
146
|
+
commandRun.arguments.action = 'site:status';
|
|
123
147
|
}
|
|
124
148
|
commandRun.command = "site";
|
|
125
149
|
if (!commandRun.options.y && commandRun.options.i && !commandRun.options.quiet) {
|
|
@@ -169,7 +193,11 @@ async function siteCommandDetected(commandRun) {
|
|
|
169
193
|
}
|
|
170
194
|
});
|
|
171
195
|
}
|
|
196
|
+
if (operation.action) {
|
|
197
|
+
p.intro(`hax site ${_picocolors.default.bold(operation.action)}`);
|
|
198
|
+
}
|
|
172
199
|
switch (operation.action) {
|
|
200
|
+
case "site:status": // easy mistype
|
|
173
201
|
case "site:stats":
|
|
174
202
|
const date = new Date(activeHaxsite.manifest.metadata.site.updated * 1000);
|
|
175
203
|
let siteItems = [];
|
|
@@ -211,9 +239,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
211
239
|
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Last updated: ${siteStats.lastUpdated} `))}`);
|
|
212
240
|
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Tags used: ${JSON.stringify(siteStats.tagUsage, null, 2)} `))}`);
|
|
213
241
|
} else if (commandRun.options.format === 'yaml') {
|
|
214
|
-
(0,
|
|
242
|
+
(0, _logging.log)((0, _jsYaml.dump)(siteStats));
|
|
215
243
|
} else {
|
|
216
|
-
(0,
|
|
244
|
+
(0, _logging.log)(siteStats);
|
|
217
245
|
}
|
|
218
246
|
// simple redirecting to file
|
|
219
247
|
if (commandRun.options.toFile) {
|
|
@@ -246,9 +274,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
246
274
|
fs.writeFileSync(commandRun.options.toFile, contents);
|
|
247
275
|
} else {
|
|
248
276
|
if (commandRun.options.format === 'yaml') {
|
|
249
|
-
(0,
|
|
277
|
+
(0, _logging.log)((0, _jsYaml.dump)(siteitems));
|
|
250
278
|
} else {
|
|
251
|
-
(0,
|
|
279
|
+
(0, _logging.log)(siteitems);
|
|
252
280
|
}
|
|
253
281
|
}
|
|
254
282
|
break;
|
|
@@ -313,10 +341,11 @@ async function siteCommandDetected(commandRun) {
|
|
|
313
341
|
itemIdMap[josImport.items[i].id] = tmpAddedItem.id;
|
|
314
342
|
}
|
|
315
343
|
if (!commandRun.options.quiet) {
|
|
316
|
-
(0,
|
|
344
|
+
(0, _logging.log)(`${josImport.items.length} nodes imported`);
|
|
317
345
|
}
|
|
346
|
+
recipe.log('hax', (0, _logging.commandString)(commandRun));
|
|
318
347
|
} else if (!commandRun.options.quiet) {
|
|
319
|
-
(0,
|
|
348
|
+
(0, _logging.log)('Must specify --item-import as path to valid item export file or URL', 'error');
|
|
320
349
|
}
|
|
321
350
|
break;
|
|
322
351
|
case "start":
|
|
@@ -327,9 +356,10 @@ async function siteCommandDetected(commandRun) {
|
|
|
327
356
|
}
|
|
328
357
|
await exec(`cd ${activeHaxsite.directory} && npx @haxtheweb/haxcms-nodejs`);
|
|
329
358
|
} catch (e) {
|
|
330
|
-
(0,
|
|
359
|
+
(0, _logging.log)(e.stderr);
|
|
331
360
|
}
|
|
332
361
|
break;
|
|
362
|
+
case "node:status": // easy mistype
|
|
333
363
|
case "node:stats":
|
|
334
364
|
try {
|
|
335
365
|
if (!commandRun.options.itemId) {
|
|
@@ -360,9 +390,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
360
390
|
switch (commandRun.options.nodeOp) {
|
|
361
391
|
case 'details':
|
|
362
392
|
if (commandRun.options.format === 'yaml') {
|
|
363
|
-
(0,
|
|
393
|
+
(0, _logging.log)((0, _jsYaml.dump)(page));
|
|
364
394
|
} else {
|
|
365
|
-
(0,
|
|
395
|
+
(0, _logging.log)(page);
|
|
366
396
|
}
|
|
367
397
|
// simple redirecting to file
|
|
368
398
|
if (commandRun.options.toFile) {
|
|
@@ -379,7 +409,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
379
409
|
if (commandRun.options.toFile) {
|
|
380
410
|
fs.writeFileSync(commandRun.options.toFile, itemHTML);
|
|
381
411
|
} else {
|
|
382
|
-
(0,
|
|
412
|
+
(0, _logging.log)(itemHTML);
|
|
383
413
|
}
|
|
384
414
|
break;
|
|
385
415
|
case 'schema':
|
|
@@ -402,9 +432,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
402
432
|
}
|
|
403
433
|
} else {
|
|
404
434
|
if (commandRun.options.format === 'yaml') {
|
|
405
|
-
(0,
|
|
435
|
+
(0, _logging.log)((0, _jsYaml.dump)(els));
|
|
406
436
|
} else {
|
|
407
|
-
(0,
|
|
437
|
+
(0, _logging.log)(els);
|
|
408
438
|
}
|
|
409
439
|
}
|
|
410
440
|
break;
|
|
@@ -416,15 +446,15 @@ async function siteCommandDetected(commandRun) {
|
|
|
416
446
|
if (commandRun.options.toFile) {
|
|
417
447
|
fs.writeFileSync(commandRun.options.toFile, resp.res.data.data);
|
|
418
448
|
} else {
|
|
419
|
-
(0,
|
|
449
|
+
(0, _logging.log)(resp.res.data.data);
|
|
420
450
|
}
|
|
421
451
|
break;
|
|
422
452
|
}
|
|
423
453
|
}
|
|
424
454
|
}
|
|
425
455
|
} catch (e) {
|
|
426
|
-
(0,
|
|
427
|
-
(0,
|
|
456
|
+
(0, _logging.log)(e.stderr);
|
|
457
|
+
(0, _logging.log)(e);
|
|
428
458
|
}
|
|
429
459
|
break;
|
|
430
460
|
case "node:add":
|
|
@@ -495,14 +525,15 @@ async function siteCommandDetected(commandRun) {
|
|
|
495
525
|
createNodeBody.node.contents = locationContent;
|
|
496
526
|
}
|
|
497
527
|
let resp = await haxcmsNodejsCli.cliBridge('createNode', createNodeBody);
|
|
528
|
+
recipe.log('hax', (0, _logging.commandString)(commandRun));
|
|
498
529
|
if (commandRun.options.v) {
|
|
499
|
-
(0,
|
|
530
|
+
(0, _logging.log)(resp.res.data, 'silly');
|
|
500
531
|
}
|
|
501
532
|
if (!commandRun.options.quiet) {
|
|
502
|
-
(0,
|
|
533
|
+
(0, _logging.log)(`"${createNodeBody.node.title}" added to site`, 'info', createNodeBody.node);
|
|
503
534
|
}
|
|
504
535
|
} catch (e) {
|
|
505
|
-
(0,
|
|
536
|
+
(0, _logging.log)(e.stderr);
|
|
506
537
|
}
|
|
507
538
|
break;
|
|
508
539
|
case "node:edit":
|
|
@@ -627,8 +658,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
627
658
|
}
|
|
628
659
|
// if we have content (meaning it's not blank) then try to write the page location
|
|
629
660
|
if (locationContent && (await page.writeLocation(locationContent))) {
|
|
661
|
+
recipe.log('hax', (0, _logging.commandString)(commandRun));
|
|
630
662
|
if (!commandRun.options.quiet) {
|
|
631
|
-
(0,
|
|
663
|
+
(0, _logging.log)(`node:edit success updated page content: "${page.id}`);
|
|
632
664
|
}
|
|
633
665
|
} else {
|
|
634
666
|
console.warn(`node:edit failure to write page content : ${page.id}`);
|
|
@@ -643,14 +675,15 @@ async function siteCommandDetected(commandRun) {
|
|
|
643
675
|
page[commandRun.options.nodeOp] = commandRun.options[commandRun.options.nodeOp];
|
|
644
676
|
}
|
|
645
677
|
let resp = await activeHaxsite.updateNode(page);
|
|
678
|
+
recipe.log('hax', (0, _logging.commandString)(commandRun));
|
|
646
679
|
if (commandRun.options.v) {
|
|
647
|
-
(0,
|
|
680
|
+
(0, _logging.log)(resp, 'silly');
|
|
648
681
|
}
|
|
649
682
|
}
|
|
650
683
|
}
|
|
651
684
|
}
|
|
652
685
|
} catch (e) {
|
|
653
|
-
(0,
|
|
686
|
+
(0, _logging.log)(e.stderr);
|
|
654
687
|
}
|
|
655
688
|
break;
|
|
656
689
|
case "node:delete":
|
|
@@ -686,14 +719,15 @@ async function siteCommandDetected(commandRun) {
|
|
|
686
719
|
if (resp.res.data === 500) {
|
|
687
720
|
console.warn(`node:delete failed "${commandRun.options.itemId} not found`);
|
|
688
721
|
} else {
|
|
689
|
-
(0,
|
|
722
|
+
recipe.log('hax', (0, _logging.commandString)(commandRun));
|
|
723
|
+
(0, _logging.log)(`"${commandRun.options.itemId}" deleted`);
|
|
690
724
|
}
|
|
691
725
|
} else {
|
|
692
|
-
(0,
|
|
726
|
+
(0, _logging.log)(`Delete operation canceled`);
|
|
693
727
|
}
|
|
694
728
|
}
|
|
695
729
|
} catch (e) {
|
|
696
|
-
(0,
|
|
730
|
+
(0, _logging.log)(e.stderr);
|
|
697
731
|
}
|
|
698
732
|
break;
|
|
699
733
|
case "site:sync":
|
|
@@ -701,7 +735,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
701
735
|
try {
|
|
702
736
|
await exec(`cd ${activeHaxsite.directory} && git pull && git push`);
|
|
703
737
|
} catch (e) {
|
|
704
|
-
(0,
|
|
738
|
+
(0, _logging.log)(e.stderr);
|
|
705
739
|
}
|
|
706
740
|
break;
|
|
707
741
|
case "site:theme":
|
|
@@ -721,10 +755,11 @@ async function siteCommandDetected(commandRun) {
|
|
|
721
755
|
if (themes && commandRun.options.theme && themes[commandRun.options.theme]) {
|
|
722
756
|
activeHaxsite.manifest.metadata.theme = themes[commandRun.options.theme];
|
|
723
757
|
activeHaxsite.manifest.save(false);
|
|
758
|
+
recipe.log('hax', (0, _logging.commandString)(commandRun));
|
|
724
759
|
}
|
|
725
760
|
}
|
|
726
761
|
} catch (e) {
|
|
727
|
-
(0,
|
|
762
|
+
(0, _logging.log)(e.stderr);
|
|
728
763
|
}
|
|
729
764
|
break;
|
|
730
765
|
case "site:surge":
|
|
@@ -736,7 +771,7 @@ async function siteCommandDetected(commandRun) {
|
|
|
736
771
|
s.start((0, _statements.merlinSays)('Installing Surge.sh globally so we can publish'));
|
|
737
772
|
let execOutput = await exec(`npm install --global surge`);
|
|
738
773
|
s.stop((0, _statements.merlinSays)('surge.sh installed globally'));
|
|
739
|
-
(0,
|
|
774
|
+
(0, _logging.log)(execOutput.stdout.trim());
|
|
740
775
|
sysSurge = true;
|
|
741
776
|
}
|
|
742
777
|
if (!commandRun.options.domain) {
|
|
@@ -753,10 +788,10 @@ async function siteCommandDetected(commandRun) {
|
|
|
753
788
|
});
|
|
754
789
|
}
|
|
755
790
|
let execOutput = await exec(`cd ${activeHaxsite.directory} && surge . ${commandRun.options.domain}`);
|
|
756
|
-
(0,
|
|
757
|
-
(0,
|
|
791
|
+
(0, _logging.log)(execOutput.stdout.trim());
|
|
792
|
+
(0, _logging.log)(`Site published: https://${commandRun.options.domain}`);
|
|
758
793
|
} catch (e) {
|
|
759
|
-
(0,
|
|
794
|
+
(0, _logging.log)(e.stderr);
|
|
760
795
|
}
|
|
761
796
|
break;
|
|
762
797
|
case "site:file-list":
|
|
@@ -766,9 +801,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
766
801
|
filename: commandRun.options.filename
|
|
767
802
|
}, res);
|
|
768
803
|
if (commandRun.options.format === 'yaml') {
|
|
769
|
-
(0,
|
|
804
|
+
(0, _logging.log)((0, _jsYaml.dump)(res.data));
|
|
770
805
|
} else {
|
|
771
|
-
(0,
|
|
806
|
+
(0, _logging.log)(res.data);
|
|
772
807
|
}
|
|
773
808
|
break;
|
|
774
809
|
case "site:html":
|
|
@@ -811,9 +846,9 @@ async function siteCommandDetected(commandRun) {
|
|
|
811
846
|
}
|
|
812
847
|
} else {
|
|
813
848
|
if (commandRun.options.format === 'yaml') {
|
|
814
|
-
(0,
|
|
849
|
+
(0, _logging.log)((0, _jsYaml.dump)(els));
|
|
815
850
|
} else {
|
|
816
|
-
(0,
|
|
851
|
+
(0, _logging.log)(els);
|
|
817
852
|
}
|
|
818
853
|
}
|
|
819
854
|
} else {
|
|
@@ -829,30 +864,56 @@ async function siteCommandDetected(commandRun) {
|
|
|
829
864
|
if (commandRun.options.toFile) {
|
|
830
865
|
fs.writeFileSync(commandRun.options.toFile, resp.res.data.data);
|
|
831
866
|
if (!commandRun.options.quiet) {
|
|
832
|
-
(0,
|
|
867
|
+
(0, _logging.log)(`${commandRun.options.toFile} written`);
|
|
833
868
|
}
|
|
834
869
|
} else {
|
|
835
|
-
(0,
|
|
870
|
+
(0, _logging.log)(resp.res.data.data);
|
|
836
871
|
}
|
|
837
872
|
} else {
|
|
838
873
|
if (commandRun.options.toFile) {
|
|
839
874
|
fs.writeFileSync(commandRun.options.toFile, siteContent);
|
|
840
875
|
if (!commandRun.options.quiet) {
|
|
841
|
-
(0,
|
|
876
|
+
(0, _logging.log)(`${commandRun.options.toFile} written`);
|
|
842
877
|
}
|
|
843
878
|
} else {
|
|
844
|
-
(0,
|
|
879
|
+
(0, _logging.log)(siteContent);
|
|
845
880
|
}
|
|
846
881
|
}
|
|
847
882
|
}
|
|
848
883
|
break;
|
|
884
|
+
// @todo need to make these work..
|
|
885
|
+
case "recipe:read":
|
|
886
|
+
// just print the recipe out
|
|
887
|
+
if (fs.existsSync(path.join(process.cwd(), `${siteRecipeFile}`))) {
|
|
888
|
+
let recContents = await fs.readFileSync(path.join(process.cwd(), `${siteRecipeFile}`));
|
|
889
|
+
console.log(recContents);
|
|
890
|
+
(0, _logging.log)(recContents);
|
|
891
|
+
}
|
|
892
|
+
break;
|
|
893
|
+
case "recipe:play":
|
|
894
|
+
// step through and run each recipe once fed a file location
|
|
895
|
+
// this allows for storing commands from a site and then replaying them with ease
|
|
896
|
+
if (!commandRun.options.recipe) {
|
|
897
|
+
commandRun.options.recipe = await p.text({
|
|
898
|
+
message: `Select recipe:`,
|
|
899
|
+
defaultValue: process.cwd(),
|
|
900
|
+
initialValue: process.cwd()
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
if (fs.existsSync(commandRun.options.recipe)) {
|
|
904
|
+
let recContents = await fs.readFileSync(commandRun.options.recipe);
|
|
905
|
+
// split into commands
|
|
906
|
+
let commandList = recContents.split('hax: ');
|
|
907
|
+
console.log(commandList);
|
|
908
|
+
}
|
|
909
|
+
break;
|
|
849
910
|
case "quit":
|
|
850
911
|
// quit
|
|
851
912
|
process.exit(0);
|
|
852
913
|
break;
|
|
853
914
|
}
|
|
854
915
|
// y or noi need to act like it ran and finish instead of looping options
|
|
855
|
-
if (commandRun.options.y || !commandRun.options.i) {
|
|
916
|
+
if (commandRun.options.y || !commandRun.options.i || !actionAssigned) {
|
|
856
917
|
process.exit(0);
|
|
857
918
|
}
|
|
858
919
|
operation.action = null;
|
|
@@ -953,6 +1014,7 @@ async function openApiBroker(scope, call, body) {
|
|
|
953
1014
|
async function siteProcess(commandRun, project, port = '3000') {
|
|
954
1015
|
// auto select operations to perform if requested
|
|
955
1016
|
var s = p.spinner();
|
|
1017
|
+
// if we have no extras, or they are empty then set for launch
|
|
956
1018
|
if (!project.extras) {
|
|
957
1019
|
project.extras = [];
|
|
958
1020
|
if (commandRun.options.i) {
|
|
@@ -1080,11 +1142,29 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1080
1142
|
await hax.RoutesMap.post.createSite({
|
|
1081
1143
|
body: siteRequest
|
|
1082
1144
|
}, res);
|
|
1145
|
+
// path different for this one as it's on the fly produced
|
|
1146
|
+
const recipeFileName = path.join(project.path, '/', project.name, `${siteRecipeFile}`);
|
|
1147
|
+
console.log(recipeFileName);
|
|
1148
|
+
const recipeLogTransport = new winston.transports.File({
|
|
1149
|
+
filename: recipeFileName
|
|
1150
|
+
});
|
|
1151
|
+
const recipe = winston.createLogger({
|
|
1152
|
+
levels: {
|
|
1153
|
+
hax: 0
|
|
1154
|
+
},
|
|
1155
|
+
level: 'hax',
|
|
1156
|
+
transports: [recipeLogTransport],
|
|
1157
|
+
format: winston.format.simple()
|
|
1158
|
+
});
|
|
1159
|
+
// matching the common object elsewhere tho different reference in this command since it creates from nothing
|
|
1160
|
+
// capture this if use input on the fly
|
|
1161
|
+
commandRun.options.theme = project.theme;
|
|
1162
|
+
recipe.log('hax', (0, _logging.commandString)(commandRun));
|
|
1083
1163
|
if (commandRun.options.v) {
|
|
1084
1164
|
if (commandRun.options.format === 'yaml') {
|
|
1085
|
-
(0,
|
|
1165
|
+
(0, _logging.log)((0, _jsYaml.dump)(res.data), 'silly');
|
|
1086
1166
|
} else {
|
|
1087
|
-
(0,
|
|
1167
|
+
(0, _logging.log)(res.data, 'silly');
|
|
1088
1168
|
}
|
|
1089
1169
|
}
|
|
1090
1170
|
if (!commandRun.options.quiet) {
|
|
@@ -1098,7 +1178,7 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1098
1178
|
}
|
|
1099
1179
|
// options for install, git and other extras
|
|
1100
1180
|
// can't launch if we didn't install first so launch implies installation
|
|
1101
|
-
if (project.extras.includes('launch')) {
|
|
1181
|
+
if (project.extras && project.extras.includes && project.extras.includes('launch')) {
|
|
1102
1182
|
let optionPath = `${project.path}/${project.name}`;
|
|
1103
1183
|
let command = `npx @haxtheweb/haxcms-nodejs`;
|
|
1104
1184
|
if (!commandRun.options.quiet) {
|
|
@@ -13,6 +13,7 @@ var ejs = _interopRequireWildcard(require("ejs"));
|
|
|
13
13
|
var p = _interopRequireWildcard(require("@clack/prompts"));
|
|
14
14
|
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
15
15
|
var _statements = require("../statements.js");
|
|
16
|
+
var _logging = require("../logging.js");
|
|
16
17
|
var _utils = require("../utils.js");
|
|
17
18
|
var hax = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs"));
|
|
18
19
|
var child_process = _interopRequireWildcard(require("child_process"));
|
|
@@ -150,7 +151,7 @@ async function webcomponentProcess(commandRun, project, port = "8000") {
|
|
|
150
151
|
// values not set by user but used in templating
|
|
151
152
|
project.className = (0, _utils.dashToCamel)(project.name);
|
|
152
153
|
// option to build github repo link for the user
|
|
153
|
-
if (project.extras.includes('git')) {
|
|
154
|
+
if (project.extras && project.extras.includes('git')) {
|
|
154
155
|
// @todo need to support git@ and https methods
|
|
155
156
|
if (commandRun.options.auto) {
|
|
156
157
|
project.gitRepo = `https://github.com/${project.author}/${project.name}.git`;
|
|
@@ -227,7 +228,7 @@ async function webcomponentProcess(commandRun, project, port = "8000") {
|
|
|
227
228
|
}
|
|
228
229
|
// options for install, git and other extras
|
|
229
230
|
// can't launch if we didn't install first so launch implies installation
|
|
230
|
-
if (project.extras.includes('launch') || project.extras.includes('install')) {
|
|
231
|
+
if (project.extras && (project.extras.includes('launch') || project.extras.includes('install'))) {
|
|
231
232
|
s.start((0, _statements.merlinSays)(`Installation magic (${commandRun.options.npmClient} install)`));
|
|
232
233
|
try {
|
|
233
234
|
// monorepos install from top but then still need to launch from local location
|
|
@@ -240,7 +241,7 @@ async function webcomponentProcess(commandRun, project, port = "8000") {
|
|
|
240
241
|
s.stop((0, _statements.merlinSays)(`Everything is installed. It's go time`));
|
|
241
242
|
}
|
|
242
243
|
// autolaunch if default was selected
|
|
243
|
-
if (project.extras.includes('launch')) {
|
|
244
|
+
if (project.extras && project.extras.includes('launch')) {
|
|
244
245
|
let optionPath = `${project.path}/${project.name}`;
|
|
245
246
|
let command = `${commandRun.options.npmClient} start`;
|
|
246
247
|
p.note(`${(0, _statements.merlinSays)(`I have summoned a sub-process daemon 👹`)}
|
|
@@ -331,7 +332,7 @@ async function webcomponentGenerateHAXSchema(commandRun, packageData) {
|
|
|
331
332
|
});
|
|
332
333
|
let wiring = new HAXWiring();
|
|
333
334
|
if (commandRun.options.debug) {
|
|
334
|
-
(0,
|
|
335
|
+
(0, _logging.log)(ceFileData, 'debug');
|
|
335
336
|
}
|
|
336
337
|
if (ceFileData) {
|
|
337
338
|
let ce = JSON.parse(ceFileData);
|
|
@@ -387,10 +388,10 @@ async function webcomponentGenerateHAXSchema(commandRun, packageData) {
|
|
|
387
388
|
}
|
|
388
389
|
});
|
|
389
390
|
if (commandRun.options.v) {
|
|
390
|
-
(0,
|
|
391
|
+
(0, _logging.log)(JSON.stringify(props, null, 2), 'silly');
|
|
391
392
|
}
|
|
392
393
|
fs.writeFileSync(`./lib/${declarations.tagName}.haxProperties.json`, JSON.stringify(props, null, 2));
|
|
393
|
-
(0,
|
|
394
|
+
(0, _logging.log)(`schema written to: ./lib/${declarations.tagName}.haxProperties.json`);
|
|
394
395
|
});
|
|
395
396
|
});
|
|
396
397
|
}
|
package/dist/lib/statements.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.communityStatement = communityStatement;
|
|
7
7
|
exports.haxIntro = haxIntro;
|
|
8
|
-
exports.log = log;
|
|
9
8
|
exports.merlinSays = merlinSays;
|
|
10
9
|
var _art = require("./art.js");
|
|
11
10
|
var p = _interopRequireWildcard(require("@clack/prompts"));
|
|
@@ -14,12 +13,6 @@ var _promises = require("node:timers/promises");
|
|
|
14
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
14
|
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); }
|
|
16
15
|
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
|
-
}
|
|
23
16
|
async function haxIntro() {
|
|
24
17
|
console.clear();
|
|
25
18
|
await (0, _promises.setTimeout)(10);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haxtheweb/create",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.23",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"node-html-parser": "6.1.13",
|
|
52
52
|
"ejs": "3.1.10",
|
|
53
53
|
"js-yaml": "4.1.0",
|
|
54
|
-
"picocolors": "1.0.1"
|
|
54
|
+
"picocolors": "1.0.1",
|
|
55
|
+
"winston": "3.17.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@babel/cli": "^7.24.6",
|