@docsalot/previewing 0.1.0-beta.3 → 0.1.0-beta.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.
|
Binary file
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const TARGET_CLIENT_VERSION = "v0.0.9";
|
|
2
2
|
export declare const INSTALL_PATH: string;
|
|
3
|
+
export declare const BUNDLED_CLIENT_TARBALL_PATH: string;
|
|
3
4
|
export declare const HOME_DIR: string;
|
|
4
5
|
export declare const DOT_DOCSALOT: string;
|
|
5
6
|
export declare const VERSION_PATH: string;
|
package/dist/constants.js
CHANGED
|
@@ -7,6 +7,7 @@ import os from "os";
|
|
|
7
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
|
+
export const BUNDLED_CLIENT_TARBALL_PATH = path.join(INSTALL_PATH, "assets", "client.tar.gz");
|
|
10
11
|
export const HOME_DIR = os.homedir();
|
|
11
12
|
// DOCSALOT_PATH can be overridden via environment variable.
|
|
12
13
|
// Priority: DOCSALOT_PATH env var > ~/.docsalot
|
|
@@ -1,56 +1,53 @@
|
|
|
1
1
|
import shell from "shelljs";
|
|
2
2
|
import fse, { pathExists } from "fs-extra";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import {
|
|
5
|
-
import { isInternetAvailable } from "is-internet-available";
|
|
6
|
-
import { CLIENT_PATH, MINT_PATH, TARGET_CLIENT_VERSION, VERSION_PATH, } from "../../constants.js";
|
|
4
|
+
import { BUNDLED_CLIENT_TARBALL_PATH, CLIENT_PATH, MINT_PATH, TARGET_CLIENT_VERSION, VERSION_PATH, } from "../../constants.js";
|
|
7
5
|
import { buildLogger, ensureYarn } from "../../util.js";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
});
|
|
6
|
+
const bootstrapBundledClient = async (logger) => {
|
|
7
|
+
if (!(await pathExists(BUNDLED_CLIENT_TARBALL_PATH))) {
|
|
8
|
+
logger.fail(`Bundled client tarball is missing at: ${BUNDLED_CLIENT_TARBALL_PATH}`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
await fse.ensureDir(CLIENT_PATH);
|
|
12
|
+
logger.text = "Extracting bundled DocsALot client...";
|
|
13
|
+
const untarResult = shell.exec(`tar -xzf "${BUNDLED_CLIENT_TARBALL_PATH}" -C "${CLIENT_PATH}" --strip-components 1`, { silent: true });
|
|
25
14
|
if (untarResult.code !== 0) {
|
|
26
|
-
logger.fail("Failed to extract DocsALot
|
|
15
|
+
logger.fail("Failed to extract bundled DocsALot client.");
|
|
27
16
|
process.exit(1);
|
|
28
17
|
}
|
|
29
|
-
fse.removeSync(tarPath);
|
|
30
|
-
fse.moveSync(path.join(tmpPath, "client"), CLIENT_PATH);
|
|
31
18
|
fse.writeFileSync(VERSION_PATH, TARGET_CLIENT_VERSION);
|
|
32
|
-
|
|
19
|
+
};
|
|
20
|
+
const shouldBootstrapClient = async () => {
|
|
21
|
+
const clientExists = await pathExists(CLIENT_PATH);
|
|
22
|
+
if (!clientExists)
|
|
23
|
+
return true;
|
|
24
|
+
if (!(await pathExists(VERSION_PATH)))
|
|
25
|
+
return true;
|
|
26
|
+
const installedVersion = fse.readFileSync(VERSION_PATH, "utf8").trim();
|
|
27
|
+
return installedVersion !== TARGET_CLIENT_VERSION;
|
|
33
28
|
};
|
|
34
29
|
const installDeps = async () => {
|
|
35
30
|
const logger = buildLogger("Preparing local DocsALot client...");
|
|
36
31
|
ensureYarn(logger);
|
|
37
32
|
await fse.ensureDir(MINT_PATH);
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const needsBootstrap = await shouldBootstrapClient();
|
|
34
|
+
if (needsBootstrap) {
|
|
35
|
+
await fse.remove(CLIENT_PATH);
|
|
36
|
+
await bootstrapBundledClient(logger);
|
|
37
|
+
}
|
|
38
|
+
const nodeModulesPath = path.join(CLIENT_PATH, "node_modules");
|
|
39
|
+
const dependenciesInstalled = await pathExists(nodeModulesPath);
|
|
40
|
+
if (!dependenciesInstalled || needsBootstrap) {
|
|
41
|
+
logger.text = "Installing local DocsALot dependencies...";
|
|
42
|
+
shell.cd(CLIENT_PATH);
|
|
43
|
+
const installResult = shell.exec("yarn");
|
|
44
|
+
if (installResult.code !== 0) {
|
|
45
|
+
logger.fail("Failed to install dependencies.");
|
|
43
46
|
process.exit(1);
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
logger.text = "Installing local DocsALot dependencies...";
|
|
48
|
-
shell.cd(CLIENT_PATH);
|
|
49
|
-
const installResult = shell.exec("yarn");
|
|
50
|
-
if (installResult.code !== 0) {
|
|
51
|
-
logger.fail("Failed to install dependencies.");
|
|
52
|
-
process.exit(1);
|
|
48
|
+
logger.succeed("Dependencies installed.");
|
|
49
|
+
return;
|
|
53
50
|
}
|
|
54
|
-
logger.succeed("Dependencies installed.");
|
|
51
|
+
logger.succeed("Dependencies already installed.");
|
|
55
52
|
};
|
|
56
53
|
export default installDeps;
|
|
@@ -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 {
|
|
11
|
-
import {
|
|
12
|
-
import { buildLogger, ensureYarn } from "../util.js";
|
|
10
|
+
import { CLIENT_PATH, HOME_DIR, DOT_DOCSALOT, CMD_EXEC_PATH, MINT_PATH, } from "../constants.js";
|
|
11
|
+
import { buildLogger } from "../util.js";
|
|
13
12
|
import listener from "./listener/index.js";
|
|
14
13
|
import { getConfigPath } from "./listener/utils/mintConfigFile.js";
|
|
14
|
+
import installDepsCommand from "./helper-commands/installDepsCommand.js";
|
|
15
15
|
const nodeModulesExists = async () => {
|
|
16
16
|
return pathExists(path.join(DOT_DOCSALOT, "client", "node_modules"));
|
|
17
17
|
};
|
|
@@ -37,34 +37,6 @@ const promptForYarn = async () => {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
const downloadTargetClient = async (logger) => {
|
|
41
|
-
fse.emptyDirSync(MINT_PATH);
|
|
42
|
-
logger.text = "Downloading DocsALot framework...";
|
|
43
|
-
const octokit = new Octokit();
|
|
44
|
-
const downloadRes = await octokit.repos.downloadTarballArchive({
|
|
45
|
-
owner: "slashml",
|
|
46
|
-
repo: "docsalot",
|
|
47
|
-
ref: TARGET_CLIENT_VERSION,
|
|
48
|
-
});
|
|
49
|
-
logger.text = "Extracting DocsALot framework...";
|
|
50
|
-
const TAR_PATH = path.join(MINT_PATH, "mint.tar.gz");
|
|
51
|
-
fse.writeFileSync(TAR_PATH, Buffer.from(downloadRes.data));
|
|
52
|
-
// strip-components 1 removes the top level directory from the unzipped content
|
|
53
|
-
// which is a folder with the release sha
|
|
54
|
-
fse.mkdirSync(path.join(MINT_PATH, "mint-tmp"));
|
|
55
|
-
shell.exec("tar -xzf mint.tar.gz -C mint-tmp --strip-components 1", {
|
|
56
|
-
silent: true,
|
|
57
|
-
});
|
|
58
|
-
fse.removeSync(TAR_PATH);
|
|
59
|
-
fse.moveSync(path.join(MINT_PATH, "mint-tmp", "client"), path.join(CLIENT_PATH));
|
|
60
|
-
fse.writeFileSync(VERSION_PATH, TARGET_CLIENT_VERSION);
|
|
61
|
-
// Delete unnecessary content downloaded from GitHub
|
|
62
|
-
fse.removeSync(path.join(MINT_PATH, "mint-tmp"));
|
|
63
|
-
logger.text = "Installing dependencies...";
|
|
64
|
-
ensureYarn(logger);
|
|
65
|
-
shell.cd(CLIENT_PATH);
|
|
66
|
-
shell.exec("yarn", { silent: true });
|
|
67
|
-
};
|
|
68
40
|
const checkForLayoutJson = async (logger) => {
|
|
69
41
|
const configPath = await getConfigPath(CMD_EXEC_PATH);
|
|
70
42
|
if (configPath == null) {
|
|
@@ -81,23 +53,6 @@ const dev = async (argv) => {
|
|
|
81
53
|
await fse.ensureDir(MINT_PATH);
|
|
82
54
|
shell.cd(MINT_PATH);
|
|
83
55
|
const internet = await isInternetAvailable();
|
|
84
|
-
if (!internet && !(await pathExists(CLIENT_PATH))) {
|
|
85
|
-
logger.fail("Running docsalot dev for the first time requires an internet connection.");
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
// if (internet) {
|
|
89
|
-
// const mintVersionExists = await pathExists(VERSION_PATH);
|
|
90
|
-
// let needToDownloadTargetClient = !mintVersionExists;
|
|
91
|
-
// if (mintVersionExists) {
|
|
92
|
-
// const currVersion = fse.readFileSync(VERSION_PATH, "utf8");
|
|
93
|
-
// if (currVersion !== TARGET_CLIENT_VERSION) {
|
|
94
|
-
// needToDownloadTargetClient = true;
|
|
95
|
-
// }
|
|
96
|
-
// }
|
|
97
|
-
// if (needToDownloadTargetClient) {
|
|
98
|
-
// await downloadTargetClient(logger);
|
|
99
|
-
// }
|
|
100
|
-
// }
|
|
101
56
|
if (!(await nodeModulesExists())) {
|
|
102
57
|
if (!internet) {
|
|
103
58
|
logger.fail(`Dependencies are missing and you are offline. Connect to the internet and run
|
|
@@ -105,15 +60,10 @@ const dev = async (argv) => {
|
|
|
105
60
|
docsalot install
|
|
106
61
|
|
|
107
62
|
`);
|
|
63
|
+
process.exit(1);
|
|
108
64
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
docsalot install
|
|
113
|
-
|
|
114
|
-
`);
|
|
115
|
-
}
|
|
116
|
-
process.exit(1);
|
|
65
|
+
logger.info("Dependencies missing; running first-time bootstrap...");
|
|
66
|
+
await installDepsCommand();
|
|
117
67
|
}
|
|
118
68
|
await checkForLayoutJson(logger);
|
|
119
69
|
shell.cd(CLIENT_PATH);
|
|
@@ -10,6 +10,7 @@ import shell from "shelljs";
|
|
|
10
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
|
+
import installDepsCommand from "./helper-commands/installDepsCommand.js";
|
|
13
14
|
const nodeModulesExists = async () => {
|
|
14
15
|
return pathExists(path.join(DOT_DOCSALOT, "client", "node_modules"));
|
|
15
16
|
};
|
|
@@ -50,10 +51,6 @@ const prod = async (argv) => {
|
|
|
50
51
|
await fse.ensureDir(MINT_PATH);
|
|
51
52
|
shell.cd(MINT_PATH);
|
|
52
53
|
const internet = await isInternetAvailable();
|
|
53
|
-
if (!internet && !(await pathExists(CLIENT_PATH))) {
|
|
54
|
-
logger.fail("Running docsalot prod for the first time requires an internet connection.");
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
54
|
if (!(await nodeModulesExists())) {
|
|
58
55
|
if (!internet) {
|
|
59
56
|
logger.fail(`Dependencies are missing and you are offline. Connect to the internet and run
|
|
@@ -61,15 +58,10 @@ const prod = async (argv) => {
|
|
|
61
58
|
docsalot install
|
|
62
59
|
|
|
63
60
|
`);
|
|
61
|
+
process.exit(1);
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
docsalot install
|
|
69
|
-
|
|
70
|
-
`);
|
|
71
|
-
}
|
|
72
|
-
process.exit(1);
|
|
63
|
+
logger.info("Dependencies missing; running first-time bootstrap...");
|
|
64
|
+
await installDepsCommand();
|
|
73
65
|
}
|
|
74
66
|
await checkForLayoutJson(logger);
|
|
75
67
|
shell.cd(CLIENT_PATH);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docsalot/previewing",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.5",
|
|
4
4
|
"description": "Preview DocsALot docs locally",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
32
|
-
"@docsalot/prebuild": "^0.1.0-beta.
|
|
33
|
-
"@docsalot/validation": "^0.1.0-beta.
|
|
32
|
+
"@docsalot/prebuild": "^0.1.0-beta.5",
|
|
33
|
+
"@docsalot/validation": "^0.1.0-beta.5",
|
|
34
34
|
"@octokit/rest": "^19.0.5",
|
|
35
35
|
"axios": "^1.2.2",
|
|
36
36
|
"chalk": "^5.1.0",
|