dirfly 0.2.0 → 0.4.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/package.json +2 -3
  2. package/index.ts +0 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirfly",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "用于将本地目录同步到指定`SVN`仓库。",
5
5
  "keywords": [
6
6
  "directory",
@@ -15,7 +15,7 @@
15
15
  "目录同步"
16
16
  ],
17
17
  "bin": {
18
- "dirfly": "./index.ts"
18
+ "dirfly": "./dist/index.js"
19
19
  },
20
20
  "scripts": {
21
21
  "bld": "bun build ./index.ts --outdir ./dist --target node --format iife ",
@@ -24,7 +24,6 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
- "module": "index.ts",
28
27
  "type": "module",
29
28
  "devDependencies": {
30
29
  "@types/node": "^22.18.0"
package/index.ts DELETED
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { parseArgs } from "node:util";
4
- import path, { basename } from "node:path";
5
- import { existsSync } from "node:fs";
6
- import { execSync } from "node:child_process";
7
-
8
- const { positionals } = parseArgs({ allowPositionals: true });
9
- const serverUrlIdx = positionals.findIndex(it => it.startsWith('svn+ssh://'))
10
- if (serverUrlIdx === -1) throw new Error('缺少svn服务地址,仅支持协议: svn+ssh://')
11
- const serverUrl = positionals[serverUrlIdx]
12
- const localDir = path.resolve(positionals[serverUrlIdx - 1] || process.cwd())
13
- if (!existsSync(localDir)) throw new Error(`本地路径不存在: ${localDir}`)
14
- const serverDir = positionals[serverUrlIdx + 1] || basename(localDir)
15
-
16
- process.chdir(localDir)
17
-
18
- const gitignore = '.gitignore'
19
- if (!existsSync(gitignore)) throw new Error(`请先创建${path.resolve(gitignore)},如 svn commit . -m "批量更新"`)
20
- if (existsSync('.svn')) throw new Error('当前目录已经被初始化过了,可以直接提交,如 `svn commit . -m "批量更新"`')
21
-
22
- const serverFullUrl = `${serverUrl}/${serverDir}`
23
- console.log(`准备导入: ${localDir} → ${serverFullUrl}`);
24
- /**
25
- * TODO
26
- * 测试目录里面有很多嵌套的子项目; 就如ebase; 会把子项目的文件上传马
27
- */
28
-
29
- const cmds = [
30
- // local直接是当前cwd,或者手动指定一个路径
31
- // 1. 先导入一个临时文件占个位置文件 .gitignore/没有的话临时创建一个文件事成之后在删除
32
- // svn import yourfile.txt http://svn.example.com/repo/trunk/project/yourfile.txt -m "导入单个文件"
33
- `svn import -m "导入临时占位文件" ${gitignore} ${serverFullUrl}/${gitignore}`,
34
- // 2. checkout " .
35
- `svn checkout "${serverFullUrl}" .`,
36
- // `svn checkout "${serverFullUrl}" ./`,
37
- // 3. 添加忽略文件
38
- `svn propset svn:ignore -F ./.gitignore ./`,
39
- `svn resolve --accept working ./.gitignore`,
40
- // 4. 添加所有文件
41
- `svn add --force . `,
42
- // 5. 忽略 临时文件
43
- // `svn delete --force ${tmpFile.name}`,
44
- // 6. 提交
45
- `svn commit -m "新增项目${serverDir}"`
46
- ]
47
- cmds.forEach(cmd => execSync(cmd))