@ia-ccun/idea-plugin-share 0.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.
- package/README.md +98 -0
- package/bin/idea-plugin.js +143 -0
- package/package.json +32 -0
- package/plugins/aicode-agent-0.1.0-223.zip +0 -0
- package/plugins/aicode-agent-0.1.0-241.zip +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# idea-plugin-share
|
|
2
|
+
|
|
3
|
+
内网 IntelliJ IDEA 插件分发工具 —— 用 npm 包当"容器",把 `.zip` 装进 `plugins/` 目录发布到 npm registry,内网同事 `npm i` 即可拿到。
|
|
4
|
+
|
|
5
|
+
## 工作原理
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
外网开发 → 把插件 zip 放进 plugins/ → npm publish → 内网 npm i → postinstall 自动复制到本地目录 → IDEA 从磁盘安装
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用方式(发布者)
|
|
12
|
+
|
|
13
|
+
### 1. 准备插件
|
|
14
|
+
|
|
15
|
+
把 IDEA 插件的 `.zip` 文件放进 `plugins/` 目录:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
plugins/
|
|
19
|
+
├── my-awesome-plugin-1.0.0.zip
|
|
20
|
+
└── another-tool-2.3.1.zip
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 2. 修改 package.json
|
|
24
|
+
|
|
25
|
+
把 `name` 改成你自己的 scope:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"name": "@your-scope/idea-plugin-share",
|
|
30
|
+
"version": "1.0.1"
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 3. 发布
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm login
|
|
38
|
+
npm publish --access public
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 使用方式(内网用户)
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# 安装
|
|
45
|
+
npm install @your-scope/idea-plugin-share -g
|
|
46
|
+
|
|
47
|
+
# 查看本地存放路径
|
|
48
|
+
idea-plugin path
|
|
49
|
+
|
|
50
|
+
# 打开目录(macOS/Win/Linux)
|
|
51
|
+
idea-plugin open
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
或一次性:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx @your-scope/idea-plugin-share install
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 目录约定
|
|
61
|
+
|
|
62
|
+
| 位置 | 说明 |
|
|
63
|
+
|------|------|
|
|
64
|
+
| `plugins/` | 源目录:放要分发的 `.zip` |
|
|
65
|
+
| `~/idea-plugins/` | 默认本地目标目录(可用 `IDEA_PLUGIN_DIR` 覆盖) |
|
|
66
|
+
|
|
67
|
+
## IDEA 安装步骤
|
|
68
|
+
|
|
69
|
+
1. `idea-plugin open` 打开目标目录
|
|
70
|
+
2. IDEA → **Settings → Plugins → ⚙ → Install Plugin from Disk**
|
|
71
|
+
3. 选择目标目录里的 `.zip`
|
|
72
|
+
4. 重启 IDEA
|
|
73
|
+
|
|
74
|
+
## 命令
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
idea-plugin install # 复制 zip 到本地(npm install 自动触发)
|
|
78
|
+
idea-plugin list # 列出本包所有插件
|
|
79
|
+
idea-plugin path # 打印本地目标目录
|
|
80
|
+
idea-plugin open # 打开本地目标目录
|
|
81
|
+
idea-plugin help # 帮助
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 更新插件
|
|
85
|
+
|
|
86
|
+
1. 更新 `package.json` 的 `version`(如 `1.0.0` → `1.0.1`)
|
|
87
|
+
2. 替换 `plugins/` 里的 zip
|
|
88
|
+
3. `npm publish`
|
|
89
|
+
|
|
90
|
+
内网用户重新 `npm i` 即可。
|
|
91
|
+
|
|
92
|
+
## 零依赖
|
|
93
|
+
|
|
94
|
+
只用 Node.js 内置模块,无需任何第三方依赖。Node >= 14。
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 极简 CLI:纯 Node.js 内置模块,零依赖
|
|
3
|
+
// - 把本包 plugins/ 下的 IDEA 插件 zip 复制到本地目标目录
|
|
4
|
+
// - 内网用户执行 `npm install @your-scope/idea-plugin-share` 即可拿到
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const { execSync } = require('child_process');
|
|
10
|
+
|
|
11
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
12
|
+
const SRC_DIR = path.join(PKG_ROOT, 'plugins');
|
|
13
|
+
const TARGET_DIR = process.env.IDEA_PLUGIN_DIR || path.join(os.homedir(), 'idea-plugins');
|
|
14
|
+
|
|
15
|
+
const COLOR = {
|
|
16
|
+
reset: '\x1b[0m',
|
|
17
|
+
green: '\x1b[32m',
|
|
18
|
+
yellow: '\x1b[33m',
|
|
19
|
+
cyan: '\x1b[36m',
|
|
20
|
+
dim: '\x1b[2m',
|
|
21
|
+
red: '\x1b[31m',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const log = {
|
|
25
|
+
ok: (m) => console.log(`${COLOR.green}✓${COLOR.reset} ${m}`),
|
|
26
|
+
info: (m) => console.log(`${COLOR.cyan}ℹ${COLOR.reset} ${m}`),
|
|
27
|
+
warn: (m) => console.log(`${COLOR.yellow}⚠${COLOR.reset} ${m}`),
|
|
28
|
+
err: (m) => console.log(`${COLOR.red}✗${COLOR.reset} ${m}`),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function findZips(dir) {
|
|
32
|
+
if (!fs.existsSync(dir)) return [];
|
|
33
|
+
return fs.readdirSync(dir).filter((f) => f.toLowerCase().endsWith('.zip'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function humanSize(bytes) {
|
|
37
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
38
|
+
let i = 0;
|
|
39
|
+
let n = bytes;
|
|
40
|
+
while (n >= 1024 && i < units.length - 1) {
|
|
41
|
+
n /= 1024;
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
44
|
+
return `${n.toFixed(n >= 10 || i === 0 ? 0 : 1)} ${units[i]}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function cmdInstall() {
|
|
48
|
+
const zips = findZips(SRC_DIR);
|
|
49
|
+
if (zips.length === 0) {
|
|
50
|
+
log.warn(`未在 ${SRC_DIR} 找到任何 .zip 文件`);
|
|
51
|
+
log.info('请把你的 IDEA 插件 zip 放进 plugins/ 目录后重新发布');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fs.mkdirSync(TARGET_DIR, { recursive: true });
|
|
56
|
+
|
|
57
|
+
log.info(`源目录: ${SRC_DIR}`);
|
|
58
|
+
log.info(`目标目录: ${TARGET_DIR}`);
|
|
59
|
+
console.log();
|
|
60
|
+
|
|
61
|
+
for (const file of zips) {
|
|
62
|
+
const src = path.join(SRC_DIR, file);
|
|
63
|
+
const dst = path.join(TARGET_DIR, file);
|
|
64
|
+
const size = fs.statSync(src).size;
|
|
65
|
+
fs.copyFileSync(src, dst);
|
|
66
|
+
log.ok(`${file} ${COLOR.dim}(${humanSize(size)})${COLOR.reset} → ${dst}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log();
|
|
70
|
+
log.info('下一步:在 IDEA 中 Settings → Plugins → ⚙ → Install Plugin from Disk');
|
|
71
|
+
log.info(`选择 ${TARGET_DIR} 下的 zip 文件安装`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function cmdList() {
|
|
75
|
+
const zips = findZips(SRC_DIR);
|
|
76
|
+
if (zips.length === 0) {
|
|
77
|
+
log.warn('本包 plugins/ 目录为空');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
console.log(`${COLOR.cyan}本包包含的 IDEA 插件:${COLOR.reset}`);
|
|
81
|
+
for (const file of zips) {
|
|
82
|
+
const full = path.join(SRC_DIR, file);
|
|
83
|
+
const size = fs.statSync(full).size;
|
|
84
|
+
console.log(` • ${file} ${COLOR.dim}(${humanSize(size)})${COLOR.reset}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function cmdPath() {
|
|
89
|
+
console.log(TARGET_DIR);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function cmdOpen() {
|
|
93
|
+
if (!fs.existsSync(TARGET_DIR)) {
|
|
94
|
+
fs.mkdirSync(TARGET_DIR, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
const cmd =
|
|
97
|
+
process.platform === 'darwin'
|
|
98
|
+
? `open "${TARGET_DIR}"`
|
|
99
|
+
: process.platform === 'win32'
|
|
100
|
+
? `explorer "${TARGET_DIR}"`
|
|
101
|
+
: `xdg-open "${TARGET_DIR}"`;
|
|
102
|
+
try {
|
|
103
|
+
execSync(cmd, { stdio: 'ignore' });
|
|
104
|
+
} catch (e) {
|
|
105
|
+
log.err(`无法打开目录: ${e.message}`);
|
|
106
|
+
log.info(`手动打开: ${TARGET_DIR}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function cmdHelp() {
|
|
111
|
+
console.log(`${COLOR.cyan}idea-plugin${COLOR.reset} - 内网 IDEA 插件分发工具
|
|
112
|
+
|
|
113
|
+
用法:
|
|
114
|
+
idea-plugin install 从本包 plugins/ 复制 zip 到本地目录(npm install 自动触发)
|
|
115
|
+
idea-plugin list 列出本包包含的插件
|
|
116
|
+
idea-plugin path 打印本地目标目录
|
|
117
|
+
idea-plugin open 打开本地目标目录
|
|
118
|
+
idea-plugin help 查看帮助
|
|
119
|
+
|
|
120
|
+
环境变量:
|
|
121
|
+
IDEA_PLUGIN_DIR 覆盖默认目标目录(默认: ~/idea-plugins)
|
|
122
|
+
`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const commands = {
|
|
126
|
+
install: cmdInstall,
|
|
127
|
+
list: cmdList,
|
|
128
|
+
ls: cmdList,
|
|
129
|
+
path: cmdPath,
|
|
130
|
+
open: cmdOpen,
|
|
131
|
+
help: cmdHelp,
|
|
132
|
+
'--help': cmdHelp,
|
|
133
|
+
'-h': cmdHelp,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const cmd = process.argv[2] || 'help';
|
|
137
|
+
const fn = commands[cmd];
|
|
138
|
+
if (!fn) {
|
|
139
|
+
log.err(`未知命令: ${cmd}`);
|
|
140
|
+
cmdHelp();
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
fn();
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ia-ccun/idea-plugin-share",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "IntelliJ IDEA 插件分发包:把 zip 放进 plugins/ 目录,npm publish 后内网 npm i 即可获取",
|
|
5
|
+
"bin": {
|
|
6
|
+
"idea-plugin": "bin/idea-plugin.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node bin/idea-plugin.js install",
|
|
10
|
+
"demo": "node examples/demo.js",
|
|
11
|
+
"list": "node bin/idea-plugin.js list"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"idea",
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
"intellij",
|
|
18
|
+
"plugin",
|
|
19
|
+
"jetbrains",
|
|
20
|
+
"distribute",
|
|
21
|
+
"intranet"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=14"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"plugins/**/*",
|
|
28
|
+
"bin/**/*",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT"
|
|
32
|
+
}
|
|
Binary file
|
|
Binary file
|