@mxpicture/build-api 0.2.5 → 0.2.6

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.
@@ -1,6 +1,6 @@
1
1
  import { activeProfile, defaultSettingsPath } from "./vscode.profiles.js";
2
2
  import { readFile } from "fs/promises";
3
- import pkg from "json5";
3
+ import json5 from "json5";
4
4
  let __settings = null;
5
5
  export const vscodeSettings = async (dir) => {
6
6
  if (!__settings) {
@@ -12,7 +12,7 @@ export const vscodeSettings = async (dir) => {
12
12
  settingsPath = defaultSettingsPath();
13
13
  }
14
14
  const raw = await readFile(settingsPath, "utf-8");
15
- __settings = pkg.parse(raw);
15
+ __settings = json5.parse(raw);
16
16
  if (!__settings)
17
17
  throw new Error("No settings found");
18
18
  }
@@ -1,6 +1,6 @@
1
1
  import * as fs from "fs";
2
2
  import { join } from "path";
3
- import pkg from "json5";
3
+ import json5 from "json5";
4
4
  import { configUserPath } from "./vscode.config.js";
5
5
  export const storagePath = () => join(configUserPath(), "globalStorage", "storage.json");
6
6
  let __storage;
@@ -8,7 +8,7 @@ export const storage = () => {
8
8
  if (__storage)
9
9
  return __storage;
10
10
  const content = fs.readFileSync(storagePath()).toString();
11
- __storage = pkg.parse(content);
11
+ __storage = json5.parse(content);
12
12
  if (!__storage)
13
13
  throw new Error("VS Code storage.json could not be loaded");
14
14
  return __storage;
@@ -1,12 +1,12 @@
1
1
  import { readFile } from "fs/promises";
2
- import pkg from "json5";
2
+ import json5 from "json5";
3
3
  import { dirname } from "path";
4
4
  const __workspaces = {};
5
5
  export const vscodeWorkspace = async (workspaceFile) => {
6
6
  let found = __workspaces[workspaceFile];
7
7
  if (!found) {
8
8
  const raw = await readFile(workspaceFile, "utf-8");
9
- found = pkg.parse(raw);
9
+ found = json5.parse(raw);
10
10
  __workspaces[workspaceFile] = found;
11
11
  }
12
12
  return { ...found };
@@ -1,8 +1,9 @@
1
1
  import { readdir, readFile, writeFile } from "fs/promises";
2
2
  import { WorkspaceFileType, } from "../types/types.workspace.js";
3
- import { join, parse, relative, resolve } from "path";
3
+ import { join, relative, resolve } from "path";
4
4
  import { splitVersion, compareVersions, concatVersion, } from "../pkg/pkg.common.js";
5
- import pkg from "json5";
5
+ import json5 from "json5";
6
+ import { parse } from "yaml";
6
7
  export const DEFAULT_WORKSPACE_FILE_ENDING = ".code-workspace";
7
8
  export const getFileType = (filename) => filename.endsWith(DEFAULT_WORKSPACE_FILE_ENDING)
8
9
  ? WorkspaceFileType.workspace
@@ -18,8 +19,9 @@ export const findWorkspaceRoot = async (startPath) => {
18
19
  const promises = [];
19
20
  while (path.length > 0) {
20
21
  promises.push((async () => {
22
+ const workingPath = path.substring(0);
21
23
  const l = level;
22
- const entries = await readdir(path, { withFileTypes: true });
24
+ const entries = await readdir(workingPath, { withFileTypes: true });
23
25
  let pkg = null;
24
26
  for (const entry of entries) {
25
27
  if (!entry.isFile())
@@ -27,16 +29,16 @@ export const findWorkspaceRoot = async (startPath) => {
27
29
  const type = getFileType(entry.name);
28
30
  if (type === WorkspaceFileType.workspace)
29
31
  return {
30
- filePath: join(path, entry.name),
31
- dirPath: path,
32
+ filePath: join(workingPath, entry.name),
33
+ dirPath: workingPath,
32
34
  filename: entry.name,
33
35
  level: l,
34
36
  type,
35
37
  };
36
38
  if (!pkg && type === WorkspaceFileType.package)
37
39
  pkg = {
38
- filePath: join(path, entry.name),
39
- dirPath: path,
40
+ filePath: join(workingPath, entry.name),
41
+ dirPath: workingPath,
40
42
  filename: entry.name,
41
43
  level: l,
42
44
  type,
@@ -51,7 +53,7 @@ export const findWorkspaceRoot = async (startPath) => {
51
53
  }
52
54
  const results = (await Promise.allSettled(promises)).filter((r) => r.status === "fulfilled");
53
55
  results.sort((a, b) => a.value.level - b.value.level);
54
- const result = results.find((r) => r.value.type === WorkspaceFileType.workspace)?.value &&
56
+ const result = results.find((r) => r.value.type === WorkspaceFileType.workspace)?.value ??
55
57
  results.find((r) => r.value.type === WorkspaceFileType.package)?.value;
56
58
  if (!result)
57
59
  throw new Error("findWorkspaceRoot: no file found");
@@ -90,7 +92,7 @@ export const readPackageJsonThrow = async (dirOrFilepath) => {
90
92
  const pkgPath = dirOrFilepath.endsWith("/package.json")
91
93
  ? dirOrFilepath
92
94
  : join(dirOrFilepath, "package.json");
93
- return pkg.parse(await readFile(pkgPath, "utf8"));
95
+ return json5.parse(await readFile(pkgPath, "utf8"));
94
96
  };
95
97
  export const readPackageJsons = async (repoRoot) => {
96
98
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/build-api",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Build utilities API",
5
5
  "type": "module",
6
6
  "author": "MXPicture",