workon 3.5.0 → 3.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/cli.js CHANGED
@@ -269,10 +269,11 @@ var init_project = __esm({
269
269
  return this._events;
270
270
  }
271
271
  set path(path8) {
272
- if (this._base) {
272
+ const pathFile = File.from(path8);
273
+ if (this._base && !pathFile.isAbsolute()) {
273
274
  this._path = this._base.join(path8);
274
275
  } else {
275
- this._path = File.from(path8);
276
+ this._path = pathFile;
276
277
  }
277
278
  this._path = this._path.absolutify();
278
279
  }
@@ -365,17 +366,17 @@ var init_environment = __esm({
365
366
  return this.projects;
366
367
  }
367
368
  const defaults = this.config.getDefaults();
368
- if (!defaults?.base) {
369
- this.projects = [];
370
- return this.projects;
371
- }
372
- const baseDir = File2.from(defaults.base);
369
+ const baseDir = defaults?.base ? File2.from(defaults.base).absolutify() : null;
373
370
  const projectsMap = this.config.getProjects();
374
- this.projects = Object.entries(projectsMap).map(([name, project]) => ({
375
- ...project,
376
- name,
377
- path: baseDir.join(project.path)
378
- }));
371
+ this.projects = Object.entries(projectsMap).map(([name, project]) => {
372
+ const projectPath = File2.from(project.path);
373
+ const resolvedPath = baseDir && !projectPath.isAbsolute() ? baseDir.join(project.path) : projectPath;
374
+ return {
375
+ ...project,
376
+ name,
377
+ path: resolvedPath
378
+ };
379
+ });
379
380
  return this.projects;
380
381
  }
381
382
  static getProjectEnvironment(base, _matching) {
@@ -2904,7 +2905,7 @@ async function initProject(defaultName, fromUser, ctx) {
2904
2905
  default: defaults?.base ? File5.from(defaults.base).join(name).path : name
2905
2906
  });
2906
2907
  let answerFile = File5.from(pathAnswer);
2907
- const defaultBase = defaults?.base ? File5.from(defaults.base) : File5.cwd();
2908
+ const defaultBase = defaults?.base ? File5.from(defaults.base).absolutify() : File5.cwd();
2908
2909
  if (!answerFile.isAbsolute()) {
2909
2910
  answerFile = defaultBase.join(answerFile.path);
2910
2911
  }
@@ -2918,7 +2919,8 @@ async function initProject(defaultName, fromUser, ctx) {
2918
2919
  } catch {
2919
2920
  answerFile = answerFile.absolutify();
2920
2921
  }
2921
- basePath = answerFile.relativize(defaultBase.path).path;
2922
+ const relPath = answerFile.relativize(defaultBase.path);
2923
+ basePath = relPath && !relPath.path.startsWith("..") ? relPath.path : answerFile.path;
2922
2924
  }
2923
2925
  const ide = await select4({
2924
2926
  message: "What is the IDE?",
@@ -3111,18 +3113,21 @@ async function createProjectManage(ctx) {
3111
3113
  return true;
3112
3114
  }
3113
3115
  });
3114
- const defaultPath = defaults?.base ? File5.from(defaults.base).join(name).path : name;
3116
+ const defaultPath = defaults?.base ? File5.from(defaults.base).absolutify().join(name).path : name;
3115
3117
  const pathInput = await input5({
3116
3118
  message: "Project path:",
3117
3119
  default: defaultPath
3118
3120
  });
3119
3121
  let relativePath = pathInput;
3120
3122
  if (defaults?.base) {
3121
- const baseDir = File5.from(defaults.base);
3123
+ const baseDir = File5.from(defaults.base).absolutify();
3122
3124
  const pathFile = File5.from(pathInput);
3123
3125
  try {
3124
3126
  if (pathFile.isAbsolute()) {
3125
- relativePath = pathFile.relativize(baseDir.path).path;
3127
+ const relPath = pathFile.relativize(baseDir.path);
3128
+ if (relPath && !relPath.path.startsWith("..")) {
3129
+ relativePath = relPath.path;
3130
+ }
3126
3131
  }
3127
3132
  } catch {
3128
3133
  relativePath = pathInput;
@@ -3183,11 +3188,14 @@ async function editProjectManage(ctx) {
3183
3188
  });
3184
3189
  let relativePath = pathInput;
3185
3190
  if (defaults?.base) {
3186
- const baseDir = File5.from(defaults.base);
3191
+ const baseDir = File5.from(defaults.base).absolutify();
3187
3192
  const pathFile = File5.from(pathInput);
3188
3193
  try {
3189
3194
  if (pathFile.isAbsolute()) {
3190
- relativePath = pathFile.relativize(baseDir.path).path;
3195
+ const relPath = pathFile.relativize(baseDir.path);
3196
+ if (relPath && !relPath.path.startsWith("..")) {
3197
+ relativePath = relPath.path;
3198
+ }
3191
3199
  }
3192
3200
  } catch {
3193
3201
  relativePath = pathInput;
@@ -4277,10 +4285,13 @@ async function createProject(ctx) {
4277
4285
  });
4278
4286
  let relativePath = pathInput;
4279
4287
  if (defaults?.base) {
4280
- const baseDir = File7.from(defaults.base);
4288
+ const baseDir = File7.from(defaults.base).absolutify();
4281
4289
  const pathFile = File7.from(pathInput);
4282
4290
  try {
4283
- relativePath = pathFile.relativize(baseDir.path).path;
4291
+ const relPath = pathFile.relativize(baseDir.path);
4292
+ if (relPath && !relPath.path.startsWith("..")) {
4293
+ relativePath = relPath.path;
4294
+ }
4284
4295
  } catch {
4285
4296
  relativePath = pathInput;
4286
4297
  }
@@ -4352,11 +4363,14 @@ async function editProject(ctx) {
4352
4363
  });
4353
4364
  let relativePath = pathInput;
4354
4365
  if (defaults?.base) {
4355
- const baseDir = File7.from(defaults.base);
4366
+ const baseDir = File7.from(defaults.base).absolutify();
4356
4367
  const pathFile = File7.from(pathInput);
4357
4368
  try {
4358
4369
  if (pathFile.isAbsolute()) {
4359
- relativePath = pathFile.relativize(baseDir.path).path;
4370
+ const relPath = pathFile.relativize(baseDir.path);
4371
+ if (relPath && !relPath.path.startsWith("..")) {
4372
+ relativePath = relPath.path;
4373
+ }
4360
4374
  }
4361
4375
  } catch {
4362
4376
  relativePath = pathInput;
@@ -4524,7 +4538,7 @@ async function addProject(pathArg, options, ctx) {
4524
4538
  log.debug(`IDE: ${ide}`);
4525
4539
  let relativePath = targetPath;
4526
4540
  if (defaults?.base) {
4527
- const baseDir = File8.from(defaults.base);
4541
+ const baseDir = File8.from(defaults.base).absolutify();
4528
4542
  try {
4529
4543
  const relPath = pathFile.relativize(baseDir.path);
4530
4544
  if (relPath && !relPath.path.startsWith("..")) {