Skip to content

Commit 3c6dcc8

Browse files
feat(license): warn NVM4102 in community feature mode
Certified packages without an active commercial license get a clear advisory instead of the community LocalAppData layout warn. Co-authored-by: Cursor
1 parent 9b8f410 commit 3c6dcc8

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

‎licensing/feature_mode.go‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package license
2+
3+
import "fmt"
4+
5+
const (
6+
// FeatureModeWarnCode is the human-facing tag when a certified package runs
7+
// without an active commercial access token (community feature mode).
8+
FeatureModeWarnCode = "NVM4102"
9+
// FeatureModeWarnEventID is the classic Application log EventId for that advisory.
10+
FeatureModeWarnEventID = 4102
11+
)
12+
13+
// InCommunityFeatureMode reports whether this is a certified package operating
14+
// without an active commercial license. Community Inno builds never return true.
15+
func InCommunityFeatureMode() bool {
16+
if IsCommunityBuild() {
17+
return false
18+
}
19+
_, ok := commercialLicenseType(accessTokenForEdition())
20+
return !ok
21+
}
22+
23+
// CommunityFeatureModeWarning returns the stderr/event-log advisory for certified
24+
// packages running without a valid commercial access token.
25+
func CommunityFeatureModeWarning() string {
26+
return fmt.Sprintf(
27+
"%s: Missing/invalid license. Operating in community build mode.",
28+
FeatureModeWarnCode,
29+
)
30+
}

‎licensing/feature_mode_test.go‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package license
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
func TestInCommunityFeatureModeCertifiedWithoutToken(t *testing.T) {
9+
withBuildChannel(t, "certified")
10+
withEditionToken(t, "")
11+
12+
if !InCommunityFeatureMode() {
13+
t.Fatal("expected community feature mode without token")
14+
}
15+
if !strings.Contains(CommunityFeatureModeWarning(), FeatureModeWarnCode) {
16+
t.Fatalf("warning missing code: %q", CommunityFeatureModeWarning())
17+
}
18+
}
19+
20+
func TestInCommunityFeatureModeCertifiedWithCommercial(t *testing.T) {
21+
withBuildChannel(t, "certified")
22+
withEditionToken(t, mustMintAccessToken(t, "governance", false))
23+
24+
if InCommunityFeatureMode() {
25+
t.Fatal("expected active commercial license")
26+
}
27+
}
28+
29+
func TestInCommunityFeatureModeCommunityBuild(t *testing.T) {
30+
withBuildChannel(t, "community")
31+
withEditionToken(t, "")
32+
33+
if InCommunityFeatureMode() {
34+
t.Fatal("community package is not community feature mode")
35+
}
36+
}

0 commit comments

Comments
 (0)