@skillsmith/cli 0.4.1 → 0.4.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/dist/.tsbuildinfo +1 -1
- package/dist/src/commands/login.test.js +3 -1
- package/dist/src/commands/login.test.js.map +1 -1
- package/dist/src/commands/logout.test.js +3 -1
- package/dist/src/commands/logout.test.js.map +1 -1
- package/dist/src/commands/manage.js +2 -2
- package/dist/src/commands/manage.js.map +1 -1
- package/dist/src/commands/search.d.ts.map +1 -1
- package/dist/src/commands/search.js +3 -3
- package/dist/src/commands/search.js.map +1 -1
- package/dist/src/commands/sync.js +5 -5
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/whoami.d.ts.map +1 -1
- package/dist/src/commands/whoami.js +5 -0
- package/dist/src/commands/whoami.js.map +1 -1
- package/dist/src/commands/whoami.test.js +3 -1
- package/dist/src/commands/whoami.test.js.map +1 -1
- package/dist/src/import.js +2 -2
- package/dist/src/import.js.map +1 -1
- package/dist/src/utils/require-tier.d.ts +38 -0
- package/dist/src/utils/require-tier.d.ts.map +1 -0
- package/dist/src/utils/require-tier.js +74 -0
- package/dist/src/utils/require-tier.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview requireTier — CLI license tier gate helper
|
|
3
|
+
* @module @skillsmith/cli/utils/require-tier
|
|
4
|
+
* @see SMI-skill-version-tracking Wave 1
|
|
5
|
+
*
|
|
6
|
+
* Throws a user-friendly error when the current license tier is below
|
|
7
|
+
* the minimum required for a CLI command or flag.
|
|
8
|
+
*
|
|
9
|
+
* Security properties:
|
|
10
|
+
* - Fail-secure: key present + validation failure → block, never fall back
|
|
11
|
+
* to community to silently allow access
|
|
12
|
+
* - SKILLSMITH_SKIP_LICENSE_CHECK=true is a CI/dev escape hatch only; it
|
|
13
|
+
* must use bracket notation per TypeScript/ESLint index-signature rules
|
|
14
|
+
* - SKILLSMITH_LICENSE_KEY is read from env but never logged
|
|
15
|
+
*/
|
|
16
|
+
import { getLicenseStatus } from './license-validation.js';
|
|
17
|
+
/**
|
|
18
|
+
* Ordered license tiers, lowest to highest.
|
|
19
|
+
* Used for tier comparison arithmetic.
|
|
20
|
+
*/
|
|
21
|
+
const TIER_ORDER = ['community', 'individual', 'team', 'enterprise'];
|
|
22
|
+
/**
|
|
23
|
+
* Prices for use in upgrade messages
|
|
24
|
+
*/
|
|
25
|
+
const TIER_PRICING = {
|
|
26
|
+
community: '$0/month',
|
|
27
|
+
individual: '$9.99/month',
|
|
28
|
+
team: '$25/user/month',
|
|
29
|
+
enterprise: '$55/user/month',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Throw if the current license tier is below minimumTier.
|
|
33
|
+
*
|
|
34
|
+
* Call this at the top of any CLI command or action that requires a paid tier.
|
|
35
|
+
*
|
|
36
|
+
* @param minimumTier - Minimum tier required to use the feature
|
|
37
|
+
* @throws Error with an upgrade prompt when the tier requirement is not met
|
|
38
|
+
* @throws Error when a license key is present but fails validation (fail-secure)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* export function createOutdatedCommand(): Command {
|
|
43
|
+
* return new Command('outdated')
|
|
44
|
+
* .action(async () => {
|
|
45
|
+
* await requireTier('individual')
|
|
46
|
+
* // ... rest of command
|
|
47
|
+
* })
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export async function requireTier(minimumTier) {
|
|
52
|
+
// CI / dev escape hatch — must use bracket notation (TS index-signature rule)
|
|
53
|
+
if (process.env['SKILLSMITH_SKIP_LICENSE_CHECK'] === 'true') {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const status = await getLicenseStatus();
|
|
57
|
+
// Fail-secure: key present + validation failure → block
|
|
58
|
+
// Never silently fall back to community when a key was supplied
|
|
59
|
+
const hasKey = Boolean(process.env['SKILLSMITH_LICENSE_KEY']);
|
|
60
|
+
if (hasKey && !status.valid) {
|
|
61
|
+
throw new Error(`License validation failed. ` +
|
|
62
|
+
`Please check your SKILLSMITH_LICENSE_KEY or visit https://skillsmith.app/account to manage your license.`);
|
|
63
|
+
}
|
|
64
|
+
const currentTier = (status.tier ?? 'community');
|
|
65
|
+
const currentIndex = TIER_ORDER.indexOf(currentTier);
|
|
66
|
+
const requiredIndex = TIER_ORDER.indexOf(minimumTier);
|
|
67
|
+
if (currentIndex < requiredIndex) {
|
|
68
|
+
const pricing = TIER_PRICING[minimumTier];
|
|
69
|
+
throw new Error(`This feature requires ${minimumTier} tier or higher (${pricing}). ` +
|
|
70
|
+
`You are currently on the ${currentTier} tier. ` +
|
|
71
|
+
`Upgrade at https://skillsmith.app/upgrade?tier=${minimumTier}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=require-tier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-tier.js","sourceRoot":"","sources":["../../../src/utils/require-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAG1D;;;GAGG;AACH,MAAM,UAAU,GAAkB,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;AAEnF;;GAEG;AACH,MAAM,YAAY,GAAgC;IAChD,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,aAAa;IACzB,IAAI,EAAE,gBAAgB;IACtB,UAAU,EAAE,gBAAgB;CAC7B,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAwB;IACxD,8EAA8E;IAC9E,IAAI,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,KAAK,MAAM,EAAE,CAAC;QAC5D,OAAM;IACR,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAA;IAEvC,wDAAwD;IACxD,gEAAgE;IAChE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAA;IAC7D,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,6BAA6B;YAC3B,0GAA0G,CAC7G,CAAA;IACH,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,WAAW,CAAgB,CAAA;IAC/D,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACpD,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAErD,IAAI,YAAY,GAAG,aAAa,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;QACzC,MAAM,IAAI,KAAK,CACb,yBAAyB,WAAW,oBAAoB,OAAO,KAAK;YAClE,4BAA4B,WAAW,SAAS;YAChD,kDAAkD,WAAW,EAAE,CAClE,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillsmith/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "CLI tools for Skillsmith skill discovery and authentication",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@inquirer/prompts": "7.10.1",
|
|
19
|
-
"@skillsmith/core": "0.4.
|
|
19
|
+
"@skillsmith/core": "0.4.14",
|
|
20
20
|
"chalk": "5.6.2",
|
|
21
21
|
"cli-table3": "0.6.5",
|
|
22
22
|
"commander": "12.1.0",
|