dirfly 0.1.0 → 0.3.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.
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ (() => {
3
+ var import_node_module = __require("node:module");
4
+ var __create = Object.create;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __toESM = (mod, isNodeMode, target) => {
10
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
11
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
12
+ for (let key of __getOwnPropNames(mod))
13
+ if (!__hasOwnProp.call(to, key))
14
+ __defProp(to, key, {
15
+ get: () => mod[key],
16
+ enumerable: true
17
+ });
18
+ return to;
19
+ };
20
+ var __require = /* @__PURE__ */ import_node_module.createRequire(import.meta.url);
21
+
22
+ // index.ts
23
+ var import_node_util = __require("node:util");
24
+ var import_node_path = __toESM(__require("node:path"));
25
+ var import_node_fs = __require("node:fs");
26
+ var import_node_child_process = __require("node:child_process");
27
+ var { positionals } = import_node_util.parseArgs({ allowPositionals: true });
28
+ var serverUrlIdx = positionals.findIndex((it) => it.startsWith("svn+ssh://"));
29
+ if (serverUrlIdx === -1)
30
+ throw new Error("缺少svn服务地址,仅支持协议: svn+ssh://");
31
+ var serverUrl = positionals[serverUrlIdx];
32
+ var localDir = import_node_path.default.resolve(positionals[serverUrlIdx - 1] || process.cwd());
33
+ if (!import_node_fs.existsSync(localDir))
34
+ throw new Error(`本地路径不存在: ${localDir}`);
35
+ var serverDir = positionals[serverUrlIdx + 1] || import_node_path.basename(localDir);
36
+ process.chdir(localDir);
37
+ var gitignore = ".gitignore";
38
+ if (!import_node_fs.existsSync(gitignore))
39
+ throw new Error(`请先创建${import_node_path.default.resolve(gitignore)},如 svn commit . -m "批量更新"`);
40
+ if (import_node_fs.existsSync(".svn"))
41
+ throw new Error('当前目录已经被初始化过了,可以直接提交,如 `svn commit . -m "批量更新"`');
42
+ var serverFullUrl = `${serverUrl}/${serverDir}`;
43
+ console.log(`准备导入: ${localDir} → ${serverFullUrl}`);
44
+ var cmds = [
45
+ `svn import -m "导入临时占位文件" ${gitignore} ${serverFullUrl}/${gitignore}`,
46
+ `svn checkout "${serverFullUrl}" .`,
47
+ `svn propset svn:ignore -F ./.gitignore ./`,
48
+ `svn resolve --accept working ./.gitignore`,
49
+ `svn add --force . `,
50
+ `svn commit -m "新增项目${serverDir}"`
51
+ ];
52
+ cmds.forEach((cmd) => import_node_child_process.execSync(cmd));
53
+ })();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dirfly",
3
- "version": "0.1.0",
4
- "description": "命令行工具,用于将本地目录同步到指定仓库",
3
+ "version": "0.3.0",
4
+ "description": "用于将本地目录同步到指定`SVN`仓库。",
5
5
  "keywords": [
6
6
  "directory",
7
7
  "sync",
@@ -15,11 +15,15 @@
15
15
  "目录同步"
16
16
  ],
17
17
  "bin": {
18
- "dirfly": "./index.ts"
18
+ "dirfly": "./dist/index.js"
19
19
  },
20
20
  "scripts": {
21
- "pub": "npm publish --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$token "
21
+ "bld": "bun build ./index.ts --outdir ./dist --target node --format iife ",
22
+ "pub": "npm run bld && npm publish --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$token "
22
23
  },
24
+ "files": [
25
+ "dist"
26
+ ],
23
27
  "module": "index.ts",
24
28
  "type": "module",
25
29
  "devDependencies": {
package/.prototools DELETED
@@ -1 +0,0 @@
1
- node = "~25"
package/index.ts DELETED
@@ -1,53 +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.match(/\S+:\/\//))
10
- if (serverUrlIdx === -1) throw new Error('缺少svn服务地址')
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
- // 期待的使用方式:npx git-svn [local] <serverurl>/[xxx]
25
- // 期待的使用方式:npx xxxlib [localfilepath] <serverurl> [localfilepath的dirname]
26
- /**
27
- * TODO
28
- * 整理一些常用的SVN命令:
29
- * - 推送
30
- * - 拉取
31
- * 拉取指定目录
32
- * 测试目录里面有很多嵌套的子项目; 就如ebase; 会把子项目的文件上传马
33
- */
34
-
35
- const cmds = [
36
- // local直接是当前cwd,或者手动指定一个路径
37
- // 1. 先导入一个临时文件占个位置文件 .gitignore/没有的话临时创建一个文件事成之后在删除
38
- // svn import yourfile.txt http://svn.example.com/repo/trunk/project/yourfile.txt -m "导入单个文件"
39
- `svn import -m "导入临时占位文件" ${gitignore} ${serverFullUrl}/${gitignore}`,
40
- // 2. checkout " .
41
- `svn checkout "${serverFullUrl}" .`,
42
- // `svn checkout "${serverFullUrl}" ./`,
43
- // 3. 添加忽略文件
44
- `svn propset svn:ignore -F ./.gitignore ./`,
45
- `svn resolve --accept working ./.gitignore`,
46
- // 4. 添加所有文件
47
- `svn add --force . `,
48
- // 5. 忽略 临时文件
49
- // `svn delete --force ${tmpFile.name}`,
50
- // 6. 提交
51
- `svn commit -m "新增项目${serverDir}"`
52
- ]
53
- cmds.forEach(cmd => execSync(cmd))
package/tsconfig.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Environment setup & latest features
4
- "lib": [
5
- "ESNext"
6
- ],
7
- "types": [
8
- "node"
9
- ],
10
- "target": "ESNext",
11
- "module": "Preserve",
12
- "moduleDetection": "force",
13
- "jsx": "react-jsx",
14
- "allowJs": true,
15
- // Bundler mode
16
- "moduleResolution": "bundler",
17
- "allowImportingTsExtensions": true,
18
- "verbatimModuleSyntax": true,
19
- "noEmit": true,
20
- // Best practices
21
- "strict": true,
22
- "skipLibCheck": true,
23
- "noFallthroughCasesInSwitch": true,
24
- "noUncheckedIndexedAccess": true,
25
- "noImplicitOverride": true,
26
- // Some stricter flags (disabled by default)
27
- "noUnusedLocals": false,
28
- "noUnusedParameters": false,
29
- "noPropertyAccessFromIndexSignature": false
30
- }
31
- }