ali-skills 0.1.8-beta.0 → 0.1.8-beta.2

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/bin/cli.mjs CHANGED
@@ -1,27 +1,47 @@
1
1
  #!/usr/bin/env node
2
+ import { execSync } from 'child_process';
3
+
2
4
  const INTERNAL_REGISTRY = 'https://registry.anpm.alibaba-inc.com';
3
5
 
6
+ function getRegistry() {
7
+ try {
8
+ return execSync('npm config get registry', { encoding: 'utf8' }).trim().replace(/\/$/, '');
9
+ } catch {
10
+ return '';
11
+ }
12
+ }
13
+
4
14
  try {
5
15
  await import('@ali/cli-skills/bin/cli.mjs');
6
16
  } catch (err) {
7
17
  if (err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'MODULE_NOT_FOUND') {
8
- console.error(`
9
- 错误:无法加载内部依赖包 @ali/cli-skills
18
+ const registry = getRegistry();
19
+ const isInternal = registry.includes('alibaba-inc.com') || registry.includes('anpm.alibaba');
20
+
21
+ if (!isInternal) {
22
+ console.error(`
23
+ 错误:当前 npm registry 不是阿里内网源,无法安装内部依赖包 @ali/cli-skills
10
24
 
11
- 这通常是因为安装时 npm registry 不是阿里内网源导致的。
25
+ 当前 registry: ${registry || '(未知)'}
12
26
 
13
- 请选择以下方式之一重新安装:
27
+ 请选择以下方式之一重新执行:
14
28
 
15
- 配置内网源后重新执行:
16
- npm config set registry ${INTERNAL_REGISTRY}
17
- npx ali-skills
29
+ 1. 配置内网源后重新执行:
30
+ npm config set registry ${INTERNAL_REGISTRY}
31
+ npx ali-skills
18
32
 
19
- 使用 tnpx 执行:
20
- tnpx ali-skills
33
+ 2. 使用 tnpx 执行:
34
+ tnpx ali-skills
21
35
 
22
- 临时指定 registry 执行:
23
- npx --registry ${INTERNAL_REGISTRY} ali-skills
36
+ 3. 临时指定 registry 执行:
37
+ npx --registry ${INTERNAL_REGISTRY} ali-skills
38
+ `);
39
+ } else {
40
+ console.error(`
41
+ 错误:@ali/cli-skills 未找到,请尝试重新安装:
42
+ npx --registry ${INTERNAL_REGISTRY} ali-skills@latest
24
43
  `);
44
+ }
25
45
  process.exit(1);
26
46
  }
27
47
  throw err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ali-skills",
3
- "version": "0.1.8-beta.0",
3
+ "version": "0.1.8-beta.2",
4
4
  "description": "The open agent skills ecosystem",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,6 @@
9
9
  },
10
10
  "files": [
11
11
  "bin",
12
- "scripts",
13
12
  "README.md"
14
13
  ],
15
14
  "keywords": [
@@ -26,14 +25,13 @@
26
25
  "url": "git+http://gitlab.alibaba-inc.com/trip-tools/ali-skills.git"
27
26
  },
28
27
  "scripts": {
29
- "preinstall": "node scripts/preinstall.mjs",
30
28
  "publish:beta": "npm version prerelease --preid=beta --no-git-tag-version && npm publish --tag beta",
31
29
  "publish:latest:patch": "npm version patch && npm publish && git push --follow-tags && tnpm sync ali-skills",
32
30
  "publish:latest:minor": "npm version minor && npm publish && git push --follow-tags && tnpm sync ali-skills"
33
31
  },
34
32
  "author": "",
35
33
  "license": "MIT",
36
- "dependencies": {
34
+ "optionalDependencies": {
37
35
  "@ali/cli-skills": "^2.1.8"
38
36
  },
39
37
  "engines": {
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * 安装前检测 npm registry 是否为阿里内网源
4
- * 内网包 @ali/cli-skills 只在内网 registry 上发布,非内网环境无法安装
5
- */
6
-
7
- const INTERNAL_REGISTRY = 'https://registry.anpm.alibaba-inc.com';
8
- const registry = (process.env.npm_config_registry || '').replace(/\/$/, '');
9
-
10
- // 已配置内网源,直接通过
11
- if (!registry || registry.includes('alibaba-inc.com') || registry.includes('anpm.alibaba')) {
12
- process.exit(0);
13
- }
14
-
15
- console.error(`
16
- ┌─────────────────────────────────────────────────────────────────┐
17
- │ ali-skills 安装失败 │
18
- ├─────────────────────────────────────────────────────────────────┤
19
- │ │
20
- │ 当前 npm registry 不是阿里内网源,无法安装内部依赖包 │
21
- │ │
22
- │ 当前 registry: ${registry.slice(0, 47).padEnd(47)} │
23
- │ │
24
- │ 请选择以下方式之一继续: │
25
- │ │
26
- │ ① 配置内网源后重新执行: │
27
- │ npm config set registry ${INTERNAL_REGISTRY} │
28
- │ npx ali-skills │
29
- │ │
30
- │ ② 使用 tnpx 执行: │
31
- │ tnpx ali-skills │
32
- │ │
33
- │ ③ 临时指定 registry 执行: │
34
- │ npx --registry ${INTERNAL_REGISTRY} ali-skills │
35
- │ │
36
- └─────────────────────────────────────────────────────────────────┘
37
- `);
38
-
39
- process.exit(1);