@memberjunction/standards 0.0.0 → 6.1.0-edge.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.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @fileoverview Minimal semver comparison.
3
+ *
4
+ * Deliberately dependency-free. This package is meant to be installed by client repos and run in
5
+ * CI, so every dependency it carries is one more thing that can conflict with their tree. The only
6
+ * comparison it needs is "is version A newer than version B", and that is twenty lines.
7
+ *
8
+ * @module @memberjunction/standards
9
+ */
10
+ /** A parsed semver, prerelease and build metadata discarded. */
11
+ interface Parsed {
12
+ Major: number;
13
+ Minor: number;
14
+ Patch: number;
15
+ }
16
+ /**
17
+ * Parse `major.minor.patch`, tolerating a `v` prefix, a prerelease tag, and build metadata.
18
+ *
19
+ * Returns `null` rather than throwing on anything unparseable: a malformed `standardsVersion` in a
20
+ * repo's config should degrade to "treat every check as available" — visible and safe — not crash
21
+ * the tool and block the build.
22
+ */
23
+ export declare function ParseVersion(version: string): Parsed | null;
24
+ /**
25
+ * Compare two versions. Returns a negative number when `a` is older, 0 when equal, positive when
26
+ * `a` is newer. An unparseable version sorts as oldest, so unknown input never *hides* a check.
27
+ */
28
+ export declare function CompareVersions(a: string, b: string): number;
29
+ /**
30
+ * Is `candidate` newer than `baseline`?
31
+ *
32
+ * This is the version-sensitivity primitive: a check whose `Since` is newer than the repo's
33
+ * adopted `StandardsVersion` is **available, not active**.
34
+ */
35
+ export declare function IsNewerThan(candidate: string, baseline: string): boolean;
36
+ export {};
37
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gEAAgE;AAChE,UAAU,MAAM;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI3D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExE"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @fileoverview Minimal semver comparison.
3
+ *
4
+ * Deliberately dependency-free. This package is meant to be installed by client repos and run in
5
+ * CI, so every dependency it carries is one more thing that can conflict with their tree. The only
6
+ * comparison it needs is "is version A newer than version B", and that is twenty lines.
7
+ *
8
+ * @module @memberjunction/standards
9
+ */
10
+ /**
11
+ * Parse `major.minor.patch`, tolerating a `v` prefix, a prerelease tag, and build metadata.
12
+ *
13
+ * Returns `null` rather than throwing on anything unparseable: a malformed `standardsVersion` in a
14
+ * repo's config should degrade to "treat every check as available" — visible and safe — not crash
15
+ * the tool and block the build.
16
+ */
17
+ export function ParseVersion(version) {
18
+ const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
19
+ if (!match)
20
+ return null;
21
+ return { Major: Number(match[1]), Minor: Number(match[2]), Patch: Number(match[3]) };
22
+ }
23
+ /**
24
+ * Compare two versions. Returns a negative number when `a` is older, 0 when equal, positive when
25
+ * `a` is newer. An unparseable version sorts as oldest, so unknown input never *hides* a check.
26
+ */
27
+ export function CompareVersions(a, b) {
28
+ const left = ParseVersion(a);
29
+ const right = ParseVersion(b);
30
+ if (!left && !right)
31
+ return 0;
32
+ if (!left)
33
+ return -1;
34
+ if (!right)
35
+ return 1;
36
+ return left.Major - right.Major || left.Minor - right.Minor || left.Patch - right.Patch;
37
+ }
38
+ /**
39
+ * Is `candidate` newer than `baseline`?
40
+ *
41
+ * This is the version-sensitivity primitive: a check whose `Since` is newer than the repo's
42
+ * adopted `StandardsVersion` is **available, not active**.
43
+ */
44
+ export function IsNewerThan(candidate, baseline) {
45
+ return CompareVersions(candidate, baseline) > 0;
46
+ }
47
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IACxC,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACzF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS;IAChD,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;AAC5F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,QAAgB;IAC3D,OAAO,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,38 @@
1
1
  {
2
2
  "name": "@memberjunction/standards",
3
- "version": "0.0.0",
4
- "description": "OIDC trusted publishing setup package for @memberjunction/standards",
3
+ "type": "module",
4
+ "version": "6.1.0-edge.0",
5
+ "description": "MemberJunction engineering standards as runnable, versioned checks — plus the scaffolding that gets a repo enforcing them. Opt-in per check; a new standard never changes an existing repo's result.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "mj-standards": "bin/run.js"
10
+ },
11
+ "files": [
12
+ "/dist",
13
+ "/bin",
14
+ "/schema"
15
+ ],
5
16
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
17
+ "MemberJunction",
18
+ "standards",
19
+ "lint",
20
+ "architecture"
21
+ ],
22
+ "author": "MemberJunction.com",
23
+ "license": "ISC",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/MemberJunction/MJ"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.9.3",
30
+ "tsc-alias": "^1.8.16",
31
+ "vitest": "^4.0.18"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc && tsc-alias -f",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest"
37
+ }
38
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://memberjunction.com/schema/mj-standards.schema.json",
4
+ "title": "MJ standards adoption",
5
+ "description": "A repository's record of which MemberJunction engineering standards it enforces, and how strictly. Written and updated by `mj standards adopt`; safe to edit by hand.",
6
+ "type": "object",
7
+ "required": ["StandardsVersion", "Checks"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "$schema": {
11
+ "type": "string",
12
+ "description": "Pointer to this schema, for editor completion."
13
+ },
14
+ "StandardsVersion": {
15
+ "type": "string",
16
+ "description": "The MJ version this repo adopted standards against. Checks introduced after this version are reported as available and do NOT run — that is what stops a package upgrade from activating new rules here. Bump it deliberately with `mj standards adopt --upgrade`.",
17
+ "pattern": "^v?\\d+\\.\\d+\\.\\d+"
18
+ },
19
+ "Roots": {
20
+ "type": "array",
21
+ "description": "Default repo-relative directories to scan, for checks that do not name their own.",
22
+ "items": { "type": "string" }
23
+ },
24
+ "Checks": {
25
+ "type": "object",
26
+ "description": "Per-check configuration. A check absent from this map does not run — adoption is explicit.",
27
+ "additionalProperties": {
28
+ "type": "object",
29
+ "required": ["Severity"],
30
+ "additionalProperties": false,
31
+ "properties": {
32
+ "Severity": {
33
+ "enum": ["off", "warn", "error"],
34
+ "description": "off = registered but not run. warn = reported, exit code stays 0 (what a newly adopted check should be for one cycle). error = reported, exit code 1."
35
+ },
36
+ "Roots": {
37
+ "type": "array",
38
+ "description": "Overrides the check's default roots.",
39
+ "items": { "type": "string" }
40
+ },
41
+ "Options": {
42
+ "type": "object",
43
+ "description": "Check-specific options. See `mj standards list` for what each check accepts.",
44
+ "additionalProperties": true
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }