vscode-behavior3 2.5.0 → 2.5.1

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/dist/build-cli.js CHANGED
@@ -218052,6 +218052,13 @@ var isValidInputOrOutput = (def, data, index) => {
218052
218052
  // src/project-path-discovery.ts
218053
218053
  var fs = __toESM(require("fs"));
218054
218054
  var path = __toESM(require("path"));
218055
+ var resolveExistingPath = (inputPath) => {
218056
+ const resolved = path.resolve(inputPath);
218057
+ if (!fs.existsSync(resolved)) {
218058
+ return resolved;
218059
+ }
218060
+ return fs.realpathSync.native(resolved);
218061
+ };
218055
218062
  var isWithinRoot = (rootDir, candidateDir) => {
218056
218063
  const relative3 = path.relative(rootDir, candidateDir);
218057
218064
  return relative3 === "" || !relative3.startsWith("..") && !path.isAbsolute(relative3);
@@ -218061,12 +218068,13 @@ var toSearchDirectory = (inputPath) => {
218061
218068
  if (!fs.existsSync(resolved)) {
218062
218069
  return path.extname(resolved) ? path.dirname(resolved) : resolved;
218063
218070
  }
218064
- const stat = fs.statSync(resolved);
218065
- return stat.isDirectory() ? resolved : path.dirname(resolved);
218071
+ const canonical = resolveExistingPath(resolved);
218072
+ const stat = fs.statSync(canonical);
218073
+ return stat.isDirectory() ? canonical : path.dirname(canonical);
218066
218074
  };
218067
218075
  var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218068
- let dir = path.resolve(searchFrom);
218069
- const boundary = rootDir ? path.resolve(rootDir) : void 0;
218076
+ let dir = resolveExistingPath(searchFrom);
218077
+ const boundary = rootDir ? resolveExistingPath(rootDir) : void 0;
218070
218078
  while (true) {
218071
218079
  if (boundary && !isWithinRoot(boundary, dir)) {
218072
218080
  break;
@@ -218075,7 +218083,7 @@ var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218075
218083
  const names = fs.readdirSync(dir);
218076
218084
  const hit = names.filter((name) => name.endsWith(suffix)).sort()[0];
218077
218085
  if (hit) {
218078
- return path.join(dir, hit);
218086
+ return resolveExistingPath(path.join(dir, hit));
218079
218087
  }
218080
218088
  } catch {
218081
218089
  }
@@ -218093,14 +218101,14 @@ var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218093
218101
  var findBehaviorWorkspaceFileSync = (searchPath, opts) => {
218094
218102
  const resolved = path.resolve(searchPath);
218095
218103
  if (resolved.endsWith(".b3-workspace") && fs.existsSync(resolved)) {
218096
- return resolved;
218104
+ return resolveExistingPath(resolved);
218097
218105
  }
218098
218106
  return findNearestFileUpward(toSearchDirectory(resolved), ".b3-workspace", opts?.rootDir);
218099
218107
  };
218100
218108
  var findBehaviorSettingFileSync = (searchPath, opts) => {
218101
218109
  const resolved = path.resolve(searchPath);
218102
218110
  if (resolved.endsWith(".b3-setting") && fs.existsSync(resolved)) {
218103
- return resolved;
218111
+ return resolveExistingPath(resolved);
218104
218112
  }
218105
218113
  return findNearestFileUpward(toSearchDirectory(resolved), ".b3-setting", opts?.rootDir);
218106
218114
  };
@@ -218108,6 +218116,25 @@ var findBehaviorSettingFileSync = (searchPath, opts) => {
218108
218116
  // src/build/build-cli.ts
218109
218117
  setFs(fs2);
218110
218118
  var normalizePosixPath = (filePath) => filePath.replace(/\\/g, "/");
218119
+ var resolveExistingPath2 = (filePath) => {
218120
+ const resolved = path2.resolve(filePath);
218121
+ if (!fs2.existsSync(resolved)) {
218122
+ return resolved;
218123
+ }
218124
+ return fs2.realpathSync.native(resolved);
218125
+ };
218126
+ async function withProcessCwd(cwd, run) {
218127
+ const previousCwd = process.cwd();
218128
+ if (previousCwd === cwd) {
218129
+ return run();
218130
+ }
218131
+ process.chdir(cwd);
218132
+ try {
218133
+ return await run();
218134
+ } finally {
218135
+ process.chdir(previousCwd);
218136
+ }
218137
+ }
218111
218138
  var ensureExistingFile = (filePath, suffix, label) => {
218112
218139
  const resolved = path2.resolve(filePath);
218113
218140
  if (!resolved.endsWith(suffix)) {
@@ -218116,7 +218143,7 @@ var ensureExistingFile = (filePath, suffix, label) => {
218116
218143
  if (!fs2.existsSync(resolved) || !fs2.statSync(resolved).isFile()) {
218117
218144
  throw new Error(`${label} does not exist: ${resolved}`);
218118
218145
  }
218119
- return resolved;
218146
+ return resolveExistingPath2(resolved);
218120
218147
  };
218121
218148
  var ensureExistingScriptFile = (filePath, label) => {
218122
218149
  const resolved = path2.resolve(filePath);
@@ -218127,7 +218154,7 @@ var ensureExistingScriptFile = (filePath, label) => {
218127
218154
  if (!fs2.existsSync(resolved) || !fs2.statSync(resolved).isFile()) {
218128
218155
  throw new Error(`${label} does not exist: ${resolved}`);
218129
218156
  }
218130
- return resolved;
218157
+ return resolveExistingPath2(resolved);
218131
218158
  };
218132
218159
  var resolveBehaviorProjectPaths = (options) => {
218133
218160
  const projectPath = path2.resolve(options.projectPath ?? process.cwd());
@@ -218175,10 +218202,13 @@ var buildBehaviorProject = async (options) => {
218175
218202
  alertError: () => {
218176
218203
  }
218177
218204
  });
218178
- const hasError = await buildProjectWithContext(
218179
- normalizePosixPath(paths.workspaceFile),
218180
- normalizePosixPath(paths.outputDir),
218181
- buildContext
218205
+ const hasError = await withProcessCwd(
218206
+ paths.workdir,
218207
+ async () => buildProjectWithContext(
218208
+ normalizePosixPath(paths.workspaceFile),
218209
+ normalizePosixPath(paths.outputDir),
218210
+ buildContext
218211
+ )
218182
218212
  );
218183
218213
  return {
218184
218214
  hasError,
package/dist/extension.js CHANGED
@@ -218536,6 +218536,13 @@ var isValidInputOrOutput = (def, data, index) => {
218536
218536
  // src/project-path-discovery.ts
218537
218537
  var fs = __toESM(require("fs"));
218538
218538
  var path = __toESM(require("path"));
218539
+ var resolveExistingPath = (inputPath) => {
218540
+ const resolved = path.resolve(inputPath);
218541
+ if (!fs.existsSync(resolved)) {
218542
+ return resolved;
218543
+ }
218544
+ return fs.realpathSync.native(resolved);
218545
+ };
218539
218546
  var isWithinRoot = (rootDir, candidateDir) => {
218540
218547
  const relative7 = path.relative(rootDir, candidateDir);
218541
218548
  return relative7 === "" || !relative7.startsWith("..") && !path.isAbsolute(relative7);
@@ -218545,12 +218552,13 @@ var toSearchDirectory = (inputPath) => {
218545
218552
  if (!fs.existsSync(resolved)) {
218546
218553
  return path.extname(resolved) ? path.dirname(resolved) : resolved;
218547
218554
  }
218548
- const stat = fs.statSync(resolved);
218549
- return stat.isDirectory() ? resolved : path.dirname(resolved);
218555
+ const canonical = resolveExistingPath(resolved);
218556
+ const stat = fs.statSync(canonical);
218557
+ return stat.isDirectory() ? canonical : path.dirname(canonical);
218550
218558
  };
218551
218559
  var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218552
- let dir = path.resolve(searchFrom);
218553
- const boundary = rootDir ? path.resolve(rootDir) : void 0;
218560
+ let dir = resolveExistingPath(searchFrom);
218561
+ const boundary = rootDir ? resolveExistingPath(rootDir) : void 0;
218554
218562
  while (true) {
218555
218563
  if (boundary && !isWithinRoot(boundary, dir)) {
218556
218564
  break;
@@ -218559,7 +218567,7 @@ var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218559
218567
  const names = fs.readdirSync(dir);
218560
218568
  const hit = names.filter((name) => name.endsWith(suffix)).sort()[0];
218561
218569
  if (hit) {
218562
- return path.join(dir, hit);
218570
+ return resolveExistingPath(path.join(dir, hit));
218563
218571
  }
218564
218572
  } catch {
218565
218573
  }
@@ -218577,14 +218585,14 @@ var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218577
218585
  var findBehaviorWorkspaceFileSync = (searchPath, opts) => {
218578
218586
  const resolved = path.resolve(searchPath);
218579
218587
  if (resolved.endsWith(".b3-workspace") && fs.existsSync(resolved)) {
218580
- return resolved;
218588
+ return resolveExistingPath(resolved);
218581
218589
  }
218582
218590
  return findNearestFileUpward(toSearchDirectory(resolved), ".b3-workspace", opts?.rootDir);
218583
218591
  };
218584
218592
  var findBehaviorSettingFileSync = (searchPath, opts) => {
218585
218593
  const resolved = path.resolve(searchPath);
218586
218594
  if (resolved.endsWith(".b3-setting") && fs.existsSync(resolved)) {
218587
- return resolved;
218595
+ return resolveExistingPath(resolved);
218588
218596
  }
218589
218597
  return findNearestFileUpward(toSearchDirectory(resolved), ".b3-setting", opts?.rootDir);
218590
218598
  };
@@ -218592,6 +218600,25 @@ var findBehaviorSettingFileSync = (searchPath, opts) => {
218592
218600
  // src/build/build-cli.ts
218593
218601
  setFs(fs2);
218594
218602
  var normalizePosixPath = (filePath) => filePath.replace(/\\/g, "/");
218603
+ var resolveExistingPath2 = (filePath) => {
218604
+ const resolved = path2.resolve(filePath);
218605
+ if (!fs2.existsSync(resolved)) {
218606
+ return resolved;
218607
+ }
218608
+ return fs2.realpathSync.native(resolved);
218609
+ };
218610
+ async function withProcessCwd(cwd, run) {
218611
+ const previousCwd = process.cwd();
218612
+ if (previousCwd === cwd) {
218613
+ return run();
218614
+ }
218615
+ process.chdir(cwd);
218616
+ try {
218617
+ return await run();
218618
+ } finally {
218619
+ process.chdir(previousCwd);
218620
+ }
218621
+ }
218595
218622
  var ensureExistingFile = (filePath, suffix, label) => {
218596
218623
  const resolved = path2.resolve(filePath);
218597
218624
  if (!resolved.endsWith(suffix)) {
@@ -218600,7 +218627,7 @@ var ensureExistingFile = (filePath, suffix, label) => {
218600
218627
  if (!fs2.existsSync(resolved) || !fs2.statSync(resolved).isFile()) {
218601
218628
  throw new Error(`${label} does not exist: ${resolved}`);
218602
218629
  }
218603
- return resolved;
218630
+ return resolveExistingPath2(resolved);
218604
218631
  };
218605
218632
  var ensureExistingScriptFile = (filePath, label) => {
218606
218633
  const resolved = path2.resolve(filePath);
@@ -218611,7 +218638,7 @@ var ensureExistingScriptFile = (filePath, label) => {
218611
218638
  if (!fs2.existsSync(resolved) || !fs2.statSync(resolved).isFile()) {
218612
218639
  throw new Error(`${label} does not exist: ${resolved}`);
218613
218640
  }
218614
- return resolved;
218641
+ return resolveExistingPath2(resolved);
218615
218642
  };
218616
218643
  var resolveBehaviorProjectPaths = (options) => {
218617
218644
  const projectPath = path2.resolve(options.projectPath ?? process.cwd());
@@ -218659,10 +218686,13 @@ var buildBehaviorProject = async (options) => {
218659
218686
  alertError: () => {
218660
218687
  }
218661
218688
  });
218662
- const hasError = await buildProjectWithContext(
218663
- normalizePosixPath(paths.workspaceFile),
218664
- normalizePosixPath(paths.outputDir),
218665
- buildContext
218689
+ const hasError = await withProcessCwd(
218690
+ paths.workdir,
218691
+ async () => buildProjectWithContext(
218692
+ normalizePosixPath(paths.workspaceFile),
218693
+ normalizePosixPath(paths.outputDir),
218694
+ buildContext
218695
+ )
218666
218696
  );
218667
218697
  return {
218668
218698
  hasError,
@@ -222899,7 +222929,7 @@ async function startBuildScriptDebugSession(params) {
222899
222929
  request: "launch",
222900
222930
  name: "Debug Behavior3 Build Script",
222901
222931
  program,
222902
- cwd: params.folder.uri.fsPath,
222932
+ cwd: params.projectDir,
222903
222933
  console: "integratedTerminal",
222904
222934
  sourceMaps: true,
222905
222935
  smartStep: true,
@@ -223036,6 +223066,7 @@ async function runBuild(context, options = {}) {
223036
223066
  }
223037
223067
  const outputDirFs = picked[0].fsPath;
223038
223068
  const outputDirPosix = outputDirFs.replace(/\\/g, "/");
223069
+ const projectDir = path12.dirname(workspaceFile);
223039
223070
  await saveLastBuildOutput(context, folder.uri, outputDirFs);
223040
223071
  const config = vscode20.workspace.getConfiguration("behavior3");
223041
223072
  const checkExpr = config.get("checkExpr", true);
@@ -223048,6 +223079,7 @@ async function runBuild(context, options = {}) {
223048
223079
  const started = await startBuildScriptDebugSession({
223049
223080
  context,
223050
223081
  folder,
223082
+ projectDir,
223051
223083
  projectPath: treeUri?.fsPath ?? workspaceFile,
223052
223084
  workspaceFile,
223053
223085
  settingPath,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "vscode-behavior3",
3
3
  "displayName": "%extension.displayName%",
4
4
  "description": "%extension.description%",
5
- "version": "2.5.0",
5
+ "version": "2.5.1",
6
6
  "publisher": "codetypess",
7
7
  "repository": {
8
8
  "type": "git",
@@ -23,18 +23,140 @@ export type BuildLogger = {
23
23
  error: (...args: unknown[]) => void;
24
24
  };
25
25
 
26
+ export type FsEncoding =
27
+ | "ascii"
28
+ | "base64"
29
+ | "base64url"
30
+ | "binary"
31
+ | "hex"
32
+ | "latin1"
33
+ | "ucs-2"
34
+ | "ucs2"
35
+ | "utf-8"
36
+ | "utf16le"
37
+ | "utf8";
38
+
39
+ export type FsFileData = string | Uint8Array;
40
+
41
+ export type FsReadFileOptions = {
42
+ encoding?: FsEncoding | null;
43
+ flag?: string;
44
+ };
45
+
46
+ export type FsWriteFileOptions = {
47
+ encoding?: FsEncoding | null;
48
+ mode?: number | string;
49
+ flag?: string;
50
+ flush?: boolean;
51
+ };
52
+
53
+ export type FsDirentLike = {
54
+ name: string;
55
+ path?: string;
56
+ parentPath?: string;
57
+ isBlockDevice(): boolean;
58
+ isCharacterDevice(): boolean;
59
+ isDirectory(): boolean;
60
+ isFIFO(): boolean;
61
+ isFile(): boolean;
62
+ isSocket(): boolean;
63
+ isSymbolicLink(): boolean;
64
+ };
65
+
66
+ export type FsStatsLike = {
67
+ atime: Date;
68
+ atimeMs: number;
69
+ birthtime: Date;
70
+ birthtimeMs: number;
71
+ blocks: number;
72
+ blksize: number;
73
+ ctime: Date;
74
+ ctimeMs: number;
75
+ dev: number;
76
+ gid: number;
77
+ ino: number;
78
+ mode: number;
79
+ mtime: Date;
80
+ mtimeMs: number;
81
+ nlink: number;
82
+ rdev: number;
83
+ size: number;
84
+ uid: number;
85
+ isBlockDevice(): boolean;
86
+ isCharacterDevice(): boolean;
87
+ isDirectory(): boolean;
88
+ isFIFO(): boolean;
89
+ isFile(): boolean;
90
+ isSocket(): boolean;
91
+ isSymbolicLink(): boolean;
92
+ };
93
+
94
+ export type FsMkdirOptions = {
95
+ recursive?: boolean;
96
+ mode?: number | string;
97
+ };
98
+
99
+ export type FsReaddirOptions = {
100
+ encoding?: FsEncoding;
101
+ recursive?: boolean;
102
+ withFileTypes?: false;
103
+ };
104
+
105
+ export type FsReaddirDirentOptions = {
106
+ encoding?: FsEncoding;
107
+ recursive?: boolean;
108
+ withFileTypes: true;
109
+ };
110
+
111
+ export type FsMkdtempOptions = {
112
+ encoding?: FsEncoding;
113
+ };
114
+
115
+ export type FsRmOptions = {
116
+ force?: boolean;
117
+ maxRetries?: number;
118
+ recursive?: boolean;
119
+ retryDelay?: number;
120
+ };
121
+
122
+ export type FsCpOptions = {
123
+ dereference?: boolean;
124
+ errorOnExist?: boolean;
125
+ filter?: (source: string, destination: string) => boolean;
126
+ force?: boolean;
127
+ mode?: number;
128
+ preserveTimestamps?: boolean;
129
+ recursive?: boolean;
130
+ verbatimSymlinks?: boolean;
131
+ };
132
+
26
133
  export type FsLike = {
27
- readFileSync(path: string, encoding: "utf8" | "utf-8"): string;
28
- writeFileSync(path: string, data: string, encoding?: "utf8" | "utf-8"): void;
134
+ accessSync(path: string, mode?: number): void;
135
+ appendFileSync(path: string, data: FsFileData, options?: FsEncoding | FsWriteFileOptions): void;
136
+ chmodSync(path: string, mode: number | string): void;
29
137
  readdirSync(path: string): string[];
30
- readdirSync(
31
- path: string,
32
- options: { encoding: "utf8" | "utf-8"; recursive?: boolean }
33
- ): string[];
34
- statSync(path: string): { mtimeMs: number; isFile(): boolean };
35
- mkdirSync(path: string, options?: { recursive?: boolean }): unknown;
36
- copyFileSync(source: string, destination: string): void;
138
+ readdirSync(path: string, options: FsReaddirOptions): string[];
139
+ readdirSync(path: string, options: FsReaddirDirentOptions): FsDirentLike[];
140
+ readFileSync(path: string): Uint8Array;
141
+ readFileSync(path: string, encoding: FsEncoding): string;
142
+ readFileSync(path: string, options: FsReadFileOptions & { encoding: FsEncoding }): string;
143
+ readFileSync(path: string, options?: FsReadFileOptions): Uint8Array;
144
+ readlinkSync(path: string, options?: FsEncoding | { encoding?: FsEncoding }): string;
145
+ realpathSync(path: string, options?: FsEncoding | { encoding?: FsEncoding }): string;
146
+ writeFileSync(path: string, data: FsFileData, options?: FsEncoding | FsWriteFileOptions): void;
147
+ copyFileSync(source: string, destination: string, mode?: number): void;
148
+ cpSync(source: string, destination: string, options?: FsCpOptions): void;
149
+ existsSync(path: string): boolean;
150
+ lstatSync(path: string): FsStatsLike;
151
+ mkdirSync(path: string, options?: FsMkdirOptions | number | string): string | undefined;
152
+ mkdtempSync(prefix: string, options?: FsEncoding | FsMkdtempOptions): string;
153
+ renameSync(oldPath: string, newPath: string): void;
154
+ rmSync(path: string, options?: FsRmOptions): void;
155
+ rmdirSync(path: string, options?: FsRmOptions): void;
156
+ statSync(path: string): FsStatsLike;
157
+ symlinkSync(target: string, path: string, type?: "dir" | "file" | "junction"): void;
37
158
  unlinkSync(path: string): void;
159
+ utimesSync(path: string, atime: string | number | Date, mtime: string | number | Date): void;
38
160
  };
39
161
 
40
162
  export type PathLike = {