@docsalot/previewing 0.1.0-beta.1 → 0.1.0-beta.3

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 CHANGED
@@ -1,17 +1,13 @@
1
- # @mintlify/previewing
1
+ # @docsalot/previewing
2
2
 
3
- Preview Mintlify docs locally.
3
+ Preview DocsALot docs locally.
4
4
 
5
- ## 🚀 Installation
5
+ ## Installation
6
6
 
7
- ```
8
- npm install @mintlify/previewing
7
+ ```bash
8
+ npm install @docsalot/previewing
9
9
  ```
10
10
 
11
11
  ## Community
12
12
 
13
- Join our Discord community if you have questions or just want to chat:
14
-
15
- [![](https://dcbadge.vercel.app/api/server/ACREKdwjG5)](https://discord.gg/ACREKdwjG5)
16
-
17
- _Built with 💚 by the Mintlify community._
13
+ Discord: https://discord.gg/Dp6EpTv4BU
@@ -1,7 +1,7 @@
1
- export declare const TARGET_MINT_VERSION = "v0.0.9";
1
+ export declare const TARGET_CLIENT_VERSION = "v0.0.9";
2
2
  export declare const INSTALL_PATH: string;
3
3
  export declare const HOME_DIR: string;
4
- export declare const DOT_MINTLIFY: string;
4
+ export declare const DOT_DOCSALOT: string;
5
5
  export declare const VERSION_PATH: string;
6
6
  export declare const CLIENT_PATH: string;
7
7
  export declare const MINT_PATH: string;
package/dist/constants.js CHANGED
@@ -3,19 +3,17 @@
3
3
  import path from "path";
4
4
  import * as url from "url";
5
5
  import os from "os";
6
- // Change this to bump to a newer version of mint's client
7
- export const TARGET_MINT_VERSION = "v0.0.9";
6
+ // Change this to bump to a newer version of the bundled client.
7
+ export const TARGET_CLIENT_VERSION = "v0.0.9";
8
8
  // package installation location
9
9
  export const INSTALL_PATH = url.fileURLToPath(new URL(".", import.meta.url));
10
10
  export const HOME_DIR = os.homedir();
11
- // DOT_MINTLIFY can be overridden via environment variable
12
- // Priority: DOCSALOT_PATH env var > hardcoded local path
13
- // Docker: Set DOCSALOT_PATH=/app/mint-main
14
- const HARDCODED_PATH = '/Users/faizank/workspace/experiments/live_projects/slashml/mint-main';
15
- export const DOT_MINTLIFY = process.env.DOCSALOT_PATH || HARDCODED_PATH;
16
- export const VERSION_PATH = path.join(DOT_MINTLIFY, "mint", "mint-version.txt");
17
- export const CLIENT_PATH = path.join(DOT_MINTLIFY, "client");
18
- export const MINT_PATH = path.join(DOT_MINTLIFY, "mint");
11
+ // DOCSALOT_PATH can be overridden via environment variable.
12
+ // Priority: DOCSALOT_PATH env var > ~/.docsalot
13
+ export const DOT_DOCSALOT = process.env.DOCSALOT_PATH || path.join(HOME_DIR, ".docsalot");
14
+ export const VERSION_PATH = path.join(DOT_DOCSALOT, "mint", "client-version.txt");
15
+ export const CLIENT_PATH = path.join(DOT_DOCSALOT, "client");
16
+ export const MINT_PATH = path.join(DOT_DOCSALOT, "mint");
19
17
  // command execution location
20
18
  export const CMD_EXEC_PATH = process.cwd();
21
19
  export const SUPPORTED_MEDIA_EXTENSIONS = [
@@ -1,11 +1,56 @@
1
1
  import shell from "shelljs";
2
- import { CLIENT_PATH } from "../../constants.js";
2
+ import fse, { pathExists } from "fs-extra";
3
+ import path from "path";
4
+ import { Octokit } from "@octokit/rest";
5
+ import { isInternetAvailable } from "is-internet-available";
6
+ import { CLIENT_PATH, MINT_PATH, TARGET_CLIENT_VERSION, VERSION_PATH, } from "../../constants.js";
3
7
  import { buildLogger, ensureYarn } from "../../util.js";
8
+ const downloadTargetClient = async (logger) => {
9
+ fse.emptyDirSync(MINT_PATH);
10
+ logger.text = "Downloading DocsALot framework...";
11
+ const octokit = new Octokit();
12
+ const downloadRes = await octokit.repos.downloadTarballArchive({
13
+ owner: "slashml",
14
+ repo: "docsalot",
15
+ ref: TARGET_CLIENT_VERSION,
16
+ });
17
+ logger.text = "Extracting DocsALot framework...";
18
+ const tarPath = path.join(MINT_PATH, "mint.tar.gz");
19
+ const tmpPath = path.join(MINT_PATH, "mint-tmp");
20
+ fse.writeFileSync(tarPath, Buffer.from(downloadRes.data));
21
+ fse.mkdirSync(tmpPath, { recursive: true });
22
+ const untarResult = shell.exec(`tar -xzf "${tarPath}" -C "${tmpPath}" --strip-components 1`, {
23
+ silent: true,
24
+ });
25
+ if (untarResult.code !== 0) {
26
+ logger.fail("Failed to extract DocsALot framework.");
27
+ process.exit(1);
28
+ }
29
+ fse.removeSync(tarPath);
30
+ fse.moveSync(path.join(tmpPath, "client"), CLIENT_PATH);
31
+ fse.writeFileSync(VERSION_PATH, TARGET_CLIENT_VERSION);
32
+ fse.removeSync(tmpPath);
33
+ };
4
34
  const installDeps = async () => {
5
- const logger = buildLogger("");
35
+ const logger = buildLogger("Preparing local DocsALot client...");
6
36
  ensureYarn(logger);
37
+ await fse.ensureDir(MINT_PATH);
38
+ const clientExists = await pathExists(CLIENT_PATH);
39
+ if (!clientExists) {
40
+ const internet = await isInternetAvailable();
41
+ if (!internet) {
42
+ logger.fail("First-time setup requires internet to download the local DocsALot framework.");
43
+ process.exit(1);
44
+ }
45
+ await downloadTargetClient(logger);
46
+ }
47
+ logger.text = "Installing local DocsALot dependencies...";
7
48
  shell.cd(CLIENT_PATH);
8
- shell.exec("yarn");
49
+ const installResult = shell.exec("yarn");
50
+ if (installResult.code !== 0) {
51
+ logger.fail("Failed to install dependencies.");
52
+ process.exit(1);
53
+ }
9
54
  logger.succeed("Dependencies installed.");
10
55
  };
11
56
  export default installDeps;
@@ -8,13 +8,12 @@ import { isInternetAvailable } from "is-internet-available";
8
8
  import path from "path";
9
9
  import shell from "shelljs";
10
10
  import { Octokit } from "@octokit/rest";
11
- import { CLIENT_PATH, HOME_DIR, DOT_MINTLIFY, CMD_EXEC_PATH, TARGET_MINT_VERSION, VERSION_PATH, MINT_PATH, } from "../constants.js";
11
+ import { CLIENT_PATH, HOME_DIR, DOT_DOCSALOT, CMD_EXEC_PATH, TARGET_CLIENT_VERSION, VERSION_PATH, MINT_PATH, } from "../constants.js";
12
12
  import { buildLogger, ensureYarn } from "../util.js";
13
13
  import listener from "./listener/index.js";
14
14
  import { getConfigPath } from "./listener/utils/mintConfigFile.js";
15
15
  const nodeModulesExists = async () => {
16
- // return pathExists(path.join(DOT_MINTLIFY, "mint", "client", "node_modules"));
17
- return pathExists(path.join(DOT_MINTLIFY, "client", "node_modules"));
16
+ return pathExists(path.join(DOT_DOCSALOT, "client", "node_modules"));
18
17
  };
19
18
  const promptForYarn = async () => {
20
19
  const yarnInstalled = shell.which("yarn");
@@ -38,16 +37,16 @@ const promptForYarn = async () => {
38
37
  });
39
38
  }
40
39
  };
41
- const downloadTargetMint = async (logger) => {
40
+ const downloadTargetClient = async (logger) => {
42
41
  fse.emptyDirSync(MINT_PATH);
43
- logger.text = "Downloading Mintlify framework...";
42
+ logger.text = "Downloading DocsALot framework...";
44
43
  const octokit = new Octokit();
45
44
  const downloadRes = await octokit.repos.downloadTarballArchive({
46
- owner: "mintlify",
47
- repo: "mint",
48
- ref: TARGET_MINT_VERSION,
45
+ owner: "slashml",
46
+ repo: "docsalot",
47
+ ref: TARGET_CLIENT_VERSION,
49
48
  });
50
- logger.text = "Extracting Mintlify framework...";
49
+ logger.text = "Extracting DocsALot framework...";
51
50
  const TAR_PATH = path.join(MINT_PATH, "mint.tar.gz");
52
51
  fse.writeFileSync(TAR_PATH, Buffer.from(downloadRes.data));
53
52
  // strip-components 1 removes the top level directory from the unzipped content
@@ -58,7 +57,7 @@ const downloadTargetMint = async (logger) => {
58
57
  });
59
58
  fse.removeSync(TAR_PATH);
60
59
  fse.moveSync(path.join(MINT_PATH, "mint-tmp", "client"), path.join(CLIENT_PATH));
61
- fse.writeFileSync(VERSION_PATH, TARGET_MINT_VERSION);
60
+ fse.writeFileSync(VERSION_PATH, TARGET_CLIENT_VERSION);
62
61
  // Delete unnecessary content downloaded from GitHub
63
62
  fse.removeSync(path.join(MINT_PATH, "mint-tmp"));
64
63
  logger.text = "Installing dependencies...";
@@ -66,10 +65,10 @@ const downloadTargetMint = async (logger) => {
66
65
  shell.cd(CLIENT_PATH);
67
66
  shell.exec("yarn", { silent: true });
68
67
  };
69
- const checkForMintJson = async (logger) => {
68
+ const checkForLayoutJson = async (logger) => {
70
69
  const configPath = await getConfigPath(CMD_EXEC_PATH);
71
70
  if (configPath == null) {
72
- logger.fail("Must be ran in a directory where a mint.json file exists.");
71
+ logger.fail("Must be ran in a directory where a layout.json file exists.");
73
72
  process.exit(1);
74
73
  }
75
74
  return;
@@ -83,40 +82,40 @@ const dev = async (argv) => {
83
82
  shell.cd(MINT_PATH);
84
83
  const internet = await isInternetAvailable();
85
84
  if (!internet && !(await pathExists(CLIENT_PATH))) {
86
- logger.fail("Running mintlify dev for the first time requires an internet connection.");
85
+ logger.fail("Running docsalot dev for the first time requires an internet connection.");
87
86
  process.exit(1);
88
87
  }
89
88
  // if (internet) {
90
89
  // const mintVersionExists = await pathExists(VERSION_PATH);
91
- // let needToDownloadTargetMint = !mintVersionExists;
90
+ // let needToDownloadTargetClient = !mintVersionExists;
92
91
  // if (mintVersionExists) {
93
92
  // const currVersion = fse.readFileSync(VERSION_PATH, "utf8");
94
- // if (currVersion !== TARGET_MINT_VERSION) {
95
- // needToDownloadTargetMint = true;
93
+ // if (currVersion !== TARGET_CLIENT_VERSION) {
94
+ // needToDownloadTargetClient = true;
96
95
  // }
97
96
  // }
98
- // if (needToDownloadTargetMint) {
99
- // await downloadTargetMint(logger);
97
+ // if (needToDownloadTargetClient) {
98
+ // await downloadTargetClient(logger);
100
99
  // }
101
100
  // }
102
101
  if (!(await nodeModulesExists())) {
103
102
  if (!internet) {
104
103
  logger.fail(`Dependencies are missing and you are offline. Connect to the internet and run
105
104
 
106
- mintlify install
105
+ docsalot install
107
106
 
108
107
  `);
109
108
  }
110
109
  else {
111
110
  logger.fail(`Dependencies were not installed correctly, run
112
111
 
113
- mintlify install
112
+ docsalot install
114
113
 
115
114
  `);
116
115
  }
117
116
  process.exit(1);
118
117
  }
119
- await checkForMintJson(logger);
118
+ await checkForLayoutJson(logger);
120
119
  shell.cd(CLIENT_PATH);
121
120
  const relativePath = path.relative(CLIENT_PATH, CMD_EXEC_PATH);
122
121
  child_process.spawnSync("yarn preconfigure", [relativePath], { shell: true });
@@ -130,7 +129,7 @@ const run = (port) => {
130
129
  // For local development, use dev-watch (binds to localhost, with file watching)
131
130
  const isProduction = process.env.BIND_ALL_INTERFACES === "true";
132
131
  const devScript = isProduction ? "npm run dev-host" : "npm run dev-watch";
133
- const mintlifyDevProcess = child_process.spawn(devScript, {
132
+ const docsalotDevProcess = child_process.spawn(devScript, {
134
133
  env: {
135
134
  ...process.env,
136
135
  PORT: port,
@@ -139,7 +138,7 @@ const run = (port) => {
139
138
  stdio: "pipe",
140
139
  shell: true,
141
140
  });
142
- mintlifyDevProcess.stdout.on("data", (data) => {
141
+ docsalotDevProcess.stdout.on("data", (data) => {
143
142
  const output = data.toString();
144
143
  console.log(output);
145
144
  if (output.startsWith("> Ready on http://localhost:")) {
@@ -149,7 +148,7 @@ const run = (port) => {
149
148
  }
150
149
  });
151
150
  const onExit = () => {
152
- mintlifyDevProcess.kill("SIGINT");
151
+ docsalotDevProcess.kill("SIGINT");
153
152
  process.exit(0);
154
153
  };
155
154
  process.on("SIGINT", onExit);
@@ -34,7 +34,9 @@ export const categorizeFiles = async (contentDirectoryPath) => {
34
34
  });
35
35
  }
36
36
  }
37
- else if (!filename.endsWith("mint.json") && !isOpenApi) {
37
+ else if (!filename.endsWith("layout.json") &&
38
+ !filename.endsWith("docs.json") &&
39
+ !isOpenApi) {
38
40
  // all other files
39
41
  staticFilenames.push(filename);
40
42
  }
@@ -64,7 +66,7 @@ const supportedStaticFileExtensions = [
64
66
  export const getCategory = (filePath) => {
65
67
  filePath = filePath.toLowerCase();
66
68
  const parsed = path.parse(filePath);
67
- if (parsed.base === "mint.json" || parsed.base === "layout.json") {
69
+ if (parsed.base === "layout.json") {
68
70
  return "mintConfig";
69
71
  }
70
72
  const fileName = parsed.name;
@@ -86,7 +86,7 @@ const listener = () => {
86
86
  console.log(`Snippet deleted: ${filename}`);
87
87
  break;
88
88
  case "mintConfig":
89
- console.log("⚠️ mint.json deleted. Please create a new mint.json file as it is mandatory.");
89
+ console.log("⚠️ layout.json deleted. Please create a new layout.json file as it is mandatory.");
90
90
  process.exit(1);
91
91
  case "potentialJsonOpenApiSpec":
92
92
  case "potentialYamlOpenApiSpec":
@@ -147,9 +147,9 @@ const onUpdateEvent = async (filename) => {
147
147
  break;
148
148
  case "mintConfig":
149
149
  regenerateNav = true;
150
- const mintJsonFileContent = (await readFile(filePath)).toString();
150
+ const layoutJsonFileContent = (await readFile(filePath)).toString();
151
151
  try {
152
- const mintConfig = JSON.parse(mintJsonFileContent);
152
+ const mintConfig = JSON.parse(layoutJsonFileContent);
153
153
  const { status, errors, warnings } = mintValidation.validateMintConfig(mintConfig);
154
154
  errors.forEach((error) => {
155
155
  console.error(`🚨 ${Chalk.red(error)}`);
@@ -163,7 +163,7 @@ const onUpdateEvent = async (filename) => {
163
163
  }
164
164
  catch (error) {
165
165
  if (error.name === "SyntaxError") {
166
- console.error(`🚨 ${Chalk.red("mint.json has invalid JSON. You are likely missing a comma or a bracket. You can paste your mint.json file into https://jsonlint.com/ to get a more specific error message.")}`);
166
+ console.error(`🚨 ${Chalk.red("layout.json has invalid JSON. You are likely missing a comma or a bracket. You can paste your layout.json file into https://jsonlint.com/ to get a more specific error message.")}`);
167
167
  }
168
168
  else {
169
169
  console.error(`🚨 ${Chalk.red(error.message)}`);
@@ -4,10 +4,6 @@ import pathUtil from "path";
4
4
  const { readFile } = _promises;
5
5
  // TODO: Put in prebuild package
6
6
  export const getConfigPath = async (contentDirectoryPath) => {
7
- // Prefer modern config filename, but keep backward compatibility.
8
- if (await pathExists(pathUtil.join(contentDirectoryPath, "mint.json"))) {
9
- return pathUtil.join(contentDirectoryPath, "mint.json");
10
- }
11
7
  if (await pathExists(pathUtil.join(contentDirectoryPath, "layout.json"))) {
12
8
  return pathUtil.join(contentDirectoryPath, "layout.json");
13
9
  }
@@ -7,11 +7,11 @@ import inquirer from "inquirer";
7
7
  import { isInternetAvailable } from "is-internet-available";
8
8
  import path from "path";
9
9
  import shell from "shelljs";
10
- import { CLIENT_PATH, HOME_DIR, DOT_MINTLIFY, CMD_EXEC_PATH, MINT_PATH, } from "../constants.js";
10
+ import { CLIENT_PATH, HOME_DIR, DOT_DOCSALOT, CMD_EXEC_PATH, MINT_PATH, } from "../constants.js";
11
11
  import { buildLogger } from "../util.js";
12
12
  import { getConfigPath } from "./listener/utils/mintConfigFile.js";
13
13
  const nodeModulesExists = async () => {
14
- return pathExists(path.join(DOT_MINTLIFY, "client", "node_modules"));
14
+ return pathExists(path.join(DOT_DOCSALOT, "client", "node_modules"));
15
15
  };
16
16
  const promptForYarn = async () => {
17
17
  const yarnInstalled = shell.which("yarn");
@@ -35,10 +35,10 @@ const promptForYarn = async () => {
35
35
  });
36
36
  }
37
37
  };
38
- const checkForMintJson = async (logger) => {
38
+ const checkForLayoutJson = async (logger) => {
39
39
  const configPath = await getConfigPath(CMD_EXEC_PATH);
40
40
  if (configPath == null) {
41
- logger.fail("Must be ran in a directory where a mint.json file exists.");
41
+ logger.fail("Must be ran in a directory where a layout.json file exists.");
42
42
  process.exit(1);
43
43
  }
44
44
  return;
@@ -46,32 +46,32 @@ const checkForMintJson = async (logger) => {
46
46
  const prod = async (argv) => {
47
47
  shell.cd(HOME_DIR);
48
48
  await promptForYarn();
49
- const logger = buildLogger("Preparing production Mintlify instance...");
49
+ const logger = buildLogger("Preparing production DocsALot instance...");
50
50
  await fse.ensureDir(MINT_PATH);
51
51
  shell.cd(MINT_PATH);
52
52
  const internet = await isInternetAvailable();
53
53
  if (!internet && !(await pathExists(CLIENT_PATH))) {
54
- logger.fail("Running mintlify prod for the first time requires an internet connection.");
54
+ logger.fail("Running docsalot prod for the first time requires an internet connection.");
55
55
  process.exit(1);
56
56
  }
57
57
  if (!(await nodeModulesExists())) {
58
58
  if (!internet) {
59
59
  logger.fail(`Dependencies are missing and you are offline. Connect to the internet and run
60
60
 
61
- mintlify install
61
+ docsalot install
62
62
 
63
63
  `);
64
64
  }
65
65
  else {
66
66
  logger.fail(`Dependencies were not installed correctly, run
67
67
 
68
- mintlify install
68
+ docsalot install
69
69
 
70
70
  `);
71
71
  }
72
72
  process.exit(1);
73
73
  }
74
- await checkForMintJson(logger);
74
+ await checkForLayoutJson(logger);
75
75
  shell.cd(CLIENT_PATH);
76
76
  const relativePath = path.relative(CLIENT_PATH, CMD_EXEC_PATH);
77
77
  child_process.spawnSync("yarn preconfigure", [relativePath], { shell: true });
@@ -95,7 +95,7 @@ const run = (port) => {
95
95
  console.log(`✅ ${Chalk.green("Build complete! Starting production server...")}`);
96
96
  console.log("");
97
97
  // Start the production server (no file watching)
98
- const mintlifyProdProcess = child_process.spawn("npm run start", {
98
+ const docsalotProdProcess = child_process.spawn("npm run start", {
99
99
  env: {
100
100
  ...process.env,
101
101
  PORT: port,
@@ -106,7 +106,7 @@ const run = (port) => {
106
106
  shell: true,
107
107
  });
108
108
  let serverStarted = false;
109
- mintlifyProdProcess.stdout.on("data", (data) => {
109
+ docsalotProdProcess.stdout.on("data", (data) => {
110
110
  const output = data.toString();
111
111
  console.log(output);
112
112
  // Next.js production server outputs "ready" or "started server"
@@ -117,11 +117,11 @@ const run = (port) => {
117
117
  open(`http://localhost:${port}`);
118
118
  }
119
119
  });
120
- mintlifyProdProcess.stderr.on("data", (data) => {
120
+ docsalotProdProcess.stderr.on("data", (data) => {
121
121
  console.error(data.toString());
122
122
  });
123
123
  const onExit = () => {
124
- mintlifyProdProcess.kill("SIGINT");
124
+ docsalotProdProcess.kill("SIGINT");
125
125
  process.exit(0);
126
126
  };
127
127
  process.on("SIGINT", onExit);