@haxtheweb/create 10.0.2 → 10.0.3
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 +30 -20
- package/dist/lib/logging.js +7 -2
- package/dist/lib/programs/site.js +43 -13
- package/dist/templates/sitetheme/base-theme.js +2 -2
- package/dist/templates/sitetheme/flex-theme.js +2 -2
- package/dist/templates/sitetheme/sidebar-theme.js +2 -2
- package/dist/templates/webcomponent/hax/package.json +2 -2
- package/package.json +1 -1
package/dist/create.js
CHANGED
|
@@ -35,7 +35,7 @@ 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').option('--recipe <char>', 'path to recipe file').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').option('--custom-theme-name <char>', 'custom theme name').option('--custom-theme-template <char>', 'custom theme template; (options: base, polaris-flex, polaris-sidebar)').version(await HAXCMS.getHAXCMSVersion()).helpCommand(true);
|
|
39
39
|
|
|
40
40
|
// default command which runs interactively
|
|
41
41
|
_commander.program.command('start').description('Select which hax sub-program to run').action(() => {
|
|
@@ -61,7 +61,7 @@ async function main() {
|
|
|
61
61
|
commandRun.arguments.action = action;
|
|
62
62
|
commandRun.options.skip = true;
|
|
63
63
|
}
|
|
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());
|
|
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').option('--custom-theme-name <char>', 'custom theme name').option('--custom-theme-template <char>', 'custom theme template (options: base, polaris-flex, polaris-sidebar)').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}`);
|
|
@@ -134,6 +134,10 @@ async function main() {
|
|
|
134
134
|
commandRun.options.author = author;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
+
// validate theme cli commands
|
|
138
|
+
if (commandRun.options.theme !== 'custom-theme' && (commandRun.options.customThemeName || commandRun.options.customThemeTemplate)) {
|
|
139
|
+
_commander.program.error(_picocolors.default.red('ERROR: You can only use the --custom-theme-name option with --theme custom-theme'));
|
|
140
|
+
}
|
|
137
141
|
let packageData = {};
|
|
138
142
|
let testPackages = [path.join(process.cwd(), 'package.json'), path.join(process.cwd(), '../', 'package.json'), path.join(process.cwd(), '../', '../', 'package.json')];
|
|
139
143
|
// test within reason, for package.json files seeing if anything is available to suggest
|
|
@@ -262,6 +266,14 @@ async function main() {
|
|
|
262
266
|
activeProject = project.type;
|
|
263
267
|
// silly but this way we don't have to take options for quitting
|
|
264
268
|
if (project.type !== 'quit') {
|
|
269
|
+
// also silly temp spot
|
|
270
|
+
let themes = await (0, _site.siteThemeList)();
|
|
271
|
+
const custom = {
|
|
272
|
+
value: 'custom-theme',
|
|
273
|
+
label: 'Create Custom Theme'
|
|
274
|
+
};
|
|
275
|
+
// Append custom option to list of core themes
|
|
276
|
+
themes.push(custom);
|
|
265
277
|
project = await p.group({
|
|
266
278
|
type: ({
|
|
267
279
|
results
|
|
@@ -362,12 +374,6 @@ async function main() {
|
|
|
362
374
|
theme: async ({
|
|
363
375
|
results
|
|
364
376
|
}) => {
|
|
365
|
-
let themes = await (0, _site.siteThemeList)();
|
|
366
|
-
let custom = {
|
|
367
|
-
value: 'custom-theme',
|
|
368
|
-
label: 'Create Custom Theme'
|
|
369
|
-
};
|
|
370
|
-
themes.push(custom);
|
|
371
377
|
if (results.type === "site" && !commandRun.options.theme) {
|
|
372
378
|
// support having no theme but autoselecting
|
|
373
379
|
if (commandRun.options.auto && commandRun.options.skip) {
|
|
@@ -382,34 +388,38 @@ async function main() {
|
|
|
382
388
|
}
|
|
383
389
|
}
|
|
384
390
|
},
|
|
385
|
-
|
|
391
|
+
customThemeName: async ({
|
|
386
392
|
results
|
|
387
|
-
}) {
|
|
393
|
+
}) => {
|
|
388
394
|
if (results.theme === "custom-theme") {
|
|
389
|
-
|
|
395
|
+
let tmpCustomName = await p.text({
|
|
390
396
|
message: 'Theme Name:',
|
|
391
|
-
placeholder: results.
|
|
397
|
+
placeholder: `${results.name}`,
|
|
392
398
|
required: false,
|
|
393
399
|
validate: value => {
|
|
394
400
|
if (!value) {
|
|
395
|
-
return "
|
|
401
|
+
return "Theme name is required (tab writes default)";
|
|
402
|
+
}
|
|
403
|
+
if (themes.some(theme => theme.value === value)) {
|
|
404
|
+
return "Theme name is already in use";
|
|
396
405
|
}
|
|
397
406
|
if (/^\d/.test(value)) {
|
|
398
|
-
return "
|
|
407
|
+
return "Theme name cannot start with a number";
|
|
399
408
|
}
|
|
400
|
-
if (value
|
|
401
|
-
return "No
|
|
409
|
+
if (/[A-Z]/.test(value)) {
|
|
410
|
+
return "No uppercase letters allowed in theme name";
|
|
402
411
|
}
|
|
403
|
-
if (value.indexOf('
|
|
404
|
-
return "
|
|
412
|
+
if (value.indexOf(' ') !== -1) {
|
|
413
|
+
return "No spaces allowed in theme name";
|
|
405
414
|
}
|
|
406
415
|
}
|
|
407
416
|
});
|
|
417
|
+
return tmpCustomName;
|
|
408
418
|
}
|
|
409
419
|
},
|
|
410
|
-
|
|
420
|
+
customThemeTemplate: ({
|
|
411
421
|
results
|
|
412
|
-
}) {
|
|
422
|
+
}) => {
|
|
413
423
|
if (results.theme === "custom-theme") {
|
|
414
424
|
const options = [{
|
|
415
425
|
value: 'base',
|
package/dist/lib/logging.js
CHANGED
|
@@ -14,7 +14,12 @@ var winston = _interopRequireWildcard(require("winston"));
|
|
|
14
14
|
var _utils = require("./utils.js");
|
|
15
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
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
|
-
|
|
17
|
+
// check for vercel running which is not allowed to write to home in logs
|
|
18
|
+
let baseLogPath = (0, _nodeOs.homedir)();
|
|
19
|
+
if (process.env.VERCEL_ENV) {
|
|
20
|
+
baseLogPath = "/tmp/";
|
|
21
|
+
}
|
|
22
|
+
const logFileName = path.join(baseLogPath, '.haxtheweb', 'create.log');
|
|
18
23
|
const consoleTransport = exports.consoleTransport = new winston.transports.Console({
|
|
19
24
|
format: winston.format.simple()
|
|
20
25
|
});
|
|
@@ -35,7 +40,7 @@ const logger = exports.logger = winston.createLogger({
|
|
|
35
40
|
transports: [consoleTransport, logFile]
|
|
36
41
|
});
|
|
37
42
|
function haxCliEnvOptions() {
|
|
38
|
-
return ['skip', 'npmClient', 'i', 'extras', 'root', 'path', 'org', 'author', 'y', 'auto'];
|
|
43
|
+
return ['skip', 'npmClient', 'i', 'extras', 'root', 'path', 'org', 'author', 'y', 'auto', 'domain'];
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
// wrapper so we can silence all log messages at the same time
|
|
@@ -1212,10 +1212,10 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
|
|
1214
1214
|
// Write theme template to site/custom
|
|
1215
|
-
if (project.
|
|
1216
|
-
s.start((0, _statements.merlinSays)(`Creating new theme: ${project.
|
|
1215
|
+
if (commandRun.options.theme === 'custom-theme' && commandRun.options.customThemeName && commandRun.options.customThemeTemplate || project.customThemeName && project.customThemeTemplate) {
|
|
1216
|
+
s.start((0, _statements.merlinSays)(`Creating new theme: ${commandRun.options.customThemeName ? commandRun.options.customThemeName : project.customThemeName}`));
|
|
1217
1217
|
await customSiteTheme(commandRun, project);
|
|
1218
|
-
s.stop((0, _statements.merlinSays)(`${project.
|
|
1218
|
+
s.stop((0, _statements.merlinSays)(`${commandRun.options.customThemeName ? commandRun.options.customThemeName : project.customThemeName} theme created!`));
|
|
1219
1219
|
}
|
|
1220
1220
|
if (project.gitRepo && !commandRun.options.isMonorepo) {
|
|
1221
1221
|
try {
|
|
@@ -1281,18 +1281,42 @@ async function siteThemeList() {
|
|
|
1281
1281
|
return items;
|
|
1282
1282
|
}
|
|
1283
1283
|
async function customSiteTheme(commandRun, project) {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
} else if (project.
|
|
1284
|
+
// pass theme name for twig templates
|
|
1285
|
+
project.customThemeName = commandRun.options.customThemeName ? commandRun.options.customThemeName : project.customThemeName;
|
|
1286
|
+
|
|
1287
|
+
// validate start and end tags for theme name
|
|
1288
|
+
if (/^custom/.test(project.customThemeName) && !/^custom-/.test(project.customThemeName)) {
|
|
1289
|
+
project.customThemeName = project.customThemeName.replace(/^custom/, "custom-");
|
|
1290
|
+
} else if (!/^custom-/.test(project.className)) {
|
|
1291
|
+
project.customThemeName = `custom-${project.customThemeName}`;
|
|
1292
|
+
}
|
|
1293
|
+
if (/theme$/.test(project.customThemeName) && !/-theme$/.test(project.customThemeName)) {
|
|
1294
|
+
project.customThemeName = project.customThemeName.replace(/theme$/, "-theme");
|
|
1295
|
+
} else if (!/-theme$/.test(project.customThemeName)) {
|
|
1296
|
+
project.customThemeName = `${project.customThemeName}-theme`;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// set camel case class name
|
|
1300
|
+
project.className = (0, _utils.dashToCamel)(project.customThemeName);
|
|
1301
|
+
|
|
1302
|
+
// path to hax site
|
|
1303
|
+
var sitePath = `${project.path}/${commandRun.options.name ? commandRun.options.name : project.name}`;
|
|
1304
|
+
|
|
1305
|
+
// path to new theme file
|
|
1306
|
+
const filePath = `${sitePath}/custom/src/${project.customThemeName}.js`;
|
|
1307
|
+
|
|
1308
|
+
// theme template to use
|
|
1309
|
+
const themeTemplate = commandRun.options.customThemeTemplate ? commandRun.options.customThemeTemplate : project.customThemeTemplate;
|
|
1310
|
+
if (themeTemplate === "polaris-flex") {
|
|
1291
1311
|
await fs.copyFileSync(`${process.mainModule.path}/templates/sitetheme/flex-theme.js`, `${sitePath}/custom/src/flex-theme.js`);
|
|
1292
1312
|
await fs.renameSync(`${sitePath}/custom/src/flex-theme.js`, filePath);
|
|
1293
|
-
} else if (
|
|
1313
|
+
} else if (themeTemplate === "polaris-sidebar") {
|
|
1294
1314
|
await fs.copyFileSync(`${process.mainModule.path}/templates/sitetheme/sidebar-theme.js`, `${sitePath}/custom/src/sidebar-theme.js`);
|
|
1295
1315
|
await fs.renameSync(`${sitePath}/custom/src/sidebar-theme.js`, filePath);
|
|
1316
|
+
} else {
|
|
1317
|
+
// vanilla theme is default
|
|
1318
|
+
await fs.copyFileSync(`${process.mainModule.path}/templates/sitetheme/base-theme.js`, `${sitePath}/custom/src/base-theme.js`);
|
|
1319
|
+
await fs.renameSync(`${sitePath}/custom/src/base-theme.js`, filePath);
|
|
1296
1320
|
}
|
|
1297
1321
|
try {
|
|
1298
1322
|
// ensure we don't try to pattern rewrite image files
|
|
@@ -1306,15 +1330,21 @@ async function customSiteTheme(commandRun, project) {
|
|
|
1306
1330
|
console.error(filePath);
|
|
1307
1331
|
console.error(err);
|
|
1308
1332
|
}
|
|
1309
|
-
|
|
1333
|
+
|
|
1334
|
+
// import theme to custom.js
|
|
1335
|
+
await fs.appendFileSync(`${sitePath}/custom/src/custom.js`, `\n import "./${project.customThemeName}.js"`);
|
|
1310
1336
|
var activeHaxsite = await hax.systemStructureContext(sitePath);
|
|
1337
|
+
|
|
1338
|
+
// add theme to site.json
|
|
1311
1339
|
let themeObj = {
|
|
1312
|
-
element: project.
|
|
1340
|
+
element: project.customThemeName,
|
|
1313
1341
|
path: filePath,
|
|
1314
1342
|
name: project.className
|
|
1315
1343
|
};
|
|
1316
1344
|
activeHaxsite.manifest.metadata.theme = themeObj;
|
|
1317
1345
|
activeHaxsite.manifest.save(false);
|
|
1346
|
+
|
|
1347
|
+
// install and build theme dependencies
|
|
1318
1348
|
await exec(`cd ${sitePath}/custom/ && ${commandRun.options.npmClient} install && ${commandRun.options.npmClient} run build && cd ${sitePath}`);
|
|
1319
1349
|
}
|
|
1320
1350
|
|
|
@@ -14,7 +14,7 @@ import { html, css, HAXCMSLitElementTheme } from "@haxtheweb/haxcms-elements/lib
|
|
|
14
14
|
* - HAXCMSTheme - A super class that provides correct baseline wiring to build a new theme
|
|
15
15
|
*
|
|
16
16
|
* @demo demo/index.html
|
|
17
|
-
* @element <%=
|
|
17
|
+
* @element <%= customThemeName %>
|
|
18
18
|
*/
|
|
19
19
|
class <%= className %> extends HAXCMSLitElementTheme {
|
|
20
20
|
//styles function
|
|
@@ -34,7 +34,7 @@ class <%= className %> extends HAXCMSLitElementTheme {
|
|
|
34
34
|
* @notice function name must be here for tooling to operate correctly
|
|
35
35
|
*/
|
|
36
36
|
static get tag() {
|
|
37
|
-
return "<%=
|
|
37
|
+
return "<%= customThemeName %>";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
constructor() {
|
|
@@ -16,7 +16,7 @@ import "@haxtheweb/haxcms-elements/lib/ui-components/blocks/site-children-block.
|
|
|
16
16
|
* - HAXCMSTheme - A super class that provides correct baseline wiring to build a new theme
|
|
17
17
|
*
|
|
18
18
|
* @demo demo/index.html
|
|
19
|
-
* @element <%=
|
|
19
|
+
* @element <%= customThemeName %>
|
|
20
20
|
*/
|
|
21
21
|
class <%= className %> extends PolarisFlexTheme {
|
|
22
22
|
//styles function
|
|
@@ -55,7 +55,7 @@ class <%= className %> extends PolarisFlexTheme {
|
|
|
55
55
|
* @notice function name must be here for tooling to operate correctly
|
|
56
56
|
*/
|
|
57
57
|
static get tag() {
|
|
58
|
-
return "<%=
|
|
58
|
+
return "<%= customThemeName %>";
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
constructor() {
|
|
@@ -16,7 +16,7 @@ import "@haxtheweb/haxcms-elements/lib/ui-components/blocks/site-children-block.
|
|
|
16
16
|
* - HAXCMSTheme - A super class that provides correct baseline wiring to build a new theme
|
|
17
17
|
*
|
|
18
18
|
* @demo demo/index.html
|
|
19
|
-
* @element <%=
|
|
19
|
+
* @element <%= customThemeName %>
|
|
20
20
|
*/
|
|
21
21
|
class <%= className %> extends PolarisFlexTheme {
|
|
22
22
|
//styles function
|
|
@@ -101,7 +101,7 @@ class <%= className %> extends PolarisFlexTheme {
|
|
|
101
101
|
* @notice function name must be here for tooling to operate correctly
|
|
102
102
|
*/
|
|
103
103
|
static get tag() {
|
|
104
|
-
return "<%=
|
|
104
|
+
return "<%= customThemeName %>";
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
constructor() {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"lit": "^3.2.1",
|
|
31
|
-
"@haxtheweb/d-d-d": "^10.0.
|
|
32
|
-
"@haxtheweb/i18n-manager": "^10.0.
|
|
31
|
+
"@haxtheweb/d-d-d": "^10.0.2",
|
|
32
|
+
"@haxtheweb/i18n-manager": "^10.0.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@babel/preset-env": "^7.16.4",
|