@haxtheweb/create 10.0.6 → 10.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/dist/create.js
CHANGED
|
@@ -16,6 +16,7 @@ var hax = _interopRequireWildcard(require("@haxtheweb/haxcms-nodejs"));
|
|
|
16
16
|
var child_process = _interopRequireWildcard(require("child_process"));
|
|
17
17
|
var util = _interopRequireWildcard(require("node:util"));
|
|
18
18
|
var _commander = require("commander");
|
|
19
|
+
var _package = _interopRequireDefault(require("../package.json"));
|
|
19
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
21
|
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); }
|
|
21
22
|
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; }
|
|
@@ -45,7 +46,7 @@ async function main() {
|
|
|
45
46
|
.option('--org <char>', 'organization for package.json').option('--author <char>', 'author for site / package.json').option('--writeHaxProperties', 'Write haxProperties for the element')
|
|
46
47
|
|
|
47
48
|
// options for site
|
|
48
|
-
.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)').version(
|
|
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)').version(_package.default.version).helpCommand(true);
|
|
49
50
|
|
|
50
51
|
// default command which runs interactively
|
|
51
52
|
_commander.program.command('start').description('Select which hax sub-program to run').action(() => {
|
|
@@ -71,7 +72,7 @@ async function main() {
|
|
|
71
72
|
commandRun.arguments.action = action;
|
|
72
73
|
commandRun.options.skip = true;
|
|
73
74
|
}
|
|
74
|
-
}).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('--quiet', 'remove console logging').option('--auto', 'yes to all questions, alias of y').option('--no-i', 'prevent interactions / sub-process, good for scripting').option('--to-file <char>', 'redirect command output to a file').option('--no-extras', 'skip all extra / automatic command processing').option('--root <char>', 'root location to execute the command from').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').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)').version(
|
|
75
|
+
}).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('--quiet', 'remove console logging').option('--auto', 'yes to all questions, alias of y').option('--no-i', 'prevent interactions / sub-process, good for scripting').option('--to-file <char>', 'redirect command output to a file').option('--no-extras', 'skip all extra / automatic command processing').option('--root <char>', 'root location to execute the command from').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').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)').version(_package.default.version);
|
|
75
76
|
let siteNodeOps = (0, _site.siteNodeOperations)();
|
|
76
77
|
for (var i in siteNodeOps) {
|
|
77
78
|
_commander.program.option(`--${(0, _utils.camelToDash)(siteNodeOps[i].value)} <char>`, `${siteNodeOps[i].label}`);
|
|
@@ -94,7 +95,7 @@ async function main() {
|
|
|
94
95
|
commandRun.arguments.action = action;
|
|
95
96
|
commandRun.options.skip = true;
|
|
96
97
|
}
|
|
97
|
-
}).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('--name <char>', 'name of the web component').option('--writeHaxProperties', 'Write haxProperties for the element').option('--to-file <char>', 'redirect command output to a file').option('--no-extras', 'skip all extra / automatic command processing').option('--no-i', 'prevent interactions / sub-process, good for scripting').option('--root <char>', 'root location to execute the command from').version(
|
|
98
|
+
}).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('--name <char>', 'name of the web component').option('--writeHaxProperties', 'Write haxProperties for the element').option('--to-file <char>', 'redirect command output to a file').option('--no-extras', 'skip all extra / automatic command processing').option('--no-i', 'prevent interactions / sub-process, good for scripting').option('--root <char>', 'root location to execute the command from').version(_package.default.version);
|
|
98
99
|
|
|
99
100
|
// audit program
|
|
100
101
|
_commander.program.command('audit').description('Audits web components for compliance with DDD (HAX design system)').action(() => {
|
|
@@ -103,7 +104,7 @@ async function main() {
|
|
|
103
104
|
arguments: {},
|
|
104
105
|
options: {}
|
|
105
106
|
};
|
|
106
|
-
}).option('--debug', 'Output for developers').version(
|
|
107
|
+
}).option('--debug', 'Output for developers').version(_package.default.version);
|
|
107
108
|
|
|
108
109
|
// process program arguments
|
|
109
110
|
_commander.program.parse();
|
|
@@ -599,7 +600,7 @@ async function main() {
|
|
|
599
600
|
};
|
|
600
601
|
}
|
|
601
602
|
project.year = new Date().getFullYear();
|
|
602
|
-
project.version =
|
|
603
|
+
project.version = _package.default.version;
|
|
603
604
|
if (!project.name && commandRun.arguments.action) {
|
|
604
605
|
project.name = commandRun.arguments.action;
|
|
605
606
|
}
|
|
@@ -41,6 +41,26 @@ _microFrontendRegistry.MicroFrontendRegistry.enableServices(['core', 'haxcms', '
|
|
|
41
41
|
const JSONOutlineSchema = josfile.default;
|
|
42
42
|
const HAXCMS = hax.HAXCMS;
|
|
43
43
|
const exec = util.promisify(child_process.exec);
|
|
44
|
+
const spawn = child_process.spawn;
|
|
45
|
+
async function interactiveExec(command, args = [], options = {}) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
process.env.NODE_NO_WARNINGS = 1;
|
|
48
|
+
const child = spawn(command, args, {
|
|
49
|
+
stdio: 'inherit',
|
|
50
|
+
...options
|
|
51
|
+
});
|
|
52
|
+
child.on('exit', code => {
|
|
53
|
+
if (code === 0) {
|
|
54
|
+
resolve();
|
|
55
|
+
} else {
|
|
56
|
+
reject(new Error(`Command failed with code ${code}`));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
child.on('error', err => {
|
|
60
|
+
reject(err);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
44
64
|
var sysSurge = true;
|
|
45
65
|
exec('surge --version', error => {
|
|
46
66
|
if (error) {
|
|
@@ -837,23 +857,26 @@ async function siteCommandDetected(commandRun) {
|
|
|
837
857
|
(0, _logging.log)(execOutput.stdout.trim());
|
|
838
858
|
sysSurge = true;
|
|
839
859
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
860
|
+
let execOutput;
|
|
861
|
+
if (commandRun.options.domain && commandRun.options.y) {
|
|
862
|
+
let s = p.spinner();
|
|
863
|
+
s.start((0, _statements.merlinSays)('Sending site to Surge.sh ..'));
|
|
864
|
+
execOutput = await exec(`cd ${activeHaxsite.directory} && surge . ${commandRun.options.domain}`);
|
|
865
|
+
(0, _logging.log)(execOutput.stdout.trim());
|
|
866
|
+
s.stop((0, _statements.merlinSays)(`Site published: https://${commandRun.options.domain}`));
|
|
867
|
+
} else {
|
|
868
|
+
let surgeArgs = ['.'];
|
|
869
|
+
// could get here bc of being interactive, yet passed in a domain...
|
|
870
|
+
if (commandRun.options.domain) {
|
|
871
|
+
surgeArgs.push(commandRun.options.domain);
|
|
872
|
+
}
|
|
873
|
+
execOutput = await interactiveExec('surge', surgeArgs, {
|
|
874
|
+
cwd: activeHaxsite.directory
|
|
851
875
|
});
|
|
876
|
+
(0, _logging.log)((0, _statements.merlinSays)(`Site published: https://${commandRun.options.domain}`));
|
|
852
877
|
}
|
|
853
|
-
let execOutput = await exec(`cd ${activeHaxsite.directory} && surge . ${commandRun.options.domain}`);
|
|
854
|
-
(0, _logging.log)(execOutput.stdout.trim());
|
|
855
|
-
(0, _logging.log)(`Site published: https://${commandRun.options.domain}`);
|
|
856
878
|
} catch (e) {
|
|
879
|
+
console.log("?");
|
|
857
880
|
(0, _logging.log)(e.stderr);
|
|
858
881
|
}
|
|
859
882
|
break;
|
|
@@ -1123,9 +1146,6 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1123
1146
|
project.extras = ['launch'];
|
|
1124
1147
|
}
|
|
1125
1148
|
}
|
|
1126
|
-
if (!commandRun.options.quiet) {
|
|
1127
|
-
s.start((0, _statements.merlinSays)(`Creating new site: ${project.name}`));
|
|
1128
|
-
}
|
|
1129
1149
|
let siteRequest = {
|
|
1130
1150
|
"site": {
|
|
1131
1151
|
"name": project.name,
|
|
@@ -1241,9 +1261,18 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1241
1261
|
}
|
|
1242
1262
|
HAXCMS.cliWritePath = `${project.path}`;
|
|
1243
1263
|
let res = new Res();
|
|
1264
|
+
// unfortunately the twig exception is not blockable from output at this layer
|
|
1244
1265
|
await hax.RoutesMap.post.createSite({
|
|
1245
1266
|
body: siteRequest
|
|
1246
1267
|
}, res);
|
|
1268
|
+
// so we run it and then clear the screen
|
|
1269
|
+
// this is a bit of a hack but it works to give the user the feedback that the site was
|
|
1270
|
+
// created successfully, but only if not in quiet mode (default)
|
|
1271
|
+
if (!commandRun.options.quiet) {
|
|
1272
|
+
process.stdout.write('\x1Bc');
|
|
1273
|
+
s.start((0, _statements.merlinSays)(`Creating new site: ${project.name}`));
|
|
1274
|
+
await (0, _promises.setTimeout)(1000);
|
|
1275
|
+
}
|
|
1247
1276
|
// path different for this one as it's on the fly produced
|
|
1248
1277
|
const recipeFileName = path.join(project.path, '/', project.name, `${siteRecipeFile}`);
|
|
1249
1278
|
const recipeLogTransport = new winston.transports.File({
|
|
@@ -1270,7 +1299,7 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1270
1299
|
}
|
|
1271
1300
|
}
|
|
1272
1301
|
if (!commandRun.options.quiet) {
|
|
1273
|
-
s.stop((0, _statements.merlinSays)(`${project.name} created!`));
|
|
1302
|
+
s.stop((0, _statements.merlinSays)(`${project.name} created successfully!`));
|
|
1274
1303
|
await (0, _promises.setTimeout)(500);
|
|
1275
1304
|
}
|
|
1276
1305
|
|
|
@@ -1285,6 +1314,16 @@ async function siteProcess(commandRun, project, port = '3000') {
|
|
|
1285
1314
|
await exec(`cd ${project.path}/${project.name} && git init && git add -A && git commit -m "first commit" && git branch -M main${project.gitRepo ? ` && git remote add origin ${project.gitRepo}` : ''}`);
|
|
1286
1315
|
} catch (e) {}
|
|
1287
1316
|
}
|
|
1317
|
+
// ensure dot files is there because it doesn't copy for some reason for sites :\
|
|
1318
|
+
if (!fs.existsSync(`${project.path}/${project.name}/.gitignore`)) {
|
|
1319
|
+
await fs.copyFileSync(`${process.mainModule.path}/templates/sitedotfiles/_gitignore`, `${project.path}/${project.name}/.gitignore`);
|
|
1320
|
+
}
|
|
1321
|
+
if (!fs.existsSync(`${project.path}/${project.name}/._npmignore`)) {
|
|
1322
|
+
await fs.copyFileSync(`${process.mainModule.path}/templates/sitedotfiles/_npmignore`, `${project.path}/${project.name}/.npmignore`);
|
|
1323
|
+
}
|
|
1324
|
+
if (!fs.existsSync(`${project.path}/${project.name}/._surgeignore`)) {
|
|
1325
|
+
await fs.copyFileSync(`${process.mainModule.path}/templates/sitedotfiles/_surgeignore`, `${project.path}/${project.name}/.surgeignore`);
|
|
1326
|
+
}
|
|
1288
1327
|
// options for install, git and other extras
|
|
1289
1328
|
// can't launch if we didn't install first so launch implies installation
|
|
1290
1329
|
if (project.extras && project.extras.includes && project.extras.includes('launch')) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node_modules
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!node_modules/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haxtheweb/create",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@clack/core": "0.3.4",
|
|
47
47
|
"@clack/prompts": "0.7.0",
|
|
48
|
-
"@haxtheweb/haxcms-nodejs": "^10.0.
|
|
48
|
+
"@haxtheweb/haxcms-nodejs": "^10.0.6",
|
|
49
49
|
"@haxtheweb/open-apis": "^10.0.1",
|
|
50
50
|
"commander": "12.1.0",
|
|
51
51
|
"ejs": "3.1.10",
|
|
@@ -55,10 +55,11 @@
|
|
|
55
55
|
"winston": "3.17.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/preset-env": "7.
|
|
61
|
-
"@babel/register": "^7.
|
|
58
|
+
"@babel/cli": "^7.27.0",
|
|
59
|
+
"@babel/core": "^7.26.10",
|
|
60
|
+
"@babel/preset-env": "^7.26.9",
|
|
61
|
+
"@babel/register": "^7.25.9",
|
|
62
|
+
"@babel/plugin-syntax-import-attributes": "^7.26.0",
|
|
62
63
|
"@custom-elements-manifest/analyzer": "^0.10.3",
|
|
63
64
|
"babel-plugin-transform-dynamic-import": "^2.1.0",
|
|
64
65
|
"commit-and-tag-version": "12.4.1",
|