@haxtheweb/create 10.0.8 → 11.0.0
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/README.md +65 -62
- package/dist/create.js +203 -31
- package/dist/lib/programs/audit.js +3 -3
- package/dist/lib/programs/party.js +332 -0
- package/dist/lib/programs/site.js +209 -45
- package/dist/lib/programs/webcomponent.js +83 -18
- package/dist/lib/utils.js +76 -1
- package/dist/lib/wc-registry.json +1 -1
- package/dist/templates/generic/sitecomponent.js +64 -0
- package/dist/templates/generic/webcomponent.js +3 -37
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -31,65 +31,73 @@ Usage: hax [options] [command]
|
|
|
31
31
|
|
|
32
32
|
Options:
|
|
33
33
|
--
|
|
34
|
-
--v
|
|
35
|
-
--debug
|
|
36
|
-
--format <char>
|
|
37
|
-
--path <char>
|
|
38
|
-
--
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
--
|
|
42
|
-
--
|
|
43
|
-
--
|
|
44
|
-
--
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
--
|
|
48
|
-
--
|
|
49
|
-
|
|
50
|
-
--
|
|
51
|
-
--
|
|
52
|
-
--
|
|
53
|
-
--
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
--
|
|
65
|
-
--
|
|
66
|
-
--
|
|
67
|
-
--
|
|
68
|
-
--
|
|
69
|
-
--
|
|
70
|
-
--
|
|
71
|
-
--custom-theme-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
--
|
|
75
|
-
--
|
|
76
|
-
--
|
|
77
|
-
--
|
|
78
|
-
--
|
|
79
|
-
--
|
|
80
|
-
--
|
|
81
|
-
--
|
|
82
|
-
--
|
|
83
|
-
|
|
34
|
+
--v Verbose output
|
|
35
|
+
--debug Output for developers
|
|
36
|
+
--format <char> Output format; json (default), yaml
|
|
37
|
+
--path <char> where to perform operation
|
|
38
|
+
--name <char> name of the project/web component
|
|
39
|
+
--npm-client <char> npm client to use (must be installed)
|
|
40
|
+
npm, yarn, pnpm (default: "npm")
|
|
41
|
+
--y yes to all questions
|
|
42
|
+
--skip skip frills like animations
|
|
43
|
+
--quiet remove console logging
|
|
44
|
+
--auto yes to all questions, alias of y
|
|
45
|
+
--no-i prevent interactions / sub-process, good
|
|
46
|
+
for scripting
|
|
47
|
+
--to-file <char> redirect command output to a file
|
|
48
|
+
--no-extras skip all extra / automatic command
|
|
49
|
+
processing
|
|
50
|
+
--root <char> root location to execute the command from
|
|
51
|
+
--org <char> organization for package.json
|
|
52
|
+
--author <char> author for site / package.json
|
|
53
|
+
--writeHaxProperties Write haxProperties for the element
|
|
54
|
+
--import-site <char> URL of site to import
|
|
55
|
+
--import-structure <char> import method to use:
|
|
56
|
+
pressbooksToSite
|
|
57
|
+
elmslnToSite
|
|
58
|
+
haxcmsToSite
|
|
59
|
+
notionToSite
|
|
60
|
+
gitbookToSite
|
|
61
|
+
evolutionToSite
|
|
62
|
+
htmlToSite
|
|
63
|
+
docxToSite
|
|
64
|
+
--node-op <char> node operation to perform
|
|
65
|
+
--item-id <char> node ID to operate on
|
|
66
|
+
--domain <char> published domain name
|
|
67
|
+
--title-scrape <char> CSS Selector for `title` in resource
|
|
68
|
+
--content-scrape <char> CSS Selector for `body` in resource
|
|
69
|
+
--items-import <char> import items from a file / site
|
|
70
|
+
--recipe <char> path to recipe file
|
|
71
|
+
--custom-theme-name <char> custom theme name
|
|
72
|
+
--custom-theme-template <char> custom theme template; (options: base,
|
|
73
|
+
polaris-flex, polaris-sidebar)
|
|
74
|
+
--repos <char...> repositories to clone
|
|
75
|
+
-V, --version output the version number
|
|
76
|
+
--title <char> Title
|
|
77
|
+
--content <char> Page content
|
|
78
|
+
--slug <char> Path (slug)
|
|
79
|
+
--published <char> Publishing status
|
|
80
|
+
--tags <char> Tags
|
|
81
|
+
--parent <char> Parent
|
|
82
|
+
--order <char> Order
|
|
83
|
+
--theme <char> Theme
|
|
84
|
+
--hide-in-menu <char> Hide in menu
|
|
85
|
+
-h, --help display help for command
|
|
84
86
|
|
|
85
87
|
Commands:
|
|
86
|
-
start
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
start Select which hax sub-program to run
|
|
89
|
+
update [options] hax cli self update
|
|
90
|
+
serve Launch HAXsite in development mode
|
|
91
|
+
(http://localhost)
|
|
92
|
+
site [options] [action] create or administer a HAXsite
|
|
93
|
+
wc|webcomponent [options] [action] Create Lit based web components, with HAX
|
|
94
|
+
recommendations
|
|
95
|
+
audit [options] Audits web components for compliance with
|
|
96
|
+
DDD (HAX design system)
|
|
97
|
+
party [options] [action] Party time! Join the HAX community and
|
|
98
|
+
get involved!
|
|
99
|
+
help [command] display help for command
|
|
100
|
+
|
|
93
101
|
```
|
|
94
102
|
## Examples
|
|
95
103
|
For a detailed list of example commands that you can perform with `hax` see [examples](examples.md).
|
|
@@ -106,11 +114,6 @@ Run `man hax` to get detailed manual.
|
|
|
106
114
|
npx @haxtheweb/create
|
|
107
115
|
# this is same as above, better windows CLI support
|
|
108
116
|
npm init @haxtheweb
|
|
109
|
-
- Try Hax: https://hax.cloud
|
|
110
|
-
- HAXCellence https://haxtheweb.org/what-is-hax
|
|
111
|
-
"scripts": {
|
|
112
|
-
"hax": "hax"
|
|
113
|
-
}
|
|
114
117
|
```
|
|
115
118
|
|
|
116
119
|
```bash
|
package/dist/create.js
CHANGED
|
@@ -9,12 +9,11 @@ var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
|
9
9
|
var _statements = require("./lib/statements.js");
|
|
10
10
|
var _logging = require("./lib/logging.js");
|
|
11
11
|
var _audit = require("./lib/programs/audit.js");
|
|
12
|
+
var _party = require("./lib/programs/party.js");
|
|
12
13
|
var _webcomponent = require("./lib/programs/webcomponent.js");
|
|
13
14
|
var _site = require("./lib/programs/site.js");
|
|
14
15
|
var _utils = require("./lib/utils.js");
|
|
15
16
|
var hax = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs"));
|
|
16
|
-
var child_process = _interopRequireWildcard(require("child_process"));
|
|
17
|
-
var util = _interopRequireWildcard(require("node:util"));
|
|
18
17
|
var _commander = require("commander");
|
|
19
18
|
var _package = _interopRequireDefault(require("../package.json"));
|
|
20
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -22,9 +21,19 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
22
21
|
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; }
|
|
23
22
|
process.env.haxcms_middleware = "node-cli";
|
|
24
23
|
const HAXCMS = hax.HAXCMS;
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
// check the last time this was run
|
|
26
|
+
let lastTime = (0, _utils.readConfigFile)('hax-cli-last-run');
|
|
27
|
+
// first run in the event it is null assume now
|
|
28
|
+
if (!lastTime) {
|
|
29
|
+
lastTime = new Date().toISOString();
|
|
30
|
+
}
|
|
31
|
+
// check time difference broken down by unit
|
|
32
|
+
const timeSince = (0, _utils.getTimeDifference)(new Date().toISOString(), lastTime);
|
|
33
|
+
// write last run so that we know last time they were here
|
|
34
|
+
(0, _utils.writeConfigFile)('hax-cli-last-run', new Date().toISOString());
|
|
26
35
|
let sysGit = true;
|
|
27
|
-
exec('git
|
|
36
|
+
(0, _utils.exec)('which git', error => {
|
|
28
37
|
if (error) {
|
|
29
38
|
sysGit = false;
|
|
30
39
|
}
|
|
@@ -46,7 +55,10 @@ async function main() {
|
|
|
46
55
|
.option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element')
|
|
47
56
|
|
|
48
57
|
// options for site
|
|
49
|
-
.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('--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)')
|
|
58
|
+
.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('--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)')
|
|
59
|
+
|
|
60
|
+
// options for party
|
|
61
|
+
.option('--repos <char...>', 'repositories to clone').version(_package.default.version).helpCommand(true);
|
|
50
62
|
|
|
51
63
|
// default command which runs interactively
|
|
52
64
|
_commander.program.command('start').description('Select which hax sub-program to run').action(() => {
|
|
@@ -56,6 +68,22 @@ async function main() {
|
|
|
56
68
|
options: {}
|
|
57
69
|
};
|
|
58
70
|
});
|
|
71
|
+
_commander.program.command('update').description('hax cli self update').option('--y', 'yes to all questions').action(() => {
|
|
72
|
+
commandRun = {
|
|
73
|
+
command: 'update',
|
|
74
|
+
arguments: {},
|
|
75
|
+
options: {}
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
_commander.program.command('serve').description('Launch HAXsite in development mode (http://localhost)').action(() => {
|
|
79
|
+
commandRun = {
|
|
80
|
+
command: 'serve',
|
|
81
|
+
arguments: {
|
|
82
|
+
action: 'serve'
|
|
83
|
+
},
|
|
84
|
+
options: {}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
59
87
|
|
|
60
88
|
// site operations and actions
|
|
61
89
|
let strActions = '';
|
|
@@ -105,6 +133,17 @@ async function main() {
|
|
|
105
133
|
options: {}
|
|
106
134
|
};
|
|
107
135
|
}).option('--debug', 'Output for developers').version(_package.default.version);
|
|
136
|
+
_commander.program.command('party').description('Party time! Join the HAX community and get involved!').argument('[action]', 'Actions to perform on web component include:' + "\n\r" + "test").action(action => {
|
|
137
|
+
commandRun = {
|
|
138
|
+
command: 'party',
|
|
139
|
+
arguments: {},
|
|
140
|
+
options: {}
|
|
141
|
+
};
|
|
142
|
+
if (action) {
|
|
143
|
+
commandRun.arguments.action = action;
|
|
144
|
+
commandRun.options.skip = true;
|
|
145
|
+
}
|
|
146
|
+
}).option('--root <char>', 'root location to execute the command from').option('--y', 'yes to all questions').option('--auto', 'yes to all questions, alias of y').option('--repos <char...>', 'repositories to clone').version(_package.default.version);
|
|
108
147
|
|
|
109
148
|
// process program arguments
|
|
110
149
|
_commander.program.parse();
|
|
@@ -140,7 +179,7 @@ async function main() {
|
|
|
140
179
|
let author = '';
|
|
141
180
|
// should be able to grab if not predefined
|
|
142
181
|
try {
|
|
143
|
-
let value = await exec(`git config user.name`);
|
|
182
|
+
let value = await (0, _utils.exec)(`git config user.name`);
|
|
144
183
|
author = value.stdout.trim();
|
|
145
184
|
} catch (e) {
|
|
146
185
|
(0, _logging.log)(`
|
|
@@ -214,26 +253,61 @@ async function main() {
|
|
|
214
253
|
if (commandRun.options.debug) {
|
|
215
254
|
(0, _logging.log)(packageData, 'debug');
|
|
216
255
|
}
|
|
217
|
-
//
|
|
218
|
-
if (
|
|
219
|
-
commandRun
|
|
220
|
-
commandRun.options.skip = true;
|
|
221
|
-
await (0, _site.siteCommandDetected)(commandRun);
|
|
256
|
+
// test for updating to latest or just run the command
|
|
257
|
+
if (commandRun.command === "update") {
|
|
258
|
+
await testForUpdates(commandRun);
|
|
222
259
|
} else if (commandRun.command === 'audit') {
|
|
223
|
-
|
|
260
|
+
let customPath = null;
|
|
261
|
+
// test for haxcms context
|
|
262
|
+
if ((await hax.systemStructureContext()) && fs.existsSync(`${process.cwd()}/custom`)) {
|
|
263
|
+
customPath = path.join(process.cwd(), 'custom');
|
|
264
|
+
}
|
|
265
|
+
(0, _audit.auditCommandDetected)(commandRun, customPath);
|
|
266
|
+
} else if (commandRun.command === 'party') {
|
|
267
|
+
await (0, _party.partyCommandDetected)(commandRun);
|
|
268
|
+
}
|
|
269
|
+
// CLI works within context of the site if one is detected, otherwise we can do other things
|
|
270
|
+
else if (await hax.systemStructureContext()) {
|
|
271
|
+
if (commandRun.command === 'serve') {
|
|
272
|
+
commandRun.program = 'serve';
|
|
273
|
+
commandRun.options.skip = true;
|
|
274
|
+
await (0, _site.siteCommandDetected)(commandRun);
|
|
275
|
+
} else {
|
|
276
|
+
commandRun.program = 'site';
|
|
277
|
+
commandRun.options.skip = true;
|
|
278
|
+
await (0, _site.siteCommandDetected)(commandRun);
|
|
279
|
+
}
|
|
224
280
|
} else if (packageData && (packageData.customElements || packageData.hax && packageData.hax.cli) && packageData.scripts.start) {
|
|
225
|
-
commandRun.
|
|
226
|
-
|
|
227
|
-
|
|
281
|
+
if (commandRun.command === 'serve') {
|
|
282
|
+
commandRun.program = 'serve';
|
|
283
|
+
commandRun.options.skip = true;
|
|
284
|
+
await (0, _webcomponent.webcomponentCommandDetected)(commandRun, packageData);
|
|
285
|
+
} else {
|
|
286
|
+
commandRun.program = 'webcomponent';
|
|
287
|
+
commandRun.options.skip = true;
|
|
288
|
+
await (0, _webcomponent.webcomponentCommandDetected)(commandRun, packageData);
|
|
289
|
+
}
|
|
228
290
|
} else {
|
|
229
291
|
if (commandRun.command === 'start' && !commandRun.options.y && !commandRun.options.auto && !commandRun.options.skip && !commandRun.options.quiet) {
|
|
230
292
|
await (0, _statements.haxIntro)();
|
|
231
293
|
}
|
|
294
|
+
// it's been 7 days since last check, do the check and offer command to resolve if needed
|
|
295
|
+
if (timeSince.days > 7) {
|
|
296
|
+
// check for updates
|
|
297
|
+
let execOut = await (0, _utils.exec)(`npm view @haxtheweb/create version`);
|
|
298
|
+
let updateCheck = execOut.stdout.trim();
|
|
299
|
+
if (updateCheck !== _package.default.version && !commandRun.options.quiet) {
|
|
300
|
+
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAX cli updates available! `))}`);
|
|
301
|
+
p.intro(`Current version: ${_package.default.version}`);
|
|
302
|
+
p.intro(`Latest version: ${updateCheck}`);
|
|
303
|
+
p.intro(`Run ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgGreen('hax update')))} to update to the latest version`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
232
306
|
let activeProject = null;
|
|
233
307
|
let project = {
|
|
234
308
|
type: null
|
|
235
309
|
};
|
|
236
|
-
while (project.type !== 'quit') {
|
|
310
|
+
while (project.type !== 'quit' && project.type !== 'update') {
|
|
237
311
|
if (activeProject) {
|
|
238
312
|
if (!commandRun.options.quiet) {
|
|
239
313
|
p.note(` 🧙🪄 BE GONE ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgGreen(activeProject)))} sub-process daemon! 🪄 + ✨ 👹 = 💀 `);
|
|
@@ -257,6 +331,22 @@ async function main() {
|
|
|
257
331
|
type: commandRun.command
|
|
258
332
|
};
|
|
259
333
|
} else if (commandRun.options.i) {
|
|
334
|
+
let buildOptions = [{
|
|
335
|
+
value: 'webcomponent',
|
|
336
|
+
label: '🏗️ Create a Web Component'
|
|
337
|
+
}, {
|
|
338
|
+
value: 'site',
|
|
339
|
+
label: '🏡 Create a HAXsite'
|
|
340
|
+
}, {
|
|
341
|
+
value: 'party',
|
|
342
|
+
label: '🎉 Join the HAX community'
|
|
343
|
+
}, {
|
|
344
|
+
value: 'update',
|
|
345
|
+
label: '🤓 Check for hax cli updates'
|
|
346
|
+
}, {
|
|
347
|
+
value: 'quit',
|
|
348
|
+
label: '🚪 Quit'
|
|
349
|
+
}];
|
|
260
350
|
project = await p.group({
|
|
261
351
|
type: ({
|
|
262
352
|
results
|
|
@@ -264,21 +354,12 @@ async function main() {
|
|
|
264
354
|
message: !activeProject ? `What should we build?` : `Thirsty for more? What should we create now?`,
|
|
265
355
|
initialValue: 'webcomponent',
|
|
266
356
|
required: true,
|
|
267
|
-
options:
|
|
268
|
-
value: 'webcomponent',
|
|
269
|
-
label: '🏗️ Create a Web Component'
|
|
270
|
-
}, {
|
|
271
|
-
value: 'site',
|
|
272
|
-
label: '🏡 Create a HAXsite'
|
|
273
|
-
}, {
|
|
274
|
-
value: 'quit',
|
|
275
|
-
label: '🚪 Quit'
|
|
276
|
-
}]
|
|
357
|
+
options: buildOptions
|
|
277
358
|
})
|
|
278
359
|
}, {
|
|
279
360
|
onCancel: () => {
|
|
280
361
|
if (!commandRun.options.quiet) {
|
|
281
|
-
p.cancel('🧙🪄 Merlin:
|
|
362
|
+
p.cancel('🧙🪄 Merlin: Canceling cli.. HAX ya later');
|
|
282
363
|
(0, _statements.communityStatement)();
|
|
283
364
|
}
|
|
284
365
|
process.exit(0);
|
|
@@ -287,9 +368,14 @@ async function main() {
|
|
|
287
368
|
} else if (!commandRun.options.i) {
|
|
288
369
|
process.exit(0);
|
|
289
370
|
}
|
|
371
|
+
if (project.type === "update") {
|
|
372
|
+
await testForUpdates(commandRun);
|
|
373
|
+
} else if (project.type === "party") {
|
|
374
|
+
await (0, _party.partyCommandDetected)(commandRun);
|
|
375
|
+
}
|
|
290
376
|
// detect being in a haxcms scaffold. easiest way is _sites being in this directory
|
|
291
377
|
// set the path automatically so we skip the question
|
|
292
|
-
if (commandRun.command === "site" && fs.existsSync(`${process.cwd()}/_sites`)) {
|
|
378
|
+
else if (commandRun.command === "site" && fs.existsSync(`${process.cwd()}/_sites`)) {
|
|
293
379
|
if (!commandRun.options.quiet) {
|
|
294
380
|
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXcms detected : Path set automatically `))}`);
|
|
295
381
|
}
|
|
@@ -297,7 +383,7 @@ async function main() {
|
|
|
297
383
|
}
|
|
298
384
|
activeProject = project.type;
|
|
299
385
|
// silly but this way we don't have to take options for quitting
|
|
300
|
-
if (project.type
|
|
386
|
+
if (['site', 'webcomponent'].includes(project.type)) {
|
|
301
387
|
// global spot for core themes list
|
|
302
388
|
let coreThemes = await (0, _site.siteThemeList)(true);
|
|
303
389
|
project = await p.group({
|
|
@@ -331,6 +417,7 @@ async function main() {
|
|
|
331
417
|
name: ({
|
|
332
418
|
results
|
|
333
419
|
}) => {
|
|
420
|
+
const reservedNames = ["annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph"];
|
|
334
421
|
if (!commandRun.arguments.action) {
|
|
335
422
|
let placeholder = "mysite";
|
|
336
423
|
let message = "Site name:";
|
|
@@ -346,12 +433,18 @@ async function main() {
|
|
|
346
433
|
if (!value) {
|
|
347
434
|
return "Name is required (tab writes default)";
|
|
348
435
|
}
|
|
436
|
+
if (reservedNames.includes(value)) {
|
|
437
|
+
return `Reserved name ${_picocolors.default.bold(value)} cannot be used`;
|
|
438
|
+
}
|
|
349
439
|
if (value.toLocaleLowerCase() !== value) {
|
|
350
440
|
return "Name must be lowercase";
|
|
351
441
|
}
|
|
352
442
|
if (/^\d/.test(value)) {
|
|
353
443
|
return "Name cannot start with a number";
|
|
354
444
|
}
|
|
445
|
+
if (/[`~!@#$%^&*()_=+\[\]{}|;:\'",<.>\/?\\]/.test(value)) {
|
|
446
|
+
return "No special characters allowed in name";
|
|
447
|
+
}
|
|
355
448
|
if (value.indexOf(' ') !== -1) {
|
|
356
449
|
return "No spaces allowed in name";
|
|
357
450
|
}
|
|
@@ -362,6 +455,10 @@ async function main() {
|
|
|
362
455
|
if (results.type === "webcomponent" && wcReg[value]) {
|
|
363
456
|
return "Name is already a web component in the wc-registry published for HAX.";
|
|
364
457
|
}
|
|
458
|
+
// Check for any other syntax errors
|
|
459
|
+
if (results.type === "webcomponent" && !/^[a-z][a-z0-9.\-]*\-[a-z0-9.\-]*$/.test(value)) {
|
|
460
|
+
return `Name must follow the syntax ${_picocolors.default.bold("my-component")}`;
|
|
461
|
+
}
|
|
365
462
|
// assumes auto was selected in CLI
|
|
366
463
|
let joint = process.cwd();
|
|
367
464
|
if (commandRun.options.path) {
|
|
@@ -381,12 +478,17 @@ async function main() {
|
|
|
381
478
|
_commander.program.error(_picocolors.default.red("Name is required (tab writes default)"));
|
|
382
479
|
process.exit(1);
|
|
383
480
|
}
|
|
481
|
+
if (reservedNames.includes(value)) {
|
|
482
|
+
_commander.program.error(_picocolors.default.red(`Reserved name ${_picocolors.default.bold(value)} cannot be used`));
|
|
483
|
+
process.exit(1);
|
|
484
|
+
}
|
|
384
485
|
if (value.toLocaleLowerCase() !== value) {
|
|
385
486
|
_commander.program.error(_picocolors.default.red("Name must be lowercase"));
|
|
386
487
|
process.exit(1);
|
|
387
488
|
}
|
|
388
489
|
if (/^\d/.test(value)) {
|
|
389
490
|
_commander.program.error(_picocolors.default.red("Name cannot start with a number"));
|
|
491
|
+
process.exit(1);
|
|
390
492
|
}
|
|
391
493
|
if (value.indexOf(' ') !== -1) {
|
|
392
494
|
_commander.program.error(_picocolors.default.red("No spaces allowed in name"));
|
|
@@ -401,6 +503,11 @@ async function main() {
|
|
|
401
503
|
_commander.program.error(_picocolors.default.red("Name is already a web component in the wc-registry published for HAX."));
|
|
402
504
|
process.exit(1);
|
|
403
505
|
}
|
|
506
|
+
// Check for any other syntax errors
|
|
507
|
+
if (results.type === "webcomponent" && !/^[a-z][a-z0-9.\-]*\-[a-z0-9.\-]*$/.test(value)) {
|
|
508
|
+
_commander.program.error(_picocolors.default.red(`Name must follow the syntax ${_picocolors.default.bold("my-component")}`));
|
|
509
|
+
process.exit(1);
|
|
510
|
+
}
|
|
404
511
|
// assumes auto was selected in CLI
|
|
405
512
|
let joint = process.cwd();
|
|
406
513
|
if (commandRun.options.path) {
|
|
@@ -577,7 +684,7 @@ async function main() {
|
|
|
577
684
|
}, {
|
|
578
685
|
onCancel: () => {
|
|
579
686
|
if (!commandRun.options.quiet) {
|
|
580
|
-
p.cancel('🧙🪄 Merlin: Canceling
|
|
687
|
+
p.cancel('🧙🪄 Merlin: Canceling cli.. HAX ya later');
|
|
581
688
|
(0, _statements.communityStatement)();
|
|
582
689
|
}
|
|
583
690
|
process.exit(0);
|
|
@@ -626,9 +733,74 @@ async function main() {
|
|
|
626
733
|
}
|
|
627
734
|
}
|
|
628
735
|
}
|
|
629
|
-
if (!commandRun.options.quiet) {
|
|
736
|
+
if (!commandRun.options.quiet && project.type !== 'update') {
|
|
630
737
|
(0, _statements.communityStatement)();
|
|
631
738
|
}
|
|
632
739
|
}
|
|
633
740
|
}
|
|
741
|
+
|
|
742
|
+
// check for updates
|
|
743
|
+
async function testForUpdates(commandRun) {
|
|
744
|
+
let execOut = await (0, _utils.exec)(`npm view @haxtheweb/create version`);
|
|
745
|
+
let latest = execOut.stdout.trim();
|
|
746
|
+
if (latest !== _package.default.version) {
|
|
747
|
+
if (!commandRun.options.quiet) {
|
|
748
|
+
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAX cli updates available! `))}`);
|
|
749
|
+
p.intro(`Current version: ${_package.default.version}`);
|
|
750
|
+
p.intro(`Latest version: ${latest}`);
|
|
751
|
+
}
|
|
752
|
+
let runUpdates = {
|
|
753
|
+
answer: false
|
|
754
|
+
};
|
|
755
|
+
if (!commandRun.options.y) {
|
|
756
|
+
runUpdates = await p.group({
|
|
757
|
+
answer: ({
|
|
758
|
+
results
|
|
759
|
+
}) => p.confirm({
|
|
760
|
+
message: `Do you want to update the cli to the latest version? (${latest})`,
|
|
761
|
+
initialValue: true
|
|
762
|
+
})
|
|
763
|
+
}, {
|
|
764
|
+
onCancel: () => {
|
|
765
|
+
if (!commandRun.options.quiet) {
|
|
766
|
+
p.cancel('🧙🪄 Merlin: Leaving so soon? HAX ya later');
|
|
767
|
+
p.outro(`
|
|
768
|
+
🧙 Upgrade at any time: ${_picocolors.default.yellow('npm install --global @haxtheweb/create')}
|
|
769
|
+
|
|
770
|
+
💡 ${_picocolors.default.bold(_picocolors.default.white(`Never. Stop. Innovating.`))}
|
|
771
|
+
`);
|
|
772
|
+
}
|
|
773
|
+
process.exit(0);
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
} else {
|
|
777
|
+
runUpdates.answer = true; // automatic
|
|
778
|
+
}
|
|
779
|
+
// ensure they wanted to run them
|
|
780
|
+
if (runUpdates.answer) {
|
|
781
|
+
await (0, _utils.interactiveExec)('npm', ['install', '--global', '@haxtheweb/create']);
|
|
782
|
+
if (!commandRun.options.quiet) {
|
|
783
|
+
p.outro(`
|
|
784
|
+
🔮 HAX CLI updated to : ${_picocolors.default.yellow(latest)}
|
|
785
|
+
|
|
786
|
+
🧙 Type ${_picocolors.default.yellow('hax help')} for latest commands
|
|
787
|
+
|
|
788
|
+
💡 ${_picocolors.default.bold(_picocolors.default.white(`Never. Stop. Innovating.`))}
|
|
789
|
+
`);
|
|
790
|
+
}
|
|
791
|
+
} else {
|
|
792
|
+
if (!commandRun.options.quiet) {
|
|
793
|
+
p.outro(`
|
|
794
|
+
🧙 Upgrade at any time: ${_picocolors.default.yellow('npm install --global @haxtheweb/create')}
|
|
795
|
+
|
|
796
|
+
💡 ${_picocolors.default.bold(_picocolors.default.white(`Never. Stop. Innovating.`))}
|
|
797
|
+
`);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
} else {
|
|
801
|
+
if (!commandRun.options.quiet) {
|
|
802
|
+
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAX CLI (${_package.default.version}) is up to date `))}`);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
634
806
|
main().catch(console.error);
|
|
@@ -17,8 +17,8 @@ let checksPassed = true;
|
|
|
17
17
|
/**
|
|
18
18
|
* @description Runs the audit command, to be called when `hax audit` command is run
|
|
19
19
|
*/
|
|
20
|
-
function auditCommandDetected(commandRun) {
|
|
21
|
-
const PROJECT_ROOT = process.cwd();
|
|
20
|
+
function auditCommandDetected(commandRun, path = null) {
|
|
21
|
+
const PROJECT_ROOT = path || process.cwd();
|
|
22
22
|
p.intro(`${_picocolors.default.bgBlack(` 🚀 Auditing DDD Compliance: ${_picocolors.default.underline(_picocolors.default.bold(_picocolors.default.yellow(PROJECT_ROOT)))} `)}`);
|
|
23
23
|
let dddignore = dddignoreInterpreter(PROJECT_ROOT);
|
|
24
24
|
if (commandRun.options.debug) {
|
|
@@ -42,7 +42,7 @@ function dddignoreInterpreter(root) {
|
|
|
42
42
|
let list = [];
|
|
43
43
|
(0, _nodeFs.readdirSync)(root).forEach(item => {
|
|
44
44
|
const FULL_PATH = _nodePath.default.join(root, item);
|
|
45
|
-
if (item !== "node_modules" && item !== ".git" && item !== "dist" && item !== "public" && (0, _nodeFs.statSync)(FULL_PATH).isDirectory()) {
|
|
45
|
+
if (item !== "node_modules" && item !== ".git" && item !== "dist" && item !== "assets" && item !== "build" && item !== "public" && (0, _nodeFs.statSync)(FULL_PATH).isDirectory()) {
|
|
46
46
|
// Directory
|
|
47
47
|
list = list.concat(dddignoreInterpreter(FULL_PATH));
|
|
48
48
|
} else if (item === ".dddignore") {
|