@docsalot/previewing 0.1.0-beta.0 → 0.1.0-beta.10
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 +6 -10
- package/dist/assets/client.tar.gz +0 -0
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +9 -10
- package/dist/local-preview/helper-commands/installDepsCommand.js +36 -7
- package/dist/local-preview/helper-commands/syncLocalContentCommand.d.ts +2 -0
- package/dist/local-preview/helper-commands/syncLocalContentCommand.js +75 -0
- package/dist/local-preview/index.js +29 -115
- package/dist/local-preview/listener/categorize.js +18 -2
- package/dist/local-preview/listener/generate.js +18 -5
- package/dist/local-preview/listener/index.d.ts +1 -1
- package/dist/local-preview/listener/index.js +51 -5
- package/dist/local-preview/prod.js +22 -82
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -15
|
@@ -2,103 +2,40 @@
|
|
|
2
2
|
import Chalk from "chalk";
|
|
3
3
|
import child_process from "child_process";
|
|
4
4
|
import open from "open";
|
|
5
|
-
import fse
|
|
6
|
-
import inquirer from "inquirer";
|
|
7
|
-
import { isInternetAvailable } from "is-internet-available";
|
|
8
|
-
import path from "path";
|
|
5
|
+
import fse from "fs-extra";
|
|
9
6
|
import shell from "shelljs";
|
|
10
|
-
import {
|
|
7
|
+
import { HOME_DIR, CLIENT_PATH, CMD_EXEC_PATH, MINT_PATH, } from "../constants.js";
|
|
11
8
|
import { buildLogger } from "../util.js";
|
|
12
9
|
import { getConfigPath } from "./listener/utils/mintConfigFile.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const promptForYarn = async () => {
|
|
17
|
-
const yarnInstalled = shell.which("yarn");
|
|
18
|
-
if (!yarnInstalled) {
|
|
19
|
-
await inquirer
|
|
20
|
-
.prompt([
|
|
21
|
-
{
|
|
22
|
-
type: "confirm",
|
|
23
|
-
name: "confirm",
|
|
24
|
-
message: "yarn must be globally installed. Install yarn?",
|
|
25
|
-
default: true,
|
|
26
|
-
},
|
|
27
|
-
])
|
|
28
|
-
.then(({ confirm }) => {
|
|
29
|
-
if (confirm) {
|
|
30
|
-
shell.exec("npm install --global yarn");
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
console.log("Installation cancelled.");
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const checkForMintJson = async (logger) => {
|
|
10
|
+
import installDepsCommand from "./helper-commands/installDepsCommand.js";
|
|
11
|
+
import syncLocalContentCommand from "./helper-commands/syncLocalContentCommand.js";
|
|
12
|
+
const checkForLayoutJson = async (logger) => {
|
|
39
13
|
const configPath = await getConfigPath(CMD_EXEC_PATH);
|
|
40
14
|
if (configPath == null) {
|
|
41
|
-
logger.fail("Must be ran in a directory where a
|
|
15
|
+
logger.fail("Must be ran in a directory where a layout.json file exists.");
|
|
42
16
|
process.exit(1);
|
|
43
17
|
}
|
|
44
18
|
return;
|
|
45
19
|
};
|
|
46
20
|
const prod = async (argv) => {
|
|
47
21
|
shell.cd(HOME_DIR);
|
|
48
|
-
|
|
49
|
-
const logger = buildLogger("Preparing production Mintlify instance...");
|
|
22
|
+
const logger = buildLogger("Preparing production DocsALot instance...");
|
|
50
23
|
await fse.ensureDir(MINT_PATH);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
if (!(await nodeModulesExists())) {
|
|
58
|
-
if (!internet) {
|
|
59
|
-
logger.fail(`Dependencies are missing and you are offline. Connect to the internet and run
|
|
60
|
-
|
|
61
|
-
mintlify install
|
|
62
|
-
|
|
63
|
-
`);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
logger.fail(`Dependencies were not installed correctly, run
|
|
67
|
-
|
|
68
|
-
mintlify install
|
|
69
|
-
|
|
70
|
-
`);
|
|
71
|
-
}
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
await checkForMintJson(logger);
|
|
75
|
-
shell.cd(CLIENT_PATH);
|
|
76
|
-
const relativePath = path.relative(CLIENT_PATH, CMD_EXEC_PATH);
|
|
77
|
-
child_process.spawnSync("yarn preconfigure", [relativePath], { shell: true });
|
|
24
|
+
await installDepsCommand();
|
|
25
|
+
await checkForLayoutJson(logger);
|
|
26
|
+
logger.text = "Syncing docs content into local runtime...";
|
|
27
|
+
await syncLocalContentCommand();
|
|
78
28
|
logger.succeed("Production instance is ready. Launching your site...");
|
|
79
29
|
run(argv.port || "3000");
|
|
80
30
|
};
|
|
81
31
|
const run = (port) => {
|
|
82
32
|
shell.cd(CLIENT_PATH);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
console.log(`🔨 ${Chalk.cyan("Building production bundle...")}`);
|
|
86
|
-
const buildResult = child_process.spawnSync("npm run build", {
|
|
87
|
-
cwd: CLIENT_PATH,
|
|
88
|
-
stdio: "inherit",
|
|
89
|
-
shell: true,
|
|
90
|
-
});
|
|
91
|
-
if (buildResult.status !== 0) {
|
|
92
|
-
console.error(`${Chalk.red("Build failed. Please fix the errors and try again.")}`);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
console.log(`✅ ${Chalk.green("Build complete! Starting production server...")}`);
|
|
96
|
-
console.log("");
|
|
97
|
-
// Start the production server (no file watching)
|
|
98
|
-
const mintlifyProdProcess = child_process.spawn("npm run start", {
|
|
33
|
+
const host = process.env.BIND_ALL_INTERFACES === "true" ? "0.0.0.0" : "127.0.0.1";
|
|
34
|
+
const docsalotProdProcess = child_process.spawn("node server.js", {
|
|
99
35
|
env: {
|
|
100
36
|
...process.env,
|
|
101
37
|
PORT: port,
|
|
38
|
+
HOSTNAME: host,
|
|
102
39
|
NODE_ENV: "production",
|
|
103
40
|
},
|
|
104
41
|
cwd: CLIENT_PATH,
|
|
@@ -106,22 +43,25 @@ const run = (port) => {
|
|
|
106
43
|
shell: true,
|
|
107
44
|
});
|
|
108
45
|
let serverStarted = false;
|
|
109
|
-
|
|
46
|
+
docsalotProdProcess.stdout.on("data", (data) => {
|
|
110
47
|
const output = data.toString();
|
|
111
48
|
console.log(output);
|
|
112
|
-
|
|
113
|
-
|
|
49
|
+
if (!serverStarted &&
|
|
50
|
+
(output.includes("started server") ||
|
|
51
|
+
output.includes("ready") ||
|
|
52
|
+
output.includes("Ready in") ||
|
|
53
|
+
output.includes("http://localhost:"))) {
|
|
114
54
|
serverStarted = true;
|
|
115
55
|
console.log(`🌿 ${Chalk.green(`Your production preview is available at http://localhost:${port}`)}`);
|
|
116
56
|
console.log(`🌿 ${Chalk.green("Press Ctrl+C any time to stop the production preview.")}`);
|
|
117
57
|
open(`http://localhost:${port}`);
|
|
118
58
|
}
|
|
119
59
|
});
|
|
120
|
-
|
|
60
|
+
docsalotProdProcess.stderr.on("data", (data) => {
|
|
121
61
|
console.error(data.toString());
|
|
122
62
|
});
|
|
123
63
|
const onExit = () => {
|
|
124
|
-
|
|
64
|
+
docsalotProdProcess.kill("SIGINT");
|
|
125
65
|
process.exit(0);
|
|
126
66
|
};
|
|
127
67
|
process.on("SIGINT", onExit);
|