@haxtheweb/create 9.0.7 → 9.0.8
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 +40 -7
- package/dist/create.js +61 -32
- package/dist/templates/webcomponent/hax/package.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,20 +1,53 @@
|
|
|
1
1
|
# HAX The CLI
|
|
2
2
|
Rapidly build web components for the Web that work with HAX. HAX The Web's CLI tools empower you to rapidly..
|
|
3
|
-
- start making Lit based web components using the HAX design system and tools
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
```bash
|
|
5
|
+
# this allows you to then use hax command
|
|
6
|
+
npm install @haxtheweb/create --global
|
|
7
|
+
# then run
|
|
8
|
+
hax
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
# Commands
|
|
12
|
+
|
|
13
|
+
## Default / global / new context
|
|
14
|
+
- `hax` - fun ascii art and interactive CLI (via [clack](https://www.clack.cc/) )
|
|
15
|
+
- `hax --name my-element --y` - Make a new HAX capable, i18n wired, Design system (DDD) driven web component
|
|
16
|
+
- if in a monorepo root, will place in correct location / inherit settings
|
|
17
|
+
- `hax --type haxsite --name mysite --y` - create a new HAXsite (HAXcms, single site)
|
|
18
|
+
|
|
19
|
+
## Site context
|
|
20
|
+
- listing stats
|
|
21
|
+
- launch site
|
|
22
|
+
- publish to surge.sh (if installed)
|
|
23
|
+
|
|
24
|
+
## web component context
|
|
25
|
+
- launch element
|
|
9
26
|
|
|
10
|
-
# Usage
|
|
27
|
+
# Alternative Usage
|
|
11
28
|
|
|
12
29
|
```bash
|
|
30
|
+
# also this will invoke 1x
|
|
13
31
|
npx @haxtheweb/create
|
|
14
|
-
#
|
|
32
|
+
# this is same as above, better windows CLI support
|
|
15
33
|
npm init @haxtheweb
|
|
16
34
|
```
|
|
17
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
|
+
{
|
|
40
|
+
"scripts": {
|
|
41
|
+
"hax": "hax"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# script creating a new element called my-element w/ all defaults
|
|
48
|
+
npm run hax -- --name my-element --y
|
|
49
|
+
```
|
|
50
|
+
|
|
18
51
|
## Windows problems?
|
|
19
52
|
Try setting a different cache path to load from `npm config set cache C:\tmp\nodejs\npm-cache --global`
|
|
20
53
|
|
package/dist/create.js
CHANGED
|
@@ -11,6 +11,7 @@ var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
|
11
11
|
var _statements = require("./lib/statements.js");
|
|
12
12
|
var _utils = require("./lib/utils.js");
|
|
13
13
|
var hax = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs"));
|
|
14
|
+
var haxcmsNodejsCli = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs/dist/cli.js"));
|
|
14
15
|
var child_process = _interopRequireWildcard(require("child_process"));
|
|
15
16
|
var util = _interopRequireWildcard(require("node:util"));
|
|
16
17
|
var _commander = require("commander");
|
|
@@ -37,16 +38,19 @@ exec('surge --version', error => {
|
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
async function main() {
|
|
40
|
-
_commander.program.option('--y') // skip steps
|
|
41
|
-
.option('--skip') // skip steps
|
|
42
|
-
.option('--auto') // select defaults whenever possible
|
|
43
|
-
.option('--type <char>') // haxsite, webcomponent
|
|
44
|
-
.option('--name <char>') //
|
|
45
|
-
.option('--
|
|
46
|
-
.option('--
|
|
47
|
-
.option('--
|
|
48
|
-
.option('--
|
|
49
|
-
.option('--')
|
|
41
|
+
_commander.program.option('--y', 'yes to all questions') // skip steps
|
|
42
|
+
.option('--skip', 'skip frills like animations') // skip steps
|
|
43
|
+
.option('--auto', 'yes to all questions, alias of y') // select defaults whenever possible
|
|
44
|
+
.option('--type <char>', 'type of project, haxsite or webcomponent') // haxsite, webcomponent
|
|
45
|
+
.option('--name <char>', 'name of the project') // haxsite / webcomponent name
|
|
46
|
+
.option('--title <char>', 'site: node title') // page title
|
|
47
|
+
.option('--domain <char>', 'site: published domain name') // haxsite / webcomponent name
|
|
48
|
+
.option('--action <char>', 'site: action to take') // action to take
|
|
49
|
+
.option('--org <char>', 'organization for package.json') // organization name
|
|
50
|
+
.option('--author <char>', 'author for site / package.json') // organization name
|
|
51
|
+
.option('--path <char>', 'where to perform operation') // path
|
|
52
|
+
.option('--npm-client <char>', 'npm client to use (must be installed) npm, yarn, pnpm') // npm yarn pnpm etc
|
|
53
|
+
.option('--').helpCommand(true);
|
|
50
54
|
_commander.program.parse();
|
|
51
55
|
var cliOptions = _commander.program.opts();
|
|
52
56
|
// auto and y assume same thing
|
|
@@ -122,9 +126,17 @@ async function main() {
|
|
|
122
126
|
// CLI works within context of the site if one is detected, otherwise we can do other thingss
|
|
123
127
|
if (siteData) {
|
|
124
128
|
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Site detected `))}`);
|
|
129
|
+
cliOptions.type = "haxsite";
|
|
125
130
|
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Name: ${siteData.name} `))}`);
|
|
131
|
+
// defaults if nothing set via CLI
|
|
126
132
|
let operation = {
|
|
127
|
-
action: null
|
|
133
|
+
action: null,
|
|
134
|
+
title: "New Page",
|
|
135
|
+
domain: `haxcli-${siteData.name}.surge.sh`
|
|
136
|
+
};
|
|
137
|
+
operation = {
|
|
138
|
+
...operation,
|
|
139
|
+
...cliOptions
|
|
128
140
|
};
|
|
129
141
|
// infinite loop until quitting the cli
|
|
130
142
|
while (operation.action !== 'quit') {
|
|
@@ -137,9 +149,10 @@ async function main() {
|
|
|
137
149
|
}, {
|
|
138
150
|
value: 'sync-git',
|
|
139
151
|
label: "Sync code in git"
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
}, {
|
|
153
|
+
value: 'node-add',
|
|
154
|
+
label: "Add New Page"
|
|
155
|
+
}];
|
|
143
156
|
if (hasSurge) {
|
|
144
157
|
actions.push({
|
|
145
158
|
value: 'publish-surge',
|
|
@@ -150,20 +163,22 @@ async function main() {
|
|
|
150
163
|
value: 'quit',
|
|
151
164
|
label: "🚪 Quit"
|
|
152
165
|
});
|
|
153
|
-
operation
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
if (!operation.action) {
|
|
167
|
+
operation = await p.group({
|
|
168
|
+
action: ({
|
|
169
|
+
results
|
|
170
|
+
}) => p.select({
|
|
171
|
+
message: `Actions you can take`,
|
|
172
|
+
options: actions
|
|
173
|
+
})
|
|
174
|
+
}, {
|
|
175
|
+
onCancel: () => {
|
|
176
|
+
p.cancel('🧙 Merlin: Canceling CLI.. HAX ya later 🪄');
|
|
177
|
+
(0, _statements.communityStatement)();
|
|
178
|
+
process.exit(0);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
167
182
|
switch (operation.action) {
|
|
168
183
|
case "status":
|
|
169
184
|
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Title: ${siteData.manifest.title} `))}`);
|
|
@@ -178,9 +193,15 @@ async function main() {
|
|
|
178
193
|
}
|
|
179
194
|
break;
|
|
180
195
|
case "node-add":
|
|
181
|
-
// @todo
|
|
196
|
+
// @todo need to accept arguments
|
|
182
197
|
try {
|
|
183
|
-
|
|
198
|
+
haxcmsNodejsCli.cliBridge('createNode', {
|
|
199
|
+
site: siteData,
|
|
200
|
+
node: {
|
|
201
|
+
title: operation.title
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
console.log(`"${operation.title}" added to site`);
|
|
184
205
|
} catch (e) {
|
|
185
206
|
console.log(e.stderr);
|
|
186
207
|
}
|
|
@@ -195,7 +216,9 @@ async function main() {
|
|
|
195
216
|
break;
|
|
196
217
|
case "publish-surge":
|
|
197
218
|
try {
|
|
198
|
-
|
|
219
|
+
// @todo should provide an option for setting the domain
|
|
220
|
+
let execOutput = await exec(`cd ${siteData.directory} && surge . ${operation.domain}`);
|
|
221
|
+
console.log(execOutput.stdout.trim());
|
|
199
222
|
} catch (e) {
|
|
200
223
|
console.log(e.stderr);
|
|
201
224
|
}
|
|
@@ -204,6 +227,10 @@ async function main() {
|
|
|
204
227
|
// quit
|
|
205
228
|
break;
|
|
206
229
|
}
|
|
230
|
+
if (cliOptions.y) {
|
|
231
|
+
process.exit(0);
|
|
232
|
+
}
|
|
233
|
+
operation.action = null;
|
|
207
234
|
}
|
|
208
235
|
} else if (packageData && packageData.hax && packageData.hax.cli && packageData.scripts.start) {
|
|
209
236
|
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Webcomponent detected `))}`);
|
|
@@ -244,7 +271,7 @@ async function main() {
|
|
|
244
271
|
p.note(` 🧙🪄 BE GONE ${_picocolors.default.bold(_picocolors.default.black(_picocolors.default.bgGreen(activeProject)))} sub-process daemon! 🪄 + ✨ 👹 = 💀 `);
|
|
245
272
|
cliOptions = {};
|
|
246
273
|
}
|
|
247
|
-
if (['haxsite', 'webcomponent'].includes(cliOptions.type)) {
|
|
274
|
+
if (['site', 'haxsite', 'webcomponent'].includes(cliOptions.type)) {
|
|
248
275
|
project = {
|
|
249
276
|
type: cliOptions.type
|
|
250
277
|
};
|
|
@@ -449,6 +476,7 @@ async function main() {
|
|
|
449
476
|
let s = p.spinner();
|
|
450
477
|
// resolve site vs multi-site
|
|
451
478
|
switch (project.type) {
|
|
479
|
+
case 'site':
|
|
452
480
|
case 'haxsite':
|
|
453
481
|
s.start((0, _statements.merlinSays)(`Creating new site: ${project.name}`));
|
|
454
482
|
let siteRequest = {
|
|
@@ -589,6 +617,7 @@ async function main() {
|
|
|
589
617
|
} else {
|
|
590
618
|
let nextSteps = `cd ${project.path}/${project.name} && `;
|
|
591
619
|
switch (project.type) {
|
|
620
|
+
case 'site':
|
|
592
621
|
case 'haxsite':
|
|
593
622
|
nextSteps += `npx @haxtheweb/haxcms-nodejs`;
|
|
594
623
|
break;
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"lit": "^3.2.0",
|
|
31
|
-
"@haxtheweb/d-d-d": "
|
|
32
|
-
"@haxtheweb/i18n-manager": "
|
|
31
|
+
"@haxtheweb/d-d-d": "^9.0.13",
|
|
32
|
+
"@haxtheweb/i18n-manager": "^9.0.13"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@babel/preset-env": "^7.16.4",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haxtheweb/create",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build": "rm -rf dist && babel src --out-dir dist --copy-files --include-dotfiles && chmod 774 dist/create.js",
|
|
23
23
|
"start": "npm run build && node ./dist/create.js && chmod 774 dist/create.js",
|
|
24
24
|
"release": "npm run build && commit-and-tag-version && git push --follow-tags origin main && npm publish",
|
|
25
|
-
"haxcms-nodejs-cli": "
|
|
25
|
+
"haxcms-nodejs-cli": "haxcms-nodejs-cli"
|
|
26
26
|
},
|
|
27
27
|
"bin": {
|
|
28
28
|
"create-haxtheweb": "./dist/create.js",
|