@liangmi/mo 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +13 -0
  2. package/dist/mo.mjs +14 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -47,8 +47,21 @@ mo setup
47
47
 
48
48
  `mo cd`, `mo edit`, and `mo open` open an interactive selector when called without arguments.
49
49
 
50
+ > [!TIP]
51
+ > If you are using `mo` with VS Code based editors, you can add this line to your editor config to prevent `mo edit` popping up a new separated window.
52
+ >
53
+ > ```json
54
+ > "window.openFoldersInNewWindow": "off"
55
+ > ```
56
+ >
57
+ > Setting `code -r` as your editor in `mo setup` have the same effect as well.
58
+
50
59
  ## Config
51
60
 
61
+ The config file should be generated by running `mo setup`. Modifying `~/.config/morc.json` manually is not recommended.
62
+
63
+ Please follow the [config_schema.json](./config_schema.json) if you are developing `mo`.
64
+
52
65
  `~/.config/morc.json`:
53
66
 
54
67
  ```json
package/dist/mo.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as __require, r as __toESM, t as __commonJSMin } from "./chunk-CBBoxR_p.mjs";
2
2
  import { C as untildify, S as parseAliasInput, _ as require_picocolors, a as ensureToolReady, b as defaultAliases, c as getDefaultConfigPath, d as error, f as icons, g as toTildePath, h as success, i as preventRunning, l as loadConfig, m as stopSpinner, n as getRestartFlagPath, o as runCommand, p as startSpinner, r as innerBinName, s as R, t as checkRestartRequired, u as supportedShells, v as aliasCommands, w as cac, x as getAliasPromptLabel } from "./runner-DW0Q4OMK.mjs";
3
3
  import * as fs$1 from "node:fs";
4
- import fs, { existsSync, mkdirSync, readdirSync, statSync, writeFileSync } from "node:fs";
4
+ import fs, { existsSync, mkdirSync, readdirSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
5
5
  import os, { tmpdir } from "node:os";
6
6
  import path from "node:path";
7
7
  import { execFileSync, spawnSync } from "node:child_process";
@@ -13,7 +13,7 @@ import { Buffer as Buffer$1 } from "node:buffer";
13
13
  import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
14
14
  import prompts from "prompts";
15
15
  //#region package.json
16
- var version = "1.0.0";
16
+ var version = "1.0.1";
17
17
  //#endregion
18
18
  //#region src/commands/clone.ts
19
19
  var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
@@ -21,8 +21,9 @@ async function runCloneCommand(repo, config) {
21
21
  const parsedRepo = parseRepo(repo);
22
22
  const ownerDir = path.join(config.root, parsedRepo.owner);
23
23
  const targetDir = path.join(ownerDir, parsedRepo.name);
24
+ const ownerExisted = existsSync(ownerDir);
24
25
  if (existsSync(targetDir)) error(`Repository already exists at ${import_picocolors.default.cyan(toTildePath(targetDir))}`);
25
- mkdirSync(ownerDir, { recursive: true });
26
+ if (!ownerExisted) mkdirSync(ownerDir, { recursive: true });
26
27
  const cloneUrl = `https://github.com/${parsedRepo.owner}/${parsedRepo.name}.git`;
27
28
  const spinner = startSpinner(`Cloning ${import_picocolors.default.bold(`${parsedRepo.owner}/${parsedRepo.name}`)}...`);
28
29
  try {
@@ -32,10 +33,20 @@ async function runCloneCommand(repo, config) {
32
33
  console.log(` ${import_picocolors.default.dim("→")} ${import_picocolors.default.cyan(toTildePath(targetDir))}`);
33
34
  } catch (err) {
34
35
  stopSpinner(spinner);
36
+ cleanupFailedClone(targetDir, ownerDir, ownerExisted);
35
37
  const details = err instanceof Error ? `: ${err.message}` : "";
36
38
  error(`Git clone failed for ${parsedRepo.owner}/${parsedRepo.name}${details}`);
37
39
  }
38
40
  }
41
+ function cleanupFailedClone(targetDir, ownerDir, ownerExisted) {
42
+ try {
43
+ if (existsSync(targetDir)) rmSync(targetDir, {
44
+ recursive: true,
45
+ force: true
46
+ });
47
+ if (!ownerExisted && existsSync(ownerDir) && readdirSync(ownerDir).length === 0) rmdirSync(ownerDir);
48
+ } catch {}
49
+ }
39
50
  async function runGitClone(url, targetDir) {
40
51
  const result = await R("git", [
41
52
  "clone",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangmi/mo",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Manage your open source projects",
5
5
  "homepage": "https://github.com/liangmiQwQ/mo#readme",
6
6
  "bugs": {