dirfly 0.8.0 → 0.9.0

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 (2) hide show
  1. package/dist/index.js +48 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,12 +3,53 @@
3
3
  // index.ts
4
4
  import { parseArgs } from "node:util";
5
5
  import path, { basename } from "node:path";
6
- import { existsSync } from "node:fs";
6
+ import { existsSync, writeFileSync } from "node:fs";
7
7
  import { spawnSync } from "node:child_process";
8
+
9
+ // .gitignore
10
+ var __default = `# dependencies (bun install)
11
+ node_modules
12
+
13
+ # output
14
+ out
15
+ dist
16
+ *.tgz
17
+
18
+ # code coverage
19
+ coverage
20
+ *.lcov
21
+
22
+ # logs
23
+ logs
24
+ _.log
25
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
26
+
27
+ # dotenv environment variable files
28
+ .env
29
+ .env.development.local
30
+ .env.test.local
31
+ .env.production.local
32
+ .env.local
33
+
34
+ # caches
35
+ .eslintcache
36
+ .cache
37
+ *.tsbuildinfo
38
+
39
+ # IntelliJ based IDEs
40
+ .idea
41
+
42
+ # Finder (MacOS) folder config
43
+ .DS_Store
44
+
45
+ .git
46
+ `;
47
+
48
+ // index.ts
8
49
  var { positionals } = parseArgs({ allowPositionals: true });
9
- var serverUrlIdx = positionals.findIndex((it) => it.startsWith("svn+ssh://"));
50
+ var serverUrlIdx = positionals.findIndex((it) => it.match(/\S+:\/\//));
10
51
  if (serverUrlIdx === -1)
11
- throw new Error("缺少svn服务地址,仅支持协议: svn+ssh://");
52
+ throw new Error("缺少svn服务地址");
12
53
  var serverUrl = positionals[serverUrlIdx];
13
54
  var localDir = path.resolve(positionals[serverUrlIdx - 1] || process.cwd());
14
55
  if (!existsSync(localDir))
@@ -17,10 +58,10 @@ var serverDir = positionals[serverUrlIdx + 1] || basename(localDir);
17
58
  process.chdir(localDir);
18
59
  var gitignore = ".gitignore";
19
60
  if (!existsSync(gitignore))
20
- throw new Error(`请先创建${path.resolve(gitignore)},如 svn commit . -m "批量更新"`);
61
+ writeFileSync(gitignore, __default);
21
62
  if (existsSync(".svn"))
22
63
  throw new Error('当前目录已经被初始化过了,可以直接提交,如 `svn commit . -m "批量更新"`');
23
- var serverFullUrl = `${serverUrl}/${serverDir}`;
64
+ var serverFullUrl = `${serverUrl.replace(/\/$/, "")}/${serverDir}`;
24
65
  console.log(`准备导入: ${localDir} → ${serverFullUrl}`);
25
66
  var cmds = [
26
67
  `svn import -m "导入临时占位文件" ${gitignore} ${serverFullUrl}/${gitignore}`,
@@ -31,10 +72,9 @@ var cmds = [
31
72
  `svn commit -m "新增项目${serverDir}"`
32
73
  ];
33
74
  cmds.forEach((cmd) => {
34
- const res = crossSpawnExec(cmd, { stdio: "inherit" });
35
- if (res.status) {
75
+ const res = crossSpawnExec(cmd);
76
+ if (res.status)
36
77
  process.exit(0);
37
- }
38
78
  });
39
79
  function crossSpawnExec(cmd, options) {
40
80
  let [bin, ...params] = cmd.trim().split(/\s+/);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirfly",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "用于将本地目录同步到指定`SVN`仓库。",
5
5
  "keywords": [
6
6
  "directory",