@pigcloud/skills 1.0.8 → 1.0.9
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.js +9 -10
- package/install.cmd +5 -5
- package/install.ps1 +30 -74
- package/install.sh +36 -168
- package/package.json +1 -1
- package/bin/runtime-bootstrap.js +0 -121
package/bin/cli.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
const fs = require('fs/promises');
|
|
4
4
|
const fsSync = require('fs');
|
|
5
5
|
const path = require('path');
|
|
6
|
-
const os = require('os');
|
|
7
|
-
const { detectRulesBundle } = require('./rules-loader');
|
|
8
|
-
const { ensureNpmRuntime } = require('./runtime-bootstrap');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
const { detectRulesBundle } = require('./rules-loader');
|
|
9
8
|
|
|
10
9
|
const PACKAGE_ROOT = path.join(__dirname, '..');
|
|
11
10
|
const SKILLS_DIR = path.join(PACKAGE_ROOT, 'skills');
|
|
@@ -463,13 +462,13 @@ function printHelp() {
|
|
|
463
462
|
console.log(' pig-skills update [--tool codex]');
|
|
464
463
|
}
|
|
465
464
|
|
|
466
|
-
async function ensureRuntimeForInstall() {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
return
|
|
472
|
-
}
|
|
465
|
+
async function ensureRuntimeForInstall() {
|
|
466
|
+
if (!commandAvailable('npm')) {
|
|
467
|
+
throw new Error('npm is not available. Install Node.js LTS first, then rerun the command.');
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return { installed: false, skipped: false, npmPath: 'npm' };
|
|
471
|
+
}
|
|
473
472
|
|
|
474
473
|
async function run() {
|
|
475
474
|
const { options, positionals } = parseArgs(process.argv.slice(2));
|
package/install.cmd
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal
|
|
3
|
-
set "SCRIPT_DIR=%~dp0"
|
|
4
|
-
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%install.ps1" %*
|
|
5
|
-
exit /b %ERRORLEVEL%
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
set "SCRIPT_DIR=%~dp0"
|
|
4
|
+
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%install.ps1" %*
|
|
5
|
+
exit /b %ERRORLEVEL%
|
package/install.ps1
CHANGED
|
@@ -1,74 +1,30 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[switch]$
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
Write-Info 'npm is missing. Installing Node.js LTS via winget...'
|
|
34
|
-
& winget install --id OpenJS.NodeJS.LTS -e --source winget --accept-package-agreements --accept-source-agreements --silent --disable-interactivity | Out-Null
|
|
35
|
-
if ($LASTEXITCODE -ne 0) {
|
|
36
|
-
throw "winget install failed with exit code $LASTEXITCODE"
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
$programFilesX86 = [Environment]::GetEnvironmentVariable('ProgramFiles(x86)')
|
|
40
|
-
$nodeDirCandidates = @(
|
|
41
|
-
Join-Path $env:ProgramFiles 'nodejs',
|
|
42
|
-
if ($programFilesX86) { Join-Path $programFilesX86 'nodejs' },
|
|
43
|
-
Join-Path $env:LocalAppData 'Programs\nodejs',
|
|
44
|
-
Join-Path $env:LocalAppData 'Microsoft\WinGet\Links'
|
|
45
|
-
) | Where-Object { $_ -and (Test-Path $_) }
|
|
46
|
-
|
|
47
|
-
foreach ($candidate in $nodeDirCandidates) {
|
|
48
|
-
if (-not (($env:PATH -split ';') -contains $candidate)) {
|
|
49
|
-
$env:PATH = "$candidate;$env:PATH"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (-not (Test-Command npm)) {
|
|
54
|
-
throw 'Node.js was installed, but npm is still not visible in this shell. Restart the shell and rerun.'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function Install-Package {
|
|
59
|
-
$repoRoot = (Resolve-Path -LiteralPath $PSScriptRoot).Path
|
|
60
|
-
$npmArgs = @('install', '-g', $repoRoot)
|
|
61
|
-
if ($SkipPostInstallSync) {
|
|
62
|
-
$env:PIG_SKILLS_SKIP_AUTO_SYNC = '1'
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
Write-Info "Installing Pig Skills from $repoRoot ..."
|
|
66
|
-
& npm @npmArgs
|
|
67
|
-
if ($LASTEXITCODE -ne 0) {
|
|
68
|
-
throw "npm install failed with exit code $LASTEXITCODE"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
Ensure-NodeRuntime
|
|
73
|
-
Install-Package
|
|
74
|
-
Write-Info 'Pig Skills installation complete.'
|
|
1
|
+
param(
|
|
2
|
+
[switch]$SkipPostInstallSync
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
$ErrorActionPreference = 'Stop'
|
|
6
|
+
|
|
7
|
+
function Write-Info([string]$Message) {
|
|
8
|
+
Write-Host $Message
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function Test-Command([string]$Name) {
|
|
12
|
+
return [bool](Get-Command $Name -ErrorAction SilentlyContinue)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (-not (Test-Command npm)) {
|
|
16
|
+
throw 'npm is not available. Install Node.js LTS first, then rerun.'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$repoRoot = (Resolve-Path -LiteralPath $PSScriptRoot).Path
|
|
20
|
+
if ($SkipPostInstallSync -or $env:PIG_SKILLS_SKIP_AUTO_SYNC -match '^(1|true|yes)$') {
|
|
21
|
+
$env:PIG_SKILLS_SKIP_AUTO_SYNC = '1'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Write-Info "Installing Pig Skills from $repoRoot ..."
|
|
25
|
+
& npm install -g $repoRoot
|
|
26
|
+
if ($LASTEXITCODE -ne 0) {
|
|
27
|
+
throw "npm install failed with exit code $LASTEXITCODE"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Write-Info 'Pig Skills installation complete.'
|
package/install.sh
CHANGED
|
@@ -1,168 +1,36 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
-
REPO_ROOT="$SCRIPT_DIR"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
printf '%s\n' "$1"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
run_privileged() {
|
|
40
|
-
if [ "$(id -u)" -eq 0 ]; then
|
|
41
|
-
"$@"
|
|
42
|
-
return
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
if has_command sudo; then
|
|
46
|
-
sudo "$@"
|
|
47
|
-
return
|
|
48
|
-
fi
|
|
49
|
-
|
|
50
|
-
die "Command requires elevated privileges: $*"
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
die() {
|
|
54
|
-
warn "$1"
|
|
55
|
-
exit 1
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
bootstrap_with_nvm() {
|
|
59
|
-
if ! has_command curl; then
|
|
60
|
-
die "curl is required to bootstrap Node.js via nvm."
|
|
61
|
-
fi
|
|
62
|
-
if ! has_command git; then
|
|
63
|
-
die "git is required to bootstrap Node.js via nvm."
|
|
64
|
-
fi
|
|
65
|
-
|
|
66
|
-
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
|
67
|
-
if [ ! -s "$NVM_DIR/nvm.sh" ]; then
|
|
68
|
-
log "npm is missing. Installing nvm and Node.js LTS..."
|
|
69
|
-
mkdir -p "$NVM_DIR"
|
|
70
|
-
tmp_install_script="$(mktemp "${TMPDIR:-/tmp}/pig-skills-nvm.XXXXXX")"
|
|
71
|
-
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh -o "$tmp_install_script"
|
|
72
|
-
bash "$tmp_install_script"
|
|
73
|
-
rm -f "$tmp_install_script"
|
|
74
|
-
fi
|
|
75
|
-
|
|
76
|
-
# shellcheck disable=SC1090
|
|
77
|
-
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
78
|
-
# shellcheck disable=SC1091
|
|
79
|
-
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
|
|
80
|
-
nvm install --lts
|
|
81
|
-
nvm use --lts
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
bootstrap_on_macos() {
|
|
85
|
-
if has_command brew; then
|
|
86
|
-
log "npm is missing. Installing Node.js via Homebrew..."
|
|
87
|
-
brew install node
|
|
88
|
-
return
|
|
89
|
-
fi
|
|
90
|
-
|
|
91
|
-
bootstrap_with_nvm
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
bootstrap_on_linux() {
|
|
95
|
-
if has_command apt-get; then
|
|
96
|
-
log "npm is missing. Installing Node.js via apt..."
|
|
97
|
-
run_privileged apt-get update
|
|
98
|
-
run_privileged apt-get install -y nodejs npm
|
|
99
|
-
return
|
|
100
|
-
fi
|
|
101
|
-
|
|
102
|
-
if has_command dnf; then
|
|
103
|
-
log "npm is missing. Installing Node.js via dnf..."
|
|
104
|
-
run_privileged dnf install -y nodejs npm
|
|
105
|
-
return
|
|
106
|
-
fi
|
|
107
|
-
|
|
108
|
-
if has_command yum; then
|
|
109
|
-
log "npm is missing. Installing Node.js via yum..."
|
|
110
|
-
run_privileged yum install -y nodejs npm
|
|
111
|
-
return
|
|
112
|
-
fi
|
|
113
|
-
|
|
114
|
-
if has_command pacman; then
|
|
115
|
-
log "npm is missing. Installing Node.js via pacman..."
|
|
116
|
-
run_privileged pacman -Sy --noconfirm nodejs npm
|
|
117
|
-
return
|
|
118
|
-
fi
|
|
119
|
-
|
|
120
|
-
if has_command zypper; then
|
|
121
|
-
log "npm is missing. Installing Node.js via zypper..."
|
|
122
|
-
run_privileged zypper --non-interactive install nodejs npm
|
|
123
|
-
return
|
|
124
|
-
fi
|
|
125
|
-
|
|
126
|
-
if has_command apk; then
|
|
127
|
-
log "npm is missing. Installing Node.js via apk..."
|
|
128
|
-
run_privileged apk add nodejs npm
|
|
129
|
-
return
|
|
130
|
-
fi
|
|
131
|
-
|
|
132
|
-
bootstrap_with_nvm
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
ensure_node_runtime() {
|
|
136
|
-
if has_command npm; then
|
|
137
|
-
return
|
|
138
|
-
fi
|
|
139
|
-
|
|
140
|
-
if is_true "$SKIP_RUNTIME_BOOTSTRAP"; then
|
|
141
|
-
die "npm is not available and runtime bootstrap is disabled. Install Node.js LTS first, then rerun."
|
|
142
|
-
fi
|
|
143
|
-
|
|
144
|
-
case "$(uname -s)" in
|
|
145
|
-
Darwin) bootstrap_on_macos ;;
|
|
146
|
-
Linux) bootstrap_on_linux ;;
|
|
147
|
-
*)
|
|
148
|
-
die "Unsupported platform for automatic bootstrap. Install Node.js LTS manually, then rerun."
|
|
149
|
-
;;
|
|
150
|
-
esac
|
|
151
|
-
|
|
152
|
-
if ! has_command npm; then
|
|
153
|
-
die "Node.js was installed, but npm is still not visible in this shell. Restart the shell and rerun."
|
|
154
|
-
fi
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
install_package() {
|
|
158
|
-
log "Installing Pig Skills from $REPO_ROOT ..."
|
|
159
|
-
if is_true "$SKIP_POSTINSTALL_SYNC"; then
|
|
160
|
-
PIG_SKILLS_SKIP_AUTO_SYNC=1 npm install -g "$REPO_ROOT"
|
|
161
|
-
else
|
|
162
|
-
npm install -g "$REPO_ROOT"
|
|
163
|
-
fi
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
ensure_node_runtime
|
|
167
|
-
install_package
|
|
168
|
-
log "Pig Skills installation complete."
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
REPO_ROOT="$SCRIPT_DIR"
|
|
6
|
+
SKIP_POSTINSTALL_SYNC="${PIG_SKILLS_SKIP_AUTO_SYNC:-0}"
|
|
7
|
+
|
|
8
|
+
for arg in "$@"; do
|
|
9
|
+
case "$arg" in
|
|
10
|
+
--skip-postinstall-sync)
|
|
11
|
+
SKIP_POSTINSTALL_SYNC=1
|
|
12
|
+
;;
|
|
13
|
+
esac
|
|
14
|
+
done
|
|
15
|
+
|
|
16
|
+
log() {
|
|
17
|
+
printf '%s\n' "$1"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
die() {
|
|
21
|
+
printf '%s\n' "$1" >&2
|
|
22
|
+
exit 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if ! command -v npm >/dev/null 2>&1; then
|
|
26
|
+
die 'npm is not available. Install Node.js LTS first, then rerun.'
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
log "Installing Pig Skills from $REPO_ROOT ..."
|
|
30
|
+
if [ "$SKIP_POSTINSTALL_SYNC" = "1" ] || [ "${SKIP_POSTINSTALL_SYNC,,}" = "true" ] || [ "${SKIP_POSTINSTALL_SYNC,,}" = "yes" ]; then
|
|
31
|
+
PIG_SKILLS_SKIP_AUTO_SYNC=1 npm install -g "$REPO_ROOT"
|
|
32
|
+
else
|
|
33
|
+
npm install -g "$REPO_ROOT"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
log 'Pig Skills installation complete.'
|
package/package.json
CHANGED
package/bin/runtime-bootstrap.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const { spawnSync } = require('child_process');
|
|
6
|
-
|
|
7
|
-
const NPM_CANDIDATES = process.platform === 'win32'
|
|
8
|
-
? [
|
|
9
|
-
path.join(process.env.ProgramFiles || 'C:\\Program Files', 'nodejs', 'npm.cmd'),
|
|
10
|
-
path.join(process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)', 'nodejs', 'npm.cmd'),
|
|
11
|
-
path.join(process.env.LocalAppData || '', 'Programs', 'nodejs', 'npm.cmd'),
|
|
12
|
-
path.join(process.env.LocalAppData || '', 'Microsoft', 'WinGet', 'Links', 'npm.cmd')
|
|
13
|
-
]
|
|
14
|
-
: [];
|
|
15
|
-
|
|
16
|
-
function commandAvailable(command) {
|
|
17
|
-
const result = spawnSync(command, ['--version'], { stdio: 'ignore' });
|
|
18
|
-
return !result.error && result.status === 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function findInstalledNpm() {
|
|
22
|
-
for (const candidate of NPM_CANDIDATES) {
|
|
23
|
-
if (candidate && fs.existsSync(candidate)) {
|
|
24
|
-
return candidate;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function refreshPathFromNpm(npmPath) {
|
|
31
|
-
if (!npmPath) return;
|
|
32
|
-
const npmDir = path.dirname(npmPath);
|
|
33
|
-
const currentPath = String(process.env.PATH || '');
|
|
34
|
-
const parts = currentPath.split(path.delimiter).filter(Boolean);
|
|
35
|
-
if (!parts.some((part) => part.toLowerCase() === npmDir.toLowerCase())) {
|
|
36
|
-
process.env.PATH = [npmDir, ...parts].join(path.delimiter);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function installNodeJsWithWinget() {
|
|
41
|
-
const args = [
|
|
42
|
-
'install',
|
|
43
|
-
'--id',
|
|
44
|
-
'OpenJS.NodeJS.LTS',
|
|
45
|
-
'-e',
|
|
46
|
-
'--source',
|
|
47
|
-
'winget',
|
|
48
|
-
'--accept-package-agreements',
|
|
49
|
-
'--accept-source-agreements',
|
|
50
|
-
'--silent',
|
|
51
|
-
'--disable-interactivity'
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
const result = spawnSync('winget', args, {
|
|
55
|
-
encoding: 'utf8',
|
|
56
|
-
stdio: ['ignore', 'pipe', 'pipe']
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (result.error) {
|
|
60
|
-
throw new Error(`Failed to launch winget: ${result.error.message}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (result.status !== 0) {
|
|
64
|
-
const message = [result.stdout, result.stderr]
|
|
65
|
-
.filter(Boolean)
|
|
66
|
-
.map((text) => String(text).trim())
|
|
67
|
-
.filter(Boolean)
|
|
68
|
-
.join('\n');
|
|
69
|
-
throw new Error(message || `winget exited with code ${result.status}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function ensureNpmRuntime(options = {}) {
|
|
74
|
-
const skip = ['1', 'true', 'yes'].includes(String(process.env.PIG_SKILLS_SKIP_RUNTIME_BOOTSTRAP || '').toLowerCase());
|
|
75
|
-
if (skip) {
|
|
76
|
-
return { installed: false, skipped: true, npmPath: commandAvailable('npm') ? 'npm' : null };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (commandAvailable('npm')) {
|
|
80
|
-
return { installed: false, skipped: false, npmPath: 'npm' };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (process.platform !== 'win32') {
|
|
84
|
-
throw new Error(
|
|
85
|
-
'npm is not available in PATH. Install Node.js 20+ first, then rerun the skill installer.'
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (!commandAvailable('winget')) {
|
|
90
|
-
throw new Error(
|
|
91
|
-
'npm is not available and winget is not installed. Install Node.js LTS manually, then rerun the skill installer.'
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!options.quiet) {
|
|
96
|
-
process.stdout.write('npm is missing. Installing Node.js LTS through winget...\n');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
installNodeJsWithWinget();
|
|
100
|
-
|
|
101
|
-
const npmPath = findInstalledNpm();
|
|
102
|
-
refreshPathFromNpm(npmPath);
|
|
103
|
-
|
|
104
|
-
if (!npmPath && !commandAvailable('npm')) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
'Node.js was installed, but npm is still not visible in this shell. Restart the shell and rerun the skill installer.'
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
installed: true,
|
|
112
|
-
skipped: false,
|
|
113
|
-
npmPath: npmPath || 'npm'
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
module.exports = {
|
|
118
|
-
ensureNpmRuntime,
|
|
119
|
-
commandAvailable,
|
|
120
|
-
findInstalledNpm
|
|
121
|
-
};
|