@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
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.partyActions = partyActions;
|
|
7
|
+
exports.partyCommandDetected = partyCommandDetected;
|
|
8
|
+
var fs = _interopRequireWildcard(require("node:fs"));
|
|
9
|
+
var _utils = require("../utils.js");
|
|
10
|
+
var _open = _interopRequireDefault(require("open"));
|
|
11
|
+
var p = _interopRequireWildcard(require("@clack/prompts"));
|
|
12
|
+
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
13
|
+
var _statements = require("../statements.js");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
+
let sysGit = true;
|
|
18
|
+
(0, _utils.exec)('which git', error => {
|
|
19
|
+
if (error) {
|
|
20
|
+
sysGit = false;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
let sysSSH = true;
|
|
24
|
+
(0, _utils.exec)('ssh -T git@github.com', (error, stdout, stderr) => {
|
|
25
|
+
const output = stdout + stderr;
|
|
26
|
+
// The GitHub SSH test always returns as stderr
|
|
27
|
+
if (!output.includes('successfully authenticated')) {
|
|
28
|
+
sysSSH = false;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function partyActions() {
|
|
32
|
+
return [{
|
|
33
|
+
value: 'docs',
|
|
34
|
+
label: "View the HAX documentation"
|
|
35
|
+
}, {
|
|
36
|
+
value: 'playground',
|
|
37
|
+
label: "Explore HAX.cloud playground"
|
|
38
|
+
}, {
|
|
39
|
+
value: 'psu',
|
|
40
|
+
label: "Visit official hax.psu.edu site"
|
|
41
|
+
}, {
|
|
42
|
+
value: 'issues',
|
|
43
|
+
label: "Engage with HAX issues on GitHub"
|
|
44
|
+
}, {
|
|
45
|
+
value: 'discord',
|
|
46
|
+
label: "Join the HAX Discord community"
|
|
47
|
+
}, {
|
|
48
|
+
value: 'club',
|
|
49
|
+
label: "Check out HAX The Club at PSU"
|
|
50
|
+
}, {
|
|
51
|
+
value: 'github',
|
|
52
|
+
label: "Contribute to core development for HAX"
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
55
|
+
async function partyCommandDetected(commandRun) {
|
|
56
|
+
if (!commandRun.options.quiet) {
|
|
57
|
+
p.intro(`${_picocolors.default.bgBlack(_picocolors.default.white(` HAXTheWeb : Party detected `))}`);
|
|
58
|
+
}
|
|
59
|
+
let actions = partyActions();
|
|
60
|
+
let actionAssigned = false;
|
|
61
|
+
// default to status unless already set so we don't issue a create in a create
|
|
62
|
+
if (!commandRun.arguments.action) {
|
|
63
|
+
actionAssigned = true;
|
|
64
|
+
commandRun.arguments.action = 'party:status';
|
|
65
|
+
}
|
|
66
|
+
commandRun.command = "party";
|
|
67
|
+
let operation = {
|
|
68
|
+
...commandRun.arguments,
|
|
69
|
+
...commandRun.options
|
|
70
|
+
};
|
|
71
|
+
actions.push({
|
|
72
|
+
value: 'quit',
|
|
73
|
+
label: "🚪 Quit"
|
|
74
|
+
});
|
|
75
|
+
while (operation.action !== 'quit') {
|
|
76
|
+
if (!operation.action) {
|
|
77
|
+
commandRun = {
|
|
78
|
+
command: null,
|
|
79
|
+
arguments: {},
|
|
80
|
+
options: {
|
|
81
|
+
// npmClient: `${operation.npmClient}`
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
operation = await p.group({
|
|
85
|
+
action: ({
|
|
86
|
+
results
|
|
87
|
+
}) => p.select({
|
|
88
|
+
message: `Actions you can take:`,
|
|
89
|
+
defaultValue: actions[0],
|
|
90
|
+
initialValue: actions[0],
|
|
91
|
+
options: actions
|
|
92
|
+
})
|
|
93
|
+
}, {
|
|
94
|
+
onCancel: () => {
|
|
95
|
+
if (!commandRun.options.quiet) {
|
|
96
|
+
p.cancel('🧙 Merlin: Canceling CLI.. HAX ya later 🪄');
|
|
97
|
+
}
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (operation.action) {
|
|
103
|
+
p.intro(`hax party ${_picocolors.default.bold(operation.action)}`);
|
|
104
|
+
}
|
|
105
|
+
switch (operation.action) {
|
|
106
|
+
case "party:status":
|
|
107
|
+
case "party:stats":
|
|
108
|
+
if (!commandRun.options.quiet) {
|
|
109
|
+
p.intro(`${_picocolors.default.green(_picocolors.default.bold(`
|
|
110
|
+
888
|
|
111
|
+
888
|
|
112
|
+
88888b. 8888b. 888d888888888888 888
|
|
113
|
+
888 "88b "88b888P" 888 888 888
|
|
114
|
+
888 888.d888888888 888 888 888
|
|
115
|
+
888 d88P888 888888 Y88b. Y88b 888
|
|
116
|
+
88888P" "Y888888888 "Y888 "Y88888
|
|
117
|
+
888 888
|
|
118
|
+
888 Y8bd88P`))}`);
|
|
119
|
+
}
|
|
120
|
+
;
|
|
121
|
+
break;
|
|
122
|
+
case "docs":
|
|
123
|
+
// open the docs
|
|
124
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` HAX Documentation `))}`);
|
|
125
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Opening in browser `))}`);
|
|
126
|
+
await (0, _open.default)("https://haxtheweb.org/");
|
|
127
|
+
p.outro(`${_picocolors.default.bgBlue(_picocolors.default.white(` https://haxtheweb.org/ `))}`);
|
|
128
|
+
break;
|
|
129
|
+
case "playground":
|
|
130
|
+
// open the playground
|
|
131
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` HAX Playground `))}`);
|
|
132
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Opening in browser `))}`);
|
|
133
|
+
await (0, _open.default)("https://hax.cloud/");
|
|
134
|
+
p.outro(`${_picocolors.default.bgBlue(_picocolors.default.white(` https://hax.cloud/ `))}`);
|
|
135
|
+
break;
|
|
136
|
+
case "psu":
|
|
137
|
+
// open the psu site
|
|
138
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` HAX PSU `))}`);
|
|
139
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Opening in browser `))}`);
|
|
140
|
+
await (0, _open.default)("https://hax.psu.edu/");
|
|
141
|
+
p.outro(`${_picocolors.default.bgBlue(_picocolors.default.white(` https://hax.psu.edu/ `))}`);
|
|
142
|
+
break;
|
|
143
|
+
case "issues":
|
|
144
|
+
// open the issues
|
|
145
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` HAX Issues on Github `))}`);
|
|
146
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Opening in browser `))}`);
|
|
147
|
+
await (0, _open.default)("https://github.com/haxtheweb/issues/issues");
|
|
148
|
+
p.outro(`${_picocolors.default.bgBlue(_picocolors.default.white(` https://github.com/haxtheweb/issues/issues `))}`);
|
|
149
|
+
break;
|
|
150
|
+
case "discord":
|
|
151
|
+
// open the discord
|
|
152
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` HAX Discord `))}`);
|
|
153
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Opening in browser `))}`);
|
|
154
|
+
await (0, _open.default)("https://discord.gg/EKYJAjqGhf");
|
|
155
|
+
p.outro(`${_picocolors.default.bgBlue(_picocolors.default.white(` https://discord.gg/EKYJAjqGhf `))}`);
|
|
156
|
+
break;
|
|
157
|
+
case "club":
|
|
158
|
+
// open the club
|
|
159
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` HAX The Club is a student organization at PSU `))}`);
|
|
160
|
+
p.intro(`${_picocolors.default.bgBlue(_picocolors.default.white(` Opening in browser `))}`);
|
|
161
|
+
await (0, _open.default)("https://orgcentral.psu.edu/organization/hax-the-club");
|
|
162
|
+
p.outro(`${_picocolors.default.bgBlue(_picocolors.default.white(` https://orgcentral.psu.edu/organization/hax-the-club `))}`);
|
|
163
|
+
// we can change this to the club website when it's up
|
|
164
|
+
break;
|
|
165
|
+
case "gh":
|
|
166
|
+
case "github":
|
|
167
|
+
try {
|
|
168
|
+
// auto and y are aliases
|
|
169
|
+
if (!commandRun.options.root && !commandRun.options.auto) {
|
|
170
|
+
commandRun.options.root = await p.text({
|
|
171
|
+
message: 'What folder will your HAX projects live in?',
|
|
172
|
+
placeholder: process.cwd(),
|
|
173
|
+
required: true,
|
|
174
|
+
validate: value => {
|
|
175
|
+
if (!value) {
|
|
176
|
+
return "Path is required (tab writes default)";
|
|
177
|
+
}
|
|
178
|
+
if (!fs.existsSync(value)) {
|
|
179
|
+
return `${value} does not exist. Select a valid folder`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
// subprocesses are based on the root process folder
|
|
184
|
+
process.chdir(commandRun.options.root);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// list HAX repos
|
|
188
|
+
const initialValues = ["webcomponents"];
|
|
189
|
+
const options = [{
|
|
190
|
+
value: "webcomponents",
|
|
191
|
+
label: "Webcomponents Monorepo - haxtheweb/webcomponents"
|
|
192
|
+
}, {
|
|
193
|
+
value: "create",
|
|
194
|
+
label: "Create CLI - haxtheweb/create"
|
|
195
|
+
}, {
|
|
196
|
+
value: "hax-the-club",
|
|
197
|
+
label: "HAX The Club - haxtheweb/hax-the-club"
|
|
198
|
+
}, {
|
|
199
|
+
value: "open-apis",
|
|
200
|
+
label: "Open APIs - haxtheweb/open-apis"
|
|
201
|
+
}, {
|
|
202
|
+
value: "haxcms-nodejs",
|
|
203
|
+
label: "HAXcms Node.js - haxtheweb/haxcms-nodejs"
|
|
204
|
+
}, {
|
|
205
|
+
value: "haxcms-php",
|
|
206
|
+
label: "HAXcms PHP - haxtheweb/haxcms-php"
|
|
207
|
+
}, {
|
|
208
|
+
value: "desktop",
|
|
209
|
+
label: "HAX The Desktop - haxtheweb/desktop"
|
|
210
|
+
}, {
|
|
211
|
+
value: "HAXiam",
|
|
212
|
+
label: "HAXiam - haxtheweb/HAXiam"
|
|
213
|
+
}];
|
|
214
|
+
p.note(`${(0, _statements.merlinSays)(`${_picocolors.default.magenta(_picocolors.default.bold('HAX is a party,'))} so you can select ${_picocolors.default.bold('multiple')} repositories at once!`)}
|
|
215
|
+
Remember to ${_picocolors.default.bold('fork each project')} on ${_picocolors.default.bold('GitHub')} (or you'll be asked to later!)`);
|
|
216
|
+
if (!commandRun.options.repos && commandRun.options.auto) {
|
|
217
|
+
commandRun.options.repos = initialValues;
|
|
218
|
+
} else if (!commandRun.options.repos) {
|
|
219
|
+
commandRun.options.repos = await p.multiselect({
|
|
220
|
+
message: 'Choose GitHub repositories to clone',
|
|
221
|
+
initialValues: initialValues,
|
|
222
|
+
options: options,
|
|
223
|
+
required: false
|
|
224
|
+
});
|
|
225
|
+
} else if (commandRun.options.repos.includes("all")) {
|
|
226
|
+
commandRun.options.repos = options.map(item => item.value);
|
|
227
|
+
}
|
|
228
|
+
await cloneHAXRepositories(commandRun);
|
|
229
|
+
} catch (e) {}
|
|
230
|
+
break;
|
|
231
|
+
case "quit":
|
|
232
|
+
// quit
|
|
233
|
+
process.exit(0);
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
// y or noi need to act like it ran and finish instead of looping options
|
|
237
|
+
if (commandRun.options.y || !commandRun.options.i || !actionAssigned) {
|
|
238
|
+
process.exit(0);
|
|
239
|
+
}
|
|
240
|
+
operation.action = null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async function cloneHAXRepositories(commandRun) {
|
|
244
|
+
let s = p.spinner();
|
|
245
|
+
|
|
246
|
+
// check for system dependencies: ssh, yarn, etc.
|
|
247
|
+
if (!sysGit) {
|
|
248
|
+
console.error(`${_picocolors.default.red(`Git is not installed. The Git CLI is required to access GitHub with ${_picocolors.default.bold('hax party')}.`)}
|
|
249
|
+
Please follow the instructions at:
|
|
250
|
+
${_picocolors.default.underline(_picocolors.default.cyan(`https://git-scm.com/book/en/v2/Getting-Started-Installing-Git`))}`);
|
|
251
|
+
process.exit(1);
|
|
252
|
+
}
|
|
253
|
+
if (!sysSSH) {
|
|
254
|
+
console.error(`${_picocolors.default.red(`SSH keys are not set up correctly. SSH is required to access GitHub with ${_picocolors.default.bold('hax party')}.`)}
|
|
255
|
+
Please follow the instructions at:
|
|
256
|
+
${_picocolors.default.underline(_picocolors.default.cyan(`https://docs.github.com/en/authentication/connecting-to-github-with-ssh`))}`);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
await (0, _utils.exec)(`yarn --version`);
|
|
261
|
+
} catch (e) {
|
|
262
|
+
await (0, _utils.exec)(`npm install -g yarn`);
|
|
263
|
+
}
|
|
264
|
+
for (const item of commandRun.options.repos) {
|
|
265
|
+
// while loop keeps HAX active until the user is ready
|
|
266
|
+
let isForked = false;
|
|
267
|
+
let firstRun = true;
|
|
268
|
+
while (!isForked) {
|
|
269
|
+
try {
|
|
270
|
+
// ssh link is used since https prompts for password
|
|
271
|
+
if (firstRun) {
|
|
272
|
+
s.start(`Cloning ${_picocolors.default.bold(item)} to ${_picocolors.default.bold(process.cwd())}`);
|
|
273
|
+
} else {
|
|
274
|
+
s.start(`Trying again... Cloning ${item} to ${_picocolors.default.bold(process.cwd())}`);
|
|
275
|
+
}
|
|
276
|
+
await (0, _utils.exec)(`git clone git@github.com:${commandRun.options.author}/${item}.git`);
|
|
277
|
+
s.stop(`${_picocolors.default.green("Successfully")} cloned ${_picocolors.default.bold(item)} to ${_picocolors.default.bold(process.cwd())}`);
|
|
278
|
+
isForked = true;
|
|
279
|
+
} catch (e) {
|
|
280
|
+
// skip the loop if the repo already exists
|
|
281
|
+
if (e.stderr.includes("already exists and is not an empty directory")) {
|
|
282
|
+
s.stop(`${_picocolors.default.yellow(`${_picocolors.default.bold(`${item}`)} already exists in ${_picocolors.default.bold(process.cwd())}`)}`);
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
s.stop(`${_picocolors.default.red("Failed")} to clone ${_picocolors.default.bold(item)} to ${_picocolors.default.bold(process.cwd())}`);
|
|
286
|
+
p.note(`${_picocolors.default.red(`Error: HAX cannot find a personal ${_picocolors.default.bold("fork")} of the ${_picocolors.default.bold(item)} repository on your GitHub account`)}
|
|
287
|
+
Use the following link to fork ${_picocolors.default.bold(item)}: ${_picocolors.default.underline(_picocolors.default.cyan(`https://github.com/haxtheweb/${item}/fork`))}`);
|
|
288
|
+
|
|
289
|
+
// We don't want to spam the link every time
|
|
290
|
+
if (firstRun) {
|
|
291
|
+
p.intro(`${(0, _statements.merlinSays)("The link will open in your browser in a few seconds")}`);
|
|
292
|
+
setTimeout(async () => {
|
|
293
|
+
await (0, _open.default)(`https://github.com/haxtheweb/${item}/fork`);
|
|
294
|
+
}, 3000);
|
|
295
|
+
firstRun = false;
|
|
296
|
+
}
|
|
297
|
+
let response = await p.confirm({
|
|
298
|
+
message: `Have you forked the repository? Would you like to try again?`,
|
|
299
|
+
initialValue: true
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Multiple ways to quit (select no, ctrl+c, etc)
|
|
303
|
+
if (p.isCancel(response) || !response) {
|
|
304
|
+
p.cancel('🧙 Merlin: Canceling CLI.. HAX ya later 🪄');
|
|
305
|
+
process.exit(0);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
s.start(`Installing dependencies for ${item}`);
|
|
310
|
+
switch (item) {
|
|
311
|
+
case "webcomponents":
|
|
312
|
+
await (0, _utils.exec)(`yarn global add lerna web-component-analyzer`);
|
|
313
|
+
await (0, _utils.exec)(`cd ${process.cwd()}/${item} && yarn install`);
|
|
314
|
+
break;
|
|
315
|
+
case "create":
|
|
316
|
+
case "hax-the-club":
|
|
317
|
+
case "open-apis":
|
|
318
|
+
case "haxcms-nodejs":
|
|
319
|
+
case "desktop":
|
|
320
|
+
await (0, _utils.exec)(`cd ${process.cwd()}/${item} && ${commandRun.options.npmClient} install`);
|
|
321
|
+
break;
|
|
322
|
+
case "haxcms-php":
|
|
323
|
+
// ddev setup
|
|
324
|
+
break;
|
|
325
|
+
case "HAXiam":
|
|
326
|
+
// curl setup?
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
s.stop(`Dependencies installed for ${item}`);
|
|
330
|
+
}
|
|
331
|
+
;
|
|
332
|
+
}
|