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

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
@@ -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,35 +1,20 @@
1
1
  import shell from "shelljs";
2
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
+ import { BUNDLED_CLIENT_TARBALL_PATH, CLIENT_PATH, MINT_PATH, TARGET_CLIENT_VERSION, VERSION_PATH, } from "../../constants.js";
7
4
  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
- });
5
+ const bootstrapBundledClient = async (logger) => {
6
+ if (!(await pathExists(BUNDLED_CLIENT_TARBALL_PATH))) {
7
+ logger.fail(`Bundled client tarball is missing at: ${BUNDLED_CLIENT_TARBALL_PATH}`);
8
+ process.exit(1);
9
+ }
10
+ await fse.ensureDir(CLIENT_PATH);
11
+ logger.text = "Extracting bundled DocsALot client...";
12
+ const untarResult = shell.exec(`tar -xzf "${BUNDLED_CLIENT_TARBALL_PATH}" -C "${CLIENT_PATH}" --strip-components 1`, { silent: true });
25
13
  if (untarResult.code !== 0) {
26
- logger.fail("Failed to extract DocsALot framework.");
14
+ logger.fail("Failed to extract bundled DocsALot client.");
27
15
  process.exit(1);
28
16
  }
29
- fse.removeSync(tarPath);
30
- fse.moveSync(path.join(tmpPath, "client"), CLIENT_PATH);
31
17
  fse.writeFileSync(VERSION_PATH, TARGET_CLIENT_VERSION);
32
- fse.removeSync(tmpPath);
33
18
  };
34
19
  const installDeps = async () => {
35
20
  const logger = buildLogger("Preparing local DocsALot client...");
@@ -37,12 +22,7 @@ const installDeps = async () => {
37
22
  await fse.ensureDir(MINT_PATH);
38
23
  const clientExists = await pathExists(CLIENT_PATH);
39
24
  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);
25
+ await bootstrapBundledClient(logger);
46
26
  }
47
27
  logger.text = "Installing local DocsALot dependencies...";
48
28
  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",
3
+ "version": "0.1.0-beta.4",
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.3",
33
- "@docsalot/validation": "^0.1.0-beta.3",
32
+ "@docsalot/prebuild": "^0.1.0-beta.4",
33
+ "@docsalot/validation": "^0.1.0-beta.4",
34
34
  "@octokit/rest": "^19.0.5",
35
35
  "axios": "^1.2.2",
36
36
  "chalk": "^5.1.0",