@haxtheweb/create 9.0.10 → 9.0.12
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 +76 -11
- package/dist/create.js +37 -12
- package/dist/lib/micro-frontend-registry.js +722 -0
- package/dist/lib/programs/site.js +176 -5
- package/dist/lib/programs/webcomponent.js +217 -13
- package/dist/templates/webcomponent/hax/package.json +1 -1
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -1,20 +1,67 @@
|
|
|
1
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
2
|
+
[](https://lit.dev/)
|
|
3
|
+
[](https://haxtheweb.org/)
|
|
4
|
+
[](https://www.npmjs.com/package/@haxtheweb/create)
|
|
5
|
+
[](https://github.com/haxtheweb/create/actions)
|
|
6
|
+
[](https://twitter.com/intent/follow?screen_name=haxtheweb)
|
|
7
|
+
|
|
1
8
|
# HAX The CLI
|
|
2
9
|
Rapidly build web components for the Web that work with HAX. HAX The Web's CLI tools empower you to rapidly..
|
|
3
10
|
|
|
4
11
|
```bash
|
|
5
12
|
# this allows you to then use hax command
|
|
6
13
|
npm install @haxtheweb/create --global
|
|
7
|
-
# then run
|
|
8
|
-
hax
|
|
14
|
+
# then run this for interactive prompt
|
|
15
|
+
hax start
|
|
9
16
|
```
|
|
10
17
|
|
|
11
18
|
# Commands
|
|
12
19
|
|
|
13
20
|
## Default / global / new context
|
|
14
|
-
- `hax` - fun ascii art and interactive CLI (via [clack](https://www.clack.cc/) )
|
|
15
|
-
- `hax
|
|
21
|
+
- `hax start` - fun ascii art and interactive CLI (via [clack](https://www.clack.cc/) )
|
|
22
|
+
- `hax webcomponent my-element --y` - Make a new HAX capable, i18n wired, Design system (DDD) driven web component
|
|
16
23
|
- if in a monorepo root, will place in correct location / inherit settings
|
|
17
|
-
- `hax
|
|
24
|
+
- `hax site mysite --y` - create a new HAXsite (HAXcms, single site)
|
|
25
|
+
|
|
26
|
+
## --help
|
|
27
|
+
Run `hax help` or `hax webcomponent --help` or `hax site --help` for up-to-date listing
|
|
28
|
+
```
|
|
29
|
+
Usage: hax [options] [command]
|
|
30
|
+
|
|
31
|
+
Options:
|
|
32
|
+
--
|
|
33
|
+
--v Verbose output for developers
|
|
34
|
+
--path <char> where to perform operation
|
|
35
|
+
--npm-client <char> npm client to use (must be installed) npm,
|
|
36
|
+
yarn, pnpm (default: "npm")
|
|
37
|
+
--y yes to all questions
|
|
38
|
+
--skip skip frills like animations
|
|
39
|
+
--auto yes to all questions, alias of y
|
|
40
|
+
--org <char> organization for package.json
|
|
41
|
+
--author <char> author for site / package.json
|
|
42
|
+
--import-site <char> URL of site to import
|
|
43
|
+
--node-op <char> node operation to perform
|
|
44
|
+
--item-id <char> node ID to operate on
|
|
45
|
+
--name <char> name of the project
|
|
46
|
+
--domain <char> published domain name
|
|
47
|
+
--title <char> Title
|
|
48
|
+
--content <char> Page content
|
|
49
|
+
--slug <char> Path (slug)
|
|
50
|
+
--published <char> Publishing status
|
|
51
|
+
--tags <char> Tags
|
|
52
|
+
--parent <char> Parent
|
|
53
|
+
--order <char> Order
|
|
54
|
+
--theme <char> Theme
|
|
55
|
+
--hide-in-menu <char> Hide in menu
|
|
56
|
+
-h, --help display help for command
|
|
57
|
+
|
|
58
|
+
Commands:
|
|
59
|
+
start Interactive program to pick options
|
|
60
|
+
site [options] [action]
|
|
61
|
+
webcomponent [options] [name] Create Lit based web components, with HAX
|
|
62
|
+
recommendations
|
|
63
|
+
help [command] display help for command
|
|
64
|
+
```
|
|
18
65
|
|
|
19
66
|
## Site context
|
|
20
67
|
- listing stats
|
|
@@ -31,12 +78,8 @@ hax
|
|
|
31
78
|
npx @haxtheweb/create
|
|
32
79
|
# this is same as above, better windows CLI support
|
|
33
80
|
npm init @haxtheweb
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## Usage in other programs
|
|
37
|
-
https://stackoverflow.com/questions/69208298/use-node-bins-without-installing-the-package-globally explains it but you should be able to use the CLI as part of another project as follows:
|
|
38
|
-
```json
|
|
39
|
-
{
|
|
81
|
+
- Try Hax: https://hax.cloud
|
|
82
|
+
- HAXCellence https://haxtheweb.org/what-is-hax
|
|
40
83
|
"scripts": {
|
|
41
84
|
"hax": "hax"
|
|
42
85
|
}
|
|
@@ -70,3 +113,25 @@ Build a HAX site that can be published and transported anywhere. Your users migh
|
|
|
70
113
|
- Ability to import via URL just like the front-end
|
|
71
114
|
- Theme development starting point to be able to build themes locally
|
|
72
115
|
- Primed to publish to gh-pages, vercel and more
|
|
116
|
+
|
|
117
|
+
# Get Help / Issues / Support
|
|
118
|
+
- Discord Channel - https://bit.ly/hax-discord
|
|
119
|
+
- Unified issue queue - https://github.com/haxtheweb/issues/issues
|
|
120
|
+
- Using Merlin directly in any HAX spaces and type "Issue" to jump start a report!
|
|
121
|
+
|
|
122
|
+
## Watch and Learn more about HAX here:
|
|
123
|
+
- Try Hax: https://hax.cloud
|
|
124
|
+
- HAXCellence https://haxtheweb.org/what-is-hax
|
|
125
|
+
- Youtube channel - https://www.youtube.com/@haxtheweb
|
|
126
|
+
|
|
127
|
+
# Related links and tech
|
|
128
|
+
- [NPM Package list](https://www.npmjs.com/org/haxtheweb)
|
|
129
|
+
- [HAXcms (NodeJS)](https://github.com/haxtheweb/haxcms-nodejs)
|
|
130
|
+
- [HAXcms (PHP)](https://github.com/haxtheweb/haxcms-php)
|
|
131
|
+
- [Storybook docs](https://open-apis.hax.cloud/)
|
|
132
|
+
- [HAX [dot] PSU](https://hax.psu.edu)
|
|
133
|
+
- [HAX doc site](https://haxtheweb.org/)
|
|
134
|
+
- [HAX + 11ty](https://github.com/haxtheweb/hax11ty)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+

|
package/dist/create.js
CHANGED
|
@@ -28,13 +28,13 @@ exec('git --version', error => {
|
|
|
28
28
|
});
|
|
29
29
|
async function main() {
|
|
30
30
|
var commandRun = {};
|
|
31
|
-
_commander.program.option('--').option('--v', 'Verbose output for developers').option('--path <char>', 'where to perform operation').option('--npm-client <char>', 'npm client to use (must be installed) npm, yarn, pnpm', 'npm').option('--y', 'yes to all questions').option('--skip', 'skip frills like animations').option('--auto', 'yes to all questions, alias of y')
|
|
31
|
+
_commander.program.option('--').option('--v', 'Verbose output').option('--debug', 'Output for developers').option('--format <char>', 'Output format; json (default), yaml').option('--path <char>', 'where to perform operation').option('--npm-client <char>', 'npm client to use (must be installed) npm, yarn, pnpm', 'npm').option('--y', 'yes to all questions').option('--skip', 'skip frills like animations').option('--auto', 'yes to all questions, alias of y')
|
|
32
32
|
|
|
33
33
|
// options for webcomponent
|
|
34
|
-
.option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json')
|
|
34
|
+
.option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element')
|
|
35
35
|
|
|
36
36
|
// options for site
|
|
37
|
-
.option('--node-op <char>', 'node operation to perform').option('--item-id <char>', 'node ID to operate on').option('--name <char>', 'name of the project').option('--domain <char>', 'published domain name').helpCommand(true);
|
|
37
|
+
.option('--import-site <char>', 'URL of site to import').option('--import-structure <char>', `import method to use:\n\rpressbooksToSite\n\relmslnToSite\n\rhaxcmsToSite\n\rnotionToSite\n\rgitbookToSite\n\revolutionToSite\n\rhtmlToSite\n\rdocxToSite`).option('--node-op <char>', 'node operation to perform').option('--item-id <char>', 'node ID to operate on').option('--name <char>', 'name of the project').option('--domain <char>', 'published domain name').helpCommand(true);
|
|
38
38
|
|
|
39
39
|
// default command which runs interactively
|
|
40
40
|
_commander.program.command('start').description('Interactive program to pick options').action(() => {
|
|
@@ -61,7 +61,7 @@ async function main() {
|
|
|
61
61
|
commandRun.arguments.action = action;
|
|
62
62
|
commandRun.options.skip = true;
|
|
63
63
|
}
|
|
64
|
-
}).option('--path <char>', 'path the project should be created in').option('--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').version(await HAXCMS.getHAXCMSVersion());
|
|
64
|
+
}).option('--path <char>', 'path the project should be created in').option('--import-site <char>', 'URL of site to import').option('--import-structure <char>', `import method to use:\n\rpressbooksToSite\n\relmslnToSite\n\rhaxcmsToSite\n\rnotionToSite\n\rgitbookToSite\n\revolutionToSite\n\rhtmlToSite\n\rdocxToSite`).option('--name <char>', 'name of the site (when creating a new one)').option('--domain <char>', 'published domain name').option('--node-op <char>', 'node operation to perform').version(await HAXCMS.getHAXCMSVersion());
|
|
65
65
|
let siteNodeOps = (0, _site.siteNodeOperations)();
|
|
66
66
|
for (var i in siteNodeOps) {
|
|
67
67
|
_commander.program.option(`--${(0, _utils.camelToDash)(siteNodeOps[i].value)} <char>`, `${siteNodeOps[i].label}`);
|
|
@@ -80,14 +80,14 @@ 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');
|
|
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');
|
|
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
|
-
if (commandRun.options.
|
|
90
|
+
if (commandRun.options.debug) {
|
|
91
91
|
console.log(commandRun);
|
|
92
92
|
}
|
|
93
93
|
// auto and y assume same thing
|
|
@@ -109,9 +109,14 @@ async function main() {
|
|
|
109
109
|
if (!commandRun.options.path && commandRun.options.skip) {
|
|
110
110
|
commandRun.options.path = process.cwd();
|
|
111
111
|
}
|
|
112
|
-
if
|
|
113
|
-
|
|
114
|
-
commandRun.options.
|
|
112
|
+
// if we skip stuff then set org/author automatically
|
|
113
|
+
if (commandRun.options.skip || commandRun.options.auto) {
|
|
114
|
+
if (!commandRun.options.org) {
|
|
115
|
+
commandRun.options.org = '';
|
|
116
|
+
}
|
|
117
|
+
if (!commandRun.options.author) {
|
|
118
|
+
commandRun.options.author = author;
|
|
119
|
+
}
|
|
115
120
|
}
|
|
116
121
|
let packageData = {};
|
|
117
122
|
let testPackages = [path.join(process.cwd(), 'package.json'), path.join(process.cwd(), '../', 'package.json'), path.join(process.cwd(), '../', '../', 'package.json')];
|
|
@@ -121,7 +126,10 @@ async function main() {
|
|
|
121
126
|
let packLoc = testPackages.shift();
|
|
122
127
|
if (fs.existsSync(packLoc)) {
|
|
123
128
|
try {
|
|
124
|
-
packageData =
|
|
129
|
+
packageData = {
|
|
130
|
+
...JSON.parse(fs.readFileSync(packLoc)),
|
|
131
|
+
...packageData
|
|
132
|
+
};
|
|
125
133
|
// assume we are working on a web component / existing if we find this key
|
|
126
134
|
if (packageData.hax && packageData.hax.cli) {
|
|
127
135
|
commandRun.program = 'webcomponent';
|
|
@@ -129,6 +137,8 @@ async function main() {
|
|
|
129
137
|
// leverage these values if they exist downstream
|
|
130
138
|
if (packageData.npmClient) {
|
|
131
139
|
commandRun.options.npmClient = packageData.npmClient;
|
|
140
|
+
} else {
|
|
141
|
+
commandRun.options.npmClient = 'npm';
|
|
132
142
|
}
|
|
133
143
|
// see if we're in a monorepo
|
|
134
144
|
if (packageData.useWorkspaces && packageData.workspaces && packageData.workspaces.packages && packageData.workspaces.packages[0]) {
|
|
@@ -149,12 +159,15 @@ async function main() {
|
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
161
|
}
|
|
162
|
+
if (commandRun.options.debug) {
|
|
163
|
+
console.log(packageData);
|
|
164
|
+
}
|
|
152
165
|
// CLI works within context of the site if one is detected, otherwise we can do other thingss
|
|
153
166
|
if (await hax.systemStructureContext()) {
|
|
154
167
|
commandRun.program = 'site';
|
|
155
168
|
commandRun.options.skip = true;
|
|
156
169
|
await (0, _site.siteCommandDetected)(commandRun);
|
|
157
|
-
} else if (packageData && packageData.hax && packageData.hax.cli && packageData.scripts.start) {
|
|
170
|
+
} else if (packageData && (packageData.customElements || packageData.hax && packageData.hax.cli) && packageData.scripts.start) {
|
|
158
171
|
commandRun.program = 'webcomponent';
|
|
159
172
|
commandRun.options.skip = true;
|
|
160
173
|
await (0, _webcomponent.webcomponentCommandDetected)(commandRun, packageData);
|
|
@@ -169,6 +182,12 @@ async function main() {
|
|
|
169
182
|
while (project.type !== 'quit') {
|
|
170
183
|
if (activeProject) {
|
|
171
184
|
p.note(` 🧙🪄 BE GONE ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgGreen(activeProject)))} sub-process daemon! 🪄 + ✨ 👹 = 💀 `);
|
|
185
|
+
// ensure if we were automatically running the command we end
|
|
186
|
+
if (commandRun.options.y) {
|
|
187
|
+
(0, _statements.communityStatement)();
|
|
188
|
+
process.exit(0);
|
|
189
|
+
}
|
|
190
|
+
// otherwise null to reset the program to run again
|
|
172
191
|
commandRun = {
|
|
173
192
|
command: null,
|
|
174
193
|
arguments: {},
|
|
@@ -192,7 +211,7 @@ async function main() {
|
|
|
192
211
|
label: '🏗️ Create a Web Component'
|
|
193
212
|
}, {
|
|
194
213
|
value: 'site',
|
|
195
|
-
label: '🏡 Create a
|
|
214
|
+
label: '🏡 Create a HAXsite'
|
|
196
215
|
}, {
|
|
197
216
|
value: 'quit',
|
|
198
217
|
label: '🚪 Quit'
|
|
@@ -206,6 +225,12 @@ async function main() {
|
|
|
206
225
|
}
|
|
207
226
|
});
|
|
208
227
|
}
|
|
228
|
+
// detect being in a haxcms scaffold. easiest way is _sites being in this directory
|
|
229
|
+
// set the path automatically so we skip the question
|
|
230
|
+
if (commandRun.command === "site" && fs.existsSync(`${process.cwd()}/_sites`)) {
|
|
231
|
+
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXcms detected : Path set automatically `))}`);
|
|
232
|
+
commandRun.options.path = `${process.cwd()}/_sites`;
|
|
233
|
+
}
|
|
209
234
|
activeProject = project.type;
|
|
210
235
|
// silly but this way we don't have to take options for quitting
|
|
211
236
|
if (project.type !== 'quit') {
|