@anytio/pspm 0.7.3 → 0.8.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/CHANGELOG.md +9 -0
- package/README.md +8 -0
- package/dist/index.js +166 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to the PSPM CLI will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.0] - 2026-03-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`upgrade` command**: Self-update pspm to the latest version with automatic package manager detection
|
|
13
|
+
- `pspm upgrade` - Detects and uses your package manager (pnpm, npm, yarn, bun)
|
|
14
|
+
- Supports both global and npx installations
|
|
15
|
+
- **Update notifier**: Background check against npm registry every 24 hours warns when a newer version is available
|
|
16
|
+
|
|
8
17
|
## [0.7.3] - 2026-03-05
|
|
9
18
|
|
|
10
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -154,6 +154,14 @@ pspm config show # Show resolved configuration
|
|
|
154
154
|
pspm config init # Create .pspmrc in current directory
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
### Self-Update
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pspm upgrade # Update pspm to the latest version
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Automatically detects your package manager (pnpm, npm, yarn, bun). The CLI also checks for updates in the background every 24 hours and notifies you when a newer version is available.
|
|
164
|
+
|
|
157
165
|
## Configuration
|
|
158
166
|
|
|
159
167
|
PSPM uses a simple npm-like INI configuration format.
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { stat, writeFile, readdir, mkdir, rm, rename, access as access$1, readFile, symlink, lstat, unlink, cp, readlink } from 'fs/promises';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
|
-
import {
|
|
4
|
+
import { join, dirname, basename, resolve, relative } from 'path';
|
|
5
5
|
import * as ini from 'ini';
|
|
6
6
|
import ignore from 'ignore';
|
|
7
7
|
import { createHash, randomBytes } from 'crypto';
|
|
@@ -14,7 +14,7 @@ import { Command } from 'commander';
|
|
|
14
14
|
import { createInterface } from 'readline';
|
|
15
15
|
import http from 'http';
|
|
16
16
|
import open from 'open';
|
|
17
|
-
import { exec as exec$1 } from 'child_process';
|
|
17
|
+
import { exec as exec$1, execSync } from 'child_process';
|
|
18
18
|
import { promisify } from 'util';
|
|
19
19
|
|
|
20
20
|
var __defProp = Object.defineProperty;
|
|
@@ -1986,16 +1986,16 @@ async function installFromNode(node, options) {
|
|
|
1986
1986
|
const skillsDir = getSkillsDir();
|
|
1987
1987
|
const destDir = join(skillsDir, username, name);
|
|
1988
1988
|
await mkdir(destDir, { recursive: true });
|
|
1989
|
-
const { writeFile:
|
|
1989
|
+
const { writeFile: writeFile10 } = await import('fs/promises');
|
|
1990
1990
|
const tempFile = join(destDir, ".temp.tgz");
|
|
1991
|
-
await
|
|
1991
|
+
await writeFile10(tempFile, tarballBuffer);
|
|
1992
1992
|
const { exec: exec2 } = await import('child_process');
|
|
1993
1993
|
const { promisify: promisify2 } = await import('util');
|
|
1994
1994
|
const execAsync = promisify2(exec2);
|
|
1995
1995
|
try {
|
|
1996
1996
|
await rm(destDir, { recursive: true, force: true });
|
|
1997
1997
|
await mkdir(destDir, { recursive: true });
|
|
1998
|
-
await
|
|
1998
|
+
await writeFile10(tempFile, tarballBuffer);
|
|
1999
1999
|
await execAsync(
|
|
2000
2000
|
`tar -xzf "${tempFile}" -C "${destDir}" --strip-components=1`
|
|
2001
2001
|
);
|
|
@@ -2331,19 +2331,19 @@ async function access(specifier, options) {
|
|
|
2331
2331
|
packageName = parsed.name;
|
|
2332
2332
|
packageUsername = parsed.username;
|
|
2333
2333
|
} else {
|
|
2334
|
-
const { readFile:
|
|
2335
|
-
const { join:
|
|
2334
|
+
const { readFile: readFile10 } = await import('fs/promises');
|
|
2335
|
+
const { join: join16 } = await import('path');
|
|
2336
2336
|
let manifest = null;
|
|
2337
2337
|
try {
|
|
2338
|
-
const content = await
|
|
2339
|
-
|
|
2338
|
+
const content = await readFile10(
|
|
2339
|
+
join16(process.cwd(), "pspm.json"),
|
|
2340
2340
|
"utf-8"
|
|
2341
2341
|
);
|
|
2342
2342
|
manifest = JSON.parse(content);
|
|
2343
2343
|
} catch {
|
|
2344
2344
|
try {
|
|
2345
|
-
const content = await
|
|
2346
|
-
|
|
2345
|
+
const content = await readFile10(
|
|
2346
|
+
join16(process.cwd(), "package.json"),
|
|
2347
2347
|
"utf-8"
|
|
2348
2348
|
);
|
|
2349
2349
|
manifest = JSON.parse(content);
|
|
@@ -4474,6 +4474,99 @@ async function update(options) {
|
|
|
4474
4474
|
process.exit(1);
|
|
4475
4475
|
}
|
|
4476
4476
|
}
|
|
4477
|
+
async function upgrade() {
|
|
4478
|
+
const packageName = "@anytio/pspm";
|
|
4479
|
+
try {
|
|
4480
|
+
const currentVersion = getCurrentVersion();
|
|
4481
|
+
console.log("Checking for updates...\n");
|
|
4482
|
+
const latestVersion = getLatestVersion3(packageName);
|
|
4483
|
+
if (!latestVersion) {
|
|
4484
|
+
console.error("Error: Could not fetch latest version from registry.");
|
|
4485
|
+
process.exit(1);
|
|
4486
|
+
}
|
|
4487
|
+
if (currentVersion === latestVersion) {
|
|
4488
|
+
console.log(`Already on the latest version: ${currentVersion}`);
|
|
4489
|
+
return;
|
|
4490
|
+
}
|
|
4491
|
+
console.log(` Current version: ${currentVersion}`);
|
|
4492
|
+
console.log(` Latest version: ${latestVersion}
|
|
4493
|
+
`);
|
|
4494
|
+
const pm = detectPackageManager();
|
|
4495
|
+
const installCmd = getInstallCommand(pm, packageName, latestVersion);
|
|
4496
|
+
console.log(`Upgrading via ${pm}...
|
|
4497
|
+
`);
|
|
4498
|
+
console.log(` $ ${installCmd}
|
|
4499
|
+
`);
|
|
4500
|
+
execSync(installCmd, { stdio: "inherit" });
|
|
4501
|
+
console.log(`
|
|
4502
|
+
Successfully upgraded to ${latestVersion}`);
|
|
4503
|
+
} catch (error) {
|
|
4504
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
4505
|
+
console.error(`Error: ${message}`);
|
|
4506
|
+
process.exit(1);
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
function getCurrentVersion() {
|
|
4510
|
+
try {
|
|
4511
|
+
const output = execSync("pspm --version", {
|
|
4512
|
+
encoding: "utf-8",
|
|
4513
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
4514
|
+
}).trim();
|
|
4515
|
+
return output;
|
|
4516
|
+
} catch {
|
|
4517
|
+
return "unknown";
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
function getLatestVersion3(packageName) {
|
|
4521
|
+
try {
|
|
4522
|
+
const output = execSync(`npm view ${packageName} version`, {
|
|
4523
|
+
encoding: "utf-8",
|
|
4524
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
4525
|
+
}).trim();
|
|
4526
|
+
return output || null;
|
|
4527
|
+
} catch {
|
|
4528
|
+
return null;
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
function detectPackageManager() {
|
|
4532
|
+
try {
|
|
4533
|
+
const pnpmList = execSync("pnpm list -g --depth=0 2>/dev/null", {
|
|
4534
|
+
encoding: "utf-8",
|
|
4535
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
4536
|
+
});
|
|
4537
|
+
if (pnpmList.includes("@anytio/pspm")) return "pnpm";
|
|
4538
|
+
} catch {
|
|
4539
|
+
}
|
|
4540
|
+
try {
|
|
4541
|
+
const bunList = execSync("bun pm ls -g 2>/dev/null", {
|
|
4542
|
+
encoding: "utf-8",
|
|
4543
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
4544
|
+
});
|
|
4545
|
+
if (bunList.includes("@anytio/pspm")) return "bun";
|
|
4546
|
+
} catch {
|
|
4547
|
+
}
|
|
4548
|
+
try {
|
|
4549
|
+
const yarnList = execSync("yarn global list 2>/dev/null", {
|
|
4550
|
+
encoding: "utf-8",
|
|
4551
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
4552
|
+
});
|
|
4553
|
+
if (yarnList.includes("@anytio/pspm")) return "yarn";
|
|
4554
|
+
} catch {
|
|
4555
|
+
}
|
|
4556
|
+
return "npm";
|
|
4557
|
+
}
|
|
4558
|
+
function getInstallCommand(pm, packageName, version3) {
|
|
4559
|
+
switch (pm) {
|
|
4560
|
+
case "pnpm":
|
|
4561
|
+
return `pnpm add -g ${packageName}@${version3}`;
|
|
4562
|
+
case "yarn":
|
|
4563
|
+
return `yarn global add ${packageName}@${version3}`;
|
|
4564
|
+
case "bun":
|
|
4565
|
+
return `bun add -g ${packageName}@${version3}`;
|
|
4566
|
+
case "npm":
|
|
4567
|
+
return `npm install -g ${packageName}@${version3}`;
|
|
4568
|
+
}
|
|
4569
|
+
}
|
|
4477
4570
|
|
|
4478
4571
|
// src/commands/version.ts
|
|
4479
4572
|
init_manifest2();
|
|
@@ -4547,6 +4640,63 @@ async function whoami() {
|
|
|
4547
4640
|
process.exit(1);
|
|
4548
4641
|
}
|
|
4549
4642
|
}
|
|
4643
|
+
var PACKAGE_NAME = "@anytio/pspm";
|
|
4644
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
4645
|
+
var CACHE_DIR = join(homedir(), ".pspm");
|
|
4646
|
+
var CACHE_FILE = join(CACHE_DIR, "update-check.json");
|
|
4647
|
+
async function checkForUpdates(currentVersion) {
|
|
4648
|
+
try {
|
|
4649
|
+
const cache = await readCache();
|
|
4650
|
+
if (cache && Date.now() - cache.lastCheck < CHECK_INTERVAL_MS) {
|
|
4651
|
+
if (cache.latestVersion !== currentVersion) {
|
|
4652
|
+
printUpdateWarning(currentVersion, cache.latestVersion);
|
|
4653
|
+
}
|
|
4654
|
+
return;
|
|
4655
|
+
}
|
|
4656
|
+
fetchAndCache(currentVersion);
|
|
4657
|
+
} catch {
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
async function readCache() {
|
|
4661
|
+
try {
|
|
4662
|
+
const content = await readFile(CACHE_FILE, "utf-8");
|
|
4663
|
+
return JSON.parse(content);
|
|
4664
|
+
} catch {
|
|
4665
|
+
return null;
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
async function writeCache(cache) {
|
|
4669
|
+
await mkdir(CACHE_DIR, { recursive: true });
|
|
4670
|
+
await writeFile(CACHE_FILE, JSON.stringify(cache));
|
|
4671
|
+
}
|
|
4672
|
+
function fetchAndCache(currentVersion) {
|
|
4673
|
+
try {
|
|
4674
|
+
const latestVersion = execSync(`npm view ${PACKAGE_NAME} version`, {
|
|
4675
|
+
encoding: "utf-8",
|
|
4676
|
+
timeout: 5e3,
|
|
4677
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
4678
|
+
}).trim();
|
|
4679
|
+
if (!latestVersion) return;
|
|
4680
|
+
const cache = {
|
|
4681
|
+
lastCheck: Date.now(),
|
|
4682
|
+
latestVersion
|
|
4683
|
+
};
|
|
4684
|
+
writeCache(cache).catch(() => {
|
|
4685
|
+
});
|
|
4686
|
+
if (latestVersion !== currentVersion) {
|
|
4687
|
+
printUpdateWarning(currentVersion, latestVersion);
|
|
4688
|
+
}
|
|
4689
|
+
} catch {
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4692
|
+
function printUpdateWarning(currentVersion, latestVersion) {
|
|
4693
|
+
console.warn(
|
|
4694
|
+
`
|
|
4695
|
+
Update available: ${currentVersion} \u2192 ${latestVersion}
|
|
4696
|
+
Run \`pspm upgrade\` to update
|
|
4697
|
+
`
|
|
4698
|
+
);
|
|
4699
|
+
}
|
|
4550
4700
|
|
|
4551
4701
|
// src/index.ts
|
|
4552
4702
|
var __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
@@ -4565,6 +4715,9 @@ configCmd.command("init").description("Create a .pspmrc file in the current dire
|
|
|
4565
4715
|
registry: options.registry
|
|
4566
4716
|
});
|
|
4567
4717
|
});
|
|
4718
|
+
program.command("upgrade").description("Upgrade pspm to the latest version").action(async () => {
|
|
4719
|
+
await upgrade();
|
|
4720
|
+
});
|
|
4568
4721
|
program.command("login").description("Log in via browser or with an API key").option(
|
|
4569
4722
|
"--api-key <key>",
|
|
4570
4723
|
"API key for direct authentication (skips browser)"
|
|
@@ -4676,6 +4829,7 @@ program.command("deprecate <specifier> [message]").description(
|
|
|
4676
4829
|
).option("--undo", "Remove deprecation status").action(async (specifier, message, options) => {
|
|
4677
4830
|
await deprecate(specifier, message, { undo: options.undo });
|
|
4678
4831
|
});
|
|
4679
|
-
program.
|
|
4832
|
+
await program.parseAsync();
|
|
4833
|
+
await checkForUpdates(version2);
|
|
4680
4834
|
//# sourceMappingURL=index.js.map
|
|
4681
4835
|
//# sourceMappingURL=index.js.map
|