@haxtheweb/create 0.0.3 → 0.0.5
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/index.js +174 -0
- package/package.json +19 -4
- package/index.js +0 -170
- /package/{templates → dist/templates}/haxcms/course/package.json +0 -0
- /package/{templates → dist/templates}/theme/default/package.json +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/.editorconfig +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/LICENSE +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/README.md +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/index.html +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/lib/webcomponent.haxProperties.json +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/package.json +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/rollup.config.js +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/src/webcomponent.js +0 -0
- /package/{templates → dist/templates}/webcomponent/hax/web-dev-server.config.mjs +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var fs = _interopRequireWildcard(require("node:fs"));
|
|
5
|
+
var path = _interopRequireWildcard(require("node:path"));
|
|
6
|
+
var _promises = require("node:timers/promises");
|
|
7
|
+
var ejs = _interopRequireWildcard(require("ejs"));
|
|
8
|
+
var p = _interopRequireWildcard(require("@clack/prompts"));
|
|
9
|
+
var sh = _interopRequireWildcard(require("sync-exec"));
|
|
10
|
+
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
const exec = sh.default;
|
|
15
|
+
async function main() {
|
|
16
|
+
console.clear();
|
|
17
|
+
// should be able to grab author off the git config in most instances
|
|
18
|
+
let value = await exec(`git config user.name`);
|
|
19
|
+
let author = value.stdout.trim();
|
|
20
|
+
await (0, _promises.setTimeout)(500);
|
|
21
|
+
p.intro(`${_picocolors.default.bgCyan(_picocolors.default.black(` HAX The CLI `))}`);
|
|
22
|
+
const project = await p.group({
|
|
23
|
+
type: ({
|
|
24
|
+
results
|
|
25
|
+
}) => p.select({
|
|
26
|
+
message: `What type of project are you building`,
|
|
27
|
+
initialValue: 'webcomponent',
|
|
28
|
+
maxItems: 3,
|
|
29
|
+
options: [{
|
|
30
|
+
value: 'webcomponent',
|
|
31
|
+
label: 'Web component'
|
|
32
|
+
}, {
|
|
33
|
+
value: 'haxcms',
|
|
34
|
+
label: "HAX Site"
|
|
35
|
+
}, {
|
|
36
|
+
value: 'theme',
|
|
37
|
+
label: "HAX Theme"
|
|
38
|
+
}]
|
|
39
|
+
}),
|
|
40
|
+
typeOption: ({
|
|
41
|
+
results
|
|
42
|
+
}) => {
|
|
43
|
+
switch (results.type) {
|
|
44
|
+
case "webcomponent":
|
|
45
|
+
return p.select({
|
|
46
|
+
message: `What kind of web component do you want to create?`,
|
|
47
|
+
initialValue: 'hax',
|
|
48
|
+
maxItems: 1,
|
|
49
|
+
options: [{
|
|
50
|
+
value: 'hax',
|
|
51
|
+
label: "HAX recommended starter"
|
|
52
|
+
}]
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
case "haxcms":
|
|
56
|
+
return p.select({
|
|
57
|
+
message: `What kind of site is it`,
|
|
58
|
+
initialValue: 'course',
|
|
59
|
+
maxItems: 2,
|
|
60
|
+
options: [{
|
|
61
|
+
value: 'course',
|
|
62
|
+
label: "Course"
|
|
63
|
+
}]
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
case "theme":
|
|
67
|
+
return p.select({
|
|
68
|
+
message: `Theme base`,
|
|
69
|
+
initialValue: 'course',
|
|
70
|
+
maxItems: 2,
|
|
71
|
+
options: [{
|
|
72
|
+
value: 'default',
|
|
73
|
+
label: "Default"
|
|
74
|
+
}]
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
name: ({
|
|
80
|
+
results
|
|
81
|
+
}) => {
|
|
82
|
+
return p.text({
|
|
83
|
+
message: 'Element name:',
|
|
84
|
+
initialValue: "my-element",
|
|
85
|
+
validate: value => {
|
|
86
|
+
if (value.indexOf(' ') !== -1) {
|
|
87
|
+
return "No spaces allowed in project name";
|
|
88
|
+
}
|
|
89
|
+
if (value.indexOf('-') === -1) {
|
|
90
|
+
return "Name must include at least one `-`";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
path: ({
|
|
96
|
+
results
|
|
97
|
+
}) => {
|
|
98
|
+
let initialPath = `${process.cwd()}/${results.name.toLowerCase()}`;
|
|
99
|
+
return p.text({
|
|
100
|
+
message: 'Where should we create your project?',
|
|
101
|
+
initialValue: initialPath
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
author: ({
|
|
105
|
+
results
|
|
106
|
+
}) => {
|
|
107
|
+
return p.text({
|
|
108
|
+
message: 'Author:',
|
|
109
|
+
initialValue: author
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
onCancel: () => {
|
|
114
|
+
p.cancel('Operation cancelled.');
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
if (project.path) {
|
|
119
|
+
project.className = dashToCamel(project.name);
|
|
120
|
+
let s = p.spinner();
|
|
121
|
+
s.start('Copying files');
|
|
122
|
+
await (0, _promises.setTimeout)(250);
|
|
123
|
+
await exec(`cp -R ${path.resolve(path.dirname(''))}/src/templates/${project.type}/${project.typeOption}/ ${project.path}`);
|
|
124
|
+
// rename paths that are of the element name in question
|
|
125
|
+
await exec(`mv ${project.path}/src/webcomponent.js ${project.path}/src/${project.name}.js`);
|
|
126
|
+
await exec(`mv ${project.path}/lib/webcomponent.haxProperties.json ${project.path}/lib/${project.name}.haxProperties.json`);
|
|
127
|
+
s.stop('Files copied');
|
|
128
|
+
await (0, _promises.setTimeout)(250);
|
|
129
|
+
s.start('Making files awesome');
|
|
130
|
+
try {
|
|
131
|
+
for (const filePath of readAllFiles(project.path)) {
|
|
132
|
+
const ejsString = ejs.fileLoader(filePath, 'utf8');
|
|
133
|
+
let content = ejs.render(ejsString, project);
|
|
134
|
+
fs.writeFileSync(filePath, content);
|
|
135
|
+
}
|
|
136
|
+
// file written successfully
|
|
137
|
+
} catch (err) {
|
|
138
|
+
console.error(err);
|
|
139
|
+
}
|
|
140
|
+
s.stop('Files are now awesome!');
|
|
141
|
+
await (0, _promises.setTimeout)(250);
|
|
142
|
+
s.start(`Let's install everything using the magic of yarn`);
|
|
143
|
+
await (0, _promises.setTimeout)(250);
|
|
144
|
+
await exec(`cd ${project.path} && yarn install`);
|
|
145
|
+
await (0, _promises.setTimeout)(250);
|
|
146
|
+
s.stop(`Everything is installed. It's go time`);
|
|
147
|
+
}
|
|
148
|
+
let nextSteps = `cd ${project.path} \nyarn start`;
|
|
149
|
+
p.note(nextSteps, `${project.name} is ready to go. To start development:`);
|
|
150
|
+
p.outro(`Welcome to the revolution. Ideas to HAX faster? ${_picocolors.default.underline(_picocolors.default.cyan('https://github.com/haxtheweb/issues'))}`);
|
|
151
|
+
}
|
|
152
|
+
main().catch(console.error);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Helper to convert dash to camel; important when reading attributes.
|
|
156
|
+
*/
|
|
157
|
+
function dashToCamel(str) {
|
|
158
|
+
return str.replace(/-([a-z])/g, function (g) {
|
|
159
|
+
return g[1].toUpperCase();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// read in all files recursively for rewriting
|
|
163
|
+
function* readAllFiles(dir) {
|
|
164
|
+
const files = fs.readdirSync(dir, {
|
|
165
|
+
withFileTypes: true
|
|
166
|
+
});
|
|
167
|
+
for (const file of files) {
|
|
168
|
+
if (file.isDirectory()) {
|
|
169
|
+
yield* readAllFiles(path.join(dir, file.name));
|
|
170
|
+
} else {
|
|
171
|
+
yield path.join(dir, file.name);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haxtheweb/create",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "Rapidly build web components for the Web that work with HAX",
|
|
8
|
-
"type": "module",
|
|
9
8
|
"author": "HAXTheWeb core team",
|
|
10
9
|
"license": "Apache-2.0",
|
|
11
10
|
"engines": {
|
|
@@ -20,11 +19,15 @@
|
|
|
20
19
|
},
|
|
21
20
|
"homepage": "https://hax.psu.edu/",
|
|
22
21
|
"scripts": {
|
|
23
|
-
"
|
|
22
|
+
"build": "rm -rf dist && babel src --out-dir dist --copy-files --include-dotfiles",
|
|
23
|
+
"start": "npm run build && node ./dist/index.js"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
26
|
-
"create-haxtheweb": "./index.js"
|
|
26
|
+
"create-haxtheweb": "./dist/index.js"
|
|
27
27
|
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
28
31
|
"keywords": [
|
|
29
32
|
"haxtheweb",
|
|
30
33
|
"haxcms",
|
|
@@ -41,5 +44,17 @@
|
|
|
41
44
|
"picocolors": "1.0.1",
|
|
42
45
|
"sync-exec": "0.6.2",
|
|
43
46
|
"ejs": "3.1.10"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/cli": "^7.24.6",
|
|
50
|
+
"@babel/core": "^7.24.6",
|
|
51
|
+
"@babel/register": "^7.24.6",
|
|
52
|
+
"@custom-elements-manifest/analyzer": "^0.10.2",
|
|
53
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
54
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
55
|
+
"@web/rollup-plugin-html": "^2.3.0",
|
|
56
|
+
"@web/rollup-plugin-import-meta-assets": "^2.2.1",
|
|
57
|
+
"babel-plugin-transform-dynamic-import": "^2.1.0",
|
|
58
|
+
"@babel/preset-env": "7.24.6"
|
|
44
59
|
}
|
|
45
60
|
}
|
package/index.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { setTimeout } from 'node:timers/promises';
|
|
4
|
-
import * as ejs from "ejs";
|
|
5
|
-
import * as p from '@clack/prompts';
|
|
6
|
-
import * as sh from "sync-exec";
|
|
7
|
-
const exec = sh.default;
|
|
8
|
-
import color from 'picocolors';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* https://github.com/open-wc/create/blob/master/src/create.js
|
|
12
|
-
* look at how openwc does templating
|
|
13
|
-
* ideally we'd be templating the files from a prebuilt repo and it would be minimal
|
|
14
|
-
* need CLIs for becoming a developer:
|
|
15
|
-
* of a new DDD based element
|
|
16
|
-
* of a new HAXcms stand alone site
|
|
17
|
-
* of a new HAX theme
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
async function main() {
|
|
21
|
-
console.clear();
|
|
22
|
-
// should be able to grab author off the git config in most instances
|
|
23
|
-
let value = await exec(`git config user.name`);
|
|
24
|
-
let author = value.stdout.trim();
|
|
25
|
-
|
|
26
|
-
await setTimeout(500);
|
|
27
|
-
|
|
28
|
-
p.intro(`${color.bgCyan(color.black(` HAX The CLI `))}`);
|
|
29
|
-
|
|
30
|
-
const project = await p.group(
|
|
31
|
-
{
|
|
32
|
-
type: ({ results }) =>
|
|
33
|
-
p.select({
|
|
34
|
-
message: `What type of project are you building`,
|
|
35
|
-
initialValue: 'webcomponent',
|
|
36
|
-
maxItems: 3,
|
|
37
|
-
options: [
|
|
38
|
-
{ value: 'webcomponent', label: 'Web component' },
|
|
39
|
-
{ value: 'haxcms', label: "HAX Site"},
|
|
40
|
-
{ value: 'theme', label: "HAX Theme"},
|
|
41
|
-
],
|
|
42
|
-
}),
|
|
43
|
-
typeOption: ({ results }) => {
|
|
44
|
-
switch (results.type) {
|
|
45
|
-
case "webcomponent":
|
|
46
|
-
return p.select({
|
|
47
|
-
message: `What kind of web component do you want to create?`,
|
|
48
|
-
initialValue: 'hax',
|
|
49
|
-
maxItems: 1,
|
|
50
|
-
options: [
|
|
51
|
-
{ value: 'hax', label: "HAX recommended starter"},
|
|
52
|
-
],
|
|
53
|
-
});
|
|
54
|
-
break;
|
|
55
|
-
case "haxcms":
|
|
56
|
-
return p.select({
|
|
57
|
-
message: `What kind of site is it`,
|
|
58
|
-
initialValue: 'course',
|
|
59
|
-
maxItems: 2,
|
|
60
|
-
options: [
|
|
61
|
-
{ value: 'course', label: "Course" },
|
|
62
|
-
],
|
|
63
|
-
});
|
|
64
|
-
break;
|
|
65
|
-
case "theme":
|
|
66
|
-
return p.select({
|
|
67
|
-
message: `Theme base`,
|
|
68
|
-
initialValue: 'course',
|
|
69
|
-
maxItems: 2,
|
|
70
|
-
options: [
|
|
71
|
-
{ value: 'default', label: "Default" },
|
|
72
|
-
],
|
|
73
|
-
});
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
name: ({ results }) => {
|
|
78
|
-
return p.text({
|
|
79
|
-
message: 'Element name:',
|
|
80
|
-
initialValue: "my-element",
|
|
81
|
-
validate: (value) => {
|
|
82
|
-
if (value.indexOf(' ') !== -1) {
|
|
83
|
-
return "No spaces allowed in project name";
|
|
84
|
-
}
|
|
85
|
-
if (value.indexOf('-') === -1) {
|
|
86
|
-
return "Name must include at least one `-`";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
path: ({ results }) => {
|
|
92
|
-
let initialPath = `${process.cwd()}/${results.name.toLowerCase()}`;
|
|
93
|
-
return p.text({
|
|
94
|
-
message: 'Where should we create your project?',
|
|
95
|
-
initialValue: initialPath,
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
author: ({ results }) => {
|
|
99
|
-
return p.text({
|
|
100
|
-
message: 'Author:',
|
|
101
|
-
initialValue: author,
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
onCancel: () => {
|
|
107
|
-
p.cancel('Operation cancelled.');
|
|
108
|
-
process.exit(0);
|
|
109
|
-
},
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
if (project.path) {
|
|
113
|
-
project.className = dashToCamel(project.name);
|
|
114
|
-
let s = p.spinner();
|
|
115
|
-
s.start('Copying files');
|
|
116
|
-
await setTimeout(250);
|
|
117
|
-
await exec(`cp -R ${path.resolve(path.dirname(''))}/templates/${project.type}/${project.typeOption}/ ${project.path}`);
|
|
118
|
-
// rename paths that are of the element name in question
|
|
119
|
-
await exec(`mv ${project.path}/src/webcomponent.js ${project.path}/src/${project.name}.js`);
|
|
120
|
-
await exec(`mv ${project.path}/lib/webcomponent.haxProperties.json ${project.path}/lib/${project.name}.haxProperties.json`);
|
|
121
|
-
s.stop('Files copied');
|
|
122
|
-
await setTimeout(250);
|
|
123
|
-
s.start('Making files awesome');
|
|
124
|
-
try {
|
|
125
|
-
for (const filePath of readAllFiles(project.path)) {
|
|
126
|
-
const ejsString = ejs.fileLoader(filePath, 'utf8');
|
|
127
|
-
let content = ejs.render(ejsString, project);
|
|
128
|
-
fs.writeFileSync(filePath, content);
|
|
129
|
-
}
|
|
130
|
-
// file written successfully
|
|
131
|
-
} catch (err) {
|
|
132
|
-
console.error(err);
|
|
133
|
-
}
|
|
134
|
-
s.stop('Files are now awesome!');
|
|
135
|
-
await setTimeout(250);
|
|
136
|
-
s.start(`Let's install everything using the magic of yarn`);
|
|
137
|
-
await setTimeout(250);
|
|
138
|
-
await exec(`cd ${project.path} && yarn install`);
|
|
139
|
-
await setTimeout(250);
|
|
140
|
-
s.stop(`Everything is installed. It's go time`);
|
|
141
|
-
}
|
|
142
|
-
let nextSteps = `cd ${project.path} \nyarn start`;
|
|
143
|
-
|
|
144
|
-
p.note(nextSteps, `${project.name} is ready to go. To start development:`);
|
|
145
|
-
|
|
146
|
-
p.outro(`Welcome to the revolution. Ideas to HAX faster? ${color.underline(color.cyan('https://github.com/haxtheweb/issues'))}`);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
main().catch(console.error);
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Helper to convert dash to camel; important when reading attributes.
|
|
153
|
-
*/
|
|
154
|
-
function dashToCamel(str) {
|
|
155
|
-
return str.replace(/-([a-z])/g, function (g) {
|
|
156
|
-
return g[1].toUpperCase();
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
// read in all files recursively for rewriting
|
|
160
|
-
function* readAllFiles(dir) {
|
|
161
|
-
const files = fs.readdirSync(dir, { withFileTypes: true });
|
|
162
|
-
|
|
163
|
-
for (const file of files) {
|
|
164
|
-
if (file.isDirectory()) {
|
|
165
|
-
yield* readAllFiles(path.join(dir, file.name));
|
|
166
|
-
} else {
|
|
167
|
-
yield path.join(dir, file.name);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|