creative-upload-extension-updater 0.1.2 → 0.1.3

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 CHANGED
@@ -9,10 +9,9 @@ npm install -g @ttam/creative-upload-extension-updater
9
9
  creative-upload-extension-updater install
10
10
  ```
11
11
 
12
- 过渡期默认使用内网 Devbox 地址 `http://10.37.83.141:3100`,无需额外参数。其他 HTTP 地址必须显式传入 `--allow-insecure`;切换 HTTPS 后请使用 `--registry https://registry.example.com`。
13
- The command downloads and verifies the first release, then prints the fixed extension directory. In Chrome, enable Developer mode once and choose **Load unpacked** for that directory.
12
+ `npm install` 完成后会提示运行 `creative-upload-updater install`;安装 npm 包本身不会自动下载插件或修改 Chrome。
14
13
 
15
- The extension ID is fixed to `amfhocfbdlbooohhoinhhhgobfdmaljc`. Do not change the manifest public key after users begin using this updater.
14
+ 安装成功后,CLI 会输出扩展目录,并引导依次打开 `chrome://extensions`、开启开发者模式、点击「加载已解压的扩展程序」。在 macOS 文件选择器中按 `Command + Shift + G`,粘贴输出的目录即可直接打开。
16
15
 
17
16
  ## Operations
18
17
 
@@ -21,12 +20,11 @@ creative-upload-extension-updater diagnose
21
20
  creative-upload-extension-updater update
22
21
  creative-upload-extension-updater rollback
23
22
  creative-upload-updater uninstall
24
- creative-upload-updater uninstall --purge
25
23
  ```
26
24
 
27
25
  `update` immediately checks the Registry and applies a newer verified release when available. On macOS it then opens a controlled extension URL so the running extension calls `chrome.runtime.reload()` automatically; pass `--no-reload` to only replace files. `rollback` restores the previous verified extension directory. Chrome must then reload the extension once.
28
26
 
29
- `uninstall` removes the Native Messaging registration and updater configuration but retains the downloaded extension. `uninstall --purge` additionally deletes the extension and rollback files. Both modes require manually removing the loaded extension in `chrome://extensions`; uninstall the CLI itself with `npm uninstall -g creative-upload-extension-updater`.
27
+ `uninstall` removes the Native Messaging registration, updater configuration, downloaded extension, and rollback files. It still requires manually removing the loaded extension in `chrome://extensions`; uninstall the CLI itself with `npm uninstall -g creative-upload-extension-updater`.
30
28
 
31
29
  ## Security
32
30
 
@@ -4,6 +4,14 @@ const path = require('node:path');
4
4
  const { diagnose, install, requestChromeReload, rollback, uninstall, update, TRANSITION_HTTP_REGISTRY_ORIGIN } = require('../lib/updater');
5
5
 
6
6
  const packageVersion = require('../package.json').version;
7
+ const printInstallGuide = (extensionDirectory) => {
8
+ process.stdout.write('\n安装完成。请在 Chrome 完成一次加载:\n\n');
9
+ process.stdout.write(' 1. 打开 chrome://extensions\n');
10
+ process.stdout.write(' 2. 开启右上角「开发者模式」\n');
11
+ process.stdout.write(' 3. 点击「加载已解压的扩展程序」\n');
12
+ process.stdout.write(` 4. 在文件选择器中按 Command + Shift + G,粘贴并打开:${extensionDirectory}\n\n`);
13
+ process.stdout.write('后续发布新版本后,扩展会定时检查更新;也可手动运行 creative-upload-updater update。\n');
14
+ };
7
15
  const usage = `用法:creative-upload-updater <命令> [选项]
8
16
 
9
17
  命令:
@@ -11,7 +19,7 @@ const usage = `用法:creative-upload-updater <命令> [选项]
11
19
  update [--no-reload] 下载并应用最新插件版本
12
20
  diagnose 输出本机安装诊断
13
21
  rollback 回滚到上一插件版本
14
- uninstall [--purge] 移除更新器注册;--purge 同时删除插件文件
22
+ uninstall 移除更新器注册、插件文件与历史版本
15
23
 
16
24
  选项:
17
25
  --help, -h 显示帮助
@@ -50,6 +58,7 @@ const main = async () => {
50
58
  hostPath: path.resolve(__dirname, 'native-host.js'),
51
59
  });
52
60
  process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
61
+ printInstallGuide(result.extensionDirectory);
53
62
  return;
54
63
  }
55
64
  if (command === 'diagnose') return process.stdout.write(`${JSON.stringify(diagnose(), null, 2)}\n`);
@@ -62,7 +71,7 @@ const main = async () => {
62
71
  return process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
63
72
  }
64
73
  if (command === 'rollback') return process.stdout.write(`${JSON.stringify(rollback(), null, 2)}\n`);
65
- if (command === 'uninstall') return process.stdout.write(`${JSON.stringify(uninstall({ purge: args.purge === true }), null, 2)}\n`);
74
+ if (command === 'uninstall') return process.stdout.write(`${JSON.stringify(uninstall(), null, 2)}\n`);
66
75
  throw new Error(`未知命令:${command}\n\n${usage}`);
67
76
  };
68
77
 
package/lib/updater.js CHANGED
@@ -163,17 +163,14 @@ const install = async ({ registryUrl = TRANSITION_HTTP_REGISTRY_ORIGIN, extensio
163
163
  fs.writeFileSync(nativeHostManifestPath, `${JSON.stringify({ name: HOST_NAME, description: 'Creative Upload Extension Updater', path: launcherPath, type: 'stdio', allowed_origins: [`chrome-extension://${extensionId}/`] }, null, 2)}\n`, { mode: 0o600 });
164
164
  return { ...update, extensionDirectory, extensionId };
165
165
  };
166
- const uninstall = ({ purge = false } = {}) => {
166
+ const uninstall = () => {
167
167
  const nativeHostRegistered = fs.existsSync(nativeHostManifestPath);
168
168
  fs.rmSync(nativeHostManifestPath, { force: true });
169
- fs.rmSync(configPath, { force: true });
170
- fs.rmSync(nativeHostLauncherPath, { force: true });
171
- if (purge) fs.rmSync(baseDirectory, { recursive: true, force: true });
169
+ fs.rmSync(baseDirectory, { recursive: true, force: true });
172
170
  return {
173
171
  nativeHostRemoved: nativeHostRegistered,
174
172
  extensionDirectory,
175
- extensionRetained: !purge && fs.existsSync(extensionDirectory),
176
- purged: purge,
173
+ extensionRemoved: !fs.existsSync(extensionDirectory),
177
174
  chromeAction: '请在 chrome://extensions 手动移除已加载的扩展。',
178
175
  };
179
176
  };
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "creative-upload-extension-updater",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "description": "Native Messaging updater for the Creative Upload unpacked Chrome extension.",
6
+ "scripts": {
7
+ "postinstall": "node scripts/postinstall.js"
8
+ },
6
9
  "bin": {
7
10
  "creative-upload-updater": "bin/creative-upload-extension-updater.js"
8
11
  },
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ const packageInfo = require('../package.json');
4
+
5
+ process.stdout.write(`\nCreative Upload Extension Updater v${packageInfo.version} 已安装。\n`);
6
+ process.stdout.write('下一步运行:creative-upload-updater install\n');
7
+ process.stdout.write('该命令会下载已验证的插件版本,并引导你在 Chrome 中加载扩展。\n\n');