@oddessentials/repo-standards 4.1.0 → 4.3.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/dist/cli.cjs +116 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +13 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.js +86 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +1 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -7
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/scripts/build.ts +172 -0
- package/scripts/detect-bazel.test.ts +61 -0
- package/scripts/detect-bazel.ts +82 -0
- package/scripts/generate-instructions.ts +174 -0
- package/scripts/generate-standards.ts +247 -0
- package/scripts/sync-manifest-version.cjs +32 -0
- package/scripts/validate-schema.ts +289 -0
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/cli.ts
|
|
22
|
+
var cli_exports = {};
|
|
23
|
+
__export(cli_exports, {
|
|
24
|
+
VERSION: () => VERSION
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(cli_exports);
|
|
27
|
+
|
|
28
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
29
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
30
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
31
|
+
|
|
32
|
+
// src/cli.ts
|
|
33
|
+
var import_node_module = require("module");
|
|
34
|
+
|
|
35
|
+
// src/index.ts
|
|
36
|
+
var import_node_url = require("url");
|
|
37
|
+
var import_node_fs = require("fs");
|
|
38
|
+
var import_node_path = require("path");
|
|
39
|
+
var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
40
|
+
var __dirname = (0, import_node_path.dirname)(__filename2);
|
|
41
|
+
var isDevMode = __dirname.includes("src");
|
|
42
|
+
var configDir = isDevMode ? (0, import_node_path.join)(__dirname, "..", "config") : (0, import_node_path.join)(__dirname, "config");
|
|
43
|
+
function loadMasterSpec() {
|
|
44
|
+
const filePath = (0, import_node_path.join)(configDir, "standards.json");
|
|
45
|
+
return JSON.parse((0, import_node_fs.readFileSync)(filePath, "utf8"));
|
|
46
|
+
}
|
|
47
|
+
function loadBaseline(stack, ci) {
|
|
48
|
+
const suffix = ci ? `.${ci}` : "";
|
|
49
|
+
const file = `standards.${stack}${suffix}.json`;
|
|
50
|
+
const filePath = (0, import_node_path.join)(configDir, file);
|
|
51
|
+
return JSON.parse((0, import_node_fs.readFileSync)(filePath, "utf8"));
|
|
52
|
+
}
|
|
53
|
+
function listSupportedStacks() {
|
|
54
|
+
const spec = loadMasterSpec();
|
|
55
|
+
return Object.keys(spec.stacks);
|
|
56
|
+
}
|
|
57
|
+
function listSupportedCiSystems() {
|
|
58
|
+
const spec = loadMasterSpec();
|
|
59
|
+
return spec.ciSystems;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/cli.ts
|
|
63
|
+
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
64
|
+
var pkg = require2("../package.json");
|
|
65
|
+
var VERSION = pkg.version;
|
|
66
|
+
function printHelp() {
|
|
67
|
+
console.log(`repo-standards v${VERSION}
|
|
68
|
+
|
|
69
|
+
Usage:
|
|
70
|
+
repo-standards --version Print version and exit
|
|
71
|
+
repo-standards --help Print this help message
|
|
72
|
+
repo-standards <stack> [ci] Get standards for a stack (optional CI system)
|
|
73
|
+
|
|
74
|
+
Supported stacks: ${listSupportedStacks().join(", ")}
|
|
75
|
+
Supported CI systems: ${listSupportedCiSystems().join(", ")}
|
|
76
|
+
|
|
77
|
+
Examples:
|
|
78
|
+
repo-standards typescript-js
|
|
79
|
+
repo-standards python github-actions
|
|
80
|
+
`);
|
|
81
|
+
}
|
|
82
|
+
function main() {
|
|
83
|
+
const args = process.argv.slice(2);
|
|
84
|
+
if (args.includes("--version") || args.includes("-V")) {
|
|
85
|
+
console.log(VERSION);
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}
|
|
88
|
+
if (args.includes("--help") || args.includes("-h") || args.length === 0) {
|
|
89
|
+
printHelp();
|
|
90
|
+
process.exit(args.length === 0 ? 1 : 0);
|
|
91
|
+
}
|
|
92
|
+
const [stackArg, ciArg] = args;
|
|
93
|
+
const validStacks = listSupportedStacks();
|
|
94
|
+
const validCiSystems = listSupportedCiSystems();
|
|
95
|
+
if (!validStacks.includes(stackArg)) {
|
|
96
|
+
console.error(`Error: Unknown stack "${stackArg}"`);
|
|
97
|
+
console.error(`Valid stacks: ${validStacks.join(", ")}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
if (ciArg && !validCiSystems.includes(ciArg)) {
|
|
101
|
+
console.error(`Error: Unknown CI system "${ciArg}"`);
|
|
102
|
+
console.error(`Valid CI systems: ${validCiSystems.join(", ")}`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
const standards = loadBaseline(
|
|
106
|
+
stackArg,
|
|
107
|
+
ciArg
|
|
108
|
+
);
|
|
109
|
+
console.log(JSON.stringify(standards, null, 2));
|
|
110
|
+
}
|
|
111
|
+
main();
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
VERSION
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../node_modules/tsup/assets/cjs_shims.js","../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * repo-standards CLI\n *\n * Usage:\n * repo-standards --version\n * repo-standards --help\n * repo-standards <stack> [ci-system]\n */\n\nimport { createRequire } from \"node:module\";\nimport {\n loadBaseline,\n listSupportedStacks,\n listSupportedCiSystems,\n} from \"./index.js\";\nimport type { StackId, CiSystem } from \"./types.js\";\n\n// Dynamic version reading from package.json for determinism invariant compliance\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\") as { version: string };\n\n/** Package version - dynamically read from package.json for determinism */\nexport const VERSION: string = pkg.version;\n\nfunction printHelp(): void {\n console.log(`repo-standards v${VERSION}\n\nUsage:\n repo-standards --version Print version and exit\n repo-standards --help Print this help message\n repo-standards <stack> [ci] Get standards for a stack (optional CI system)\n\nSupported stacks: ${listSupportedStacks().join(\", \")}\nSupported CI systems: ${listSupportedCiSystems().join(\", \")}\n\nExamples:\n repo-standards typescript-js\n repo-standards python github-actions\n`);\n}\n\nfunction main(): void {\n const args = process.argv.slice(2);\n\n // Handle --version\n if (args.includes(\"--version\") || args.includes(\"-V\")) {\n console.log(VERSION);\n process.exit(0);\n }\n\n // Handle --help or no args\n if (args.includes(\"--help\") || args.includes(\"-h\") || args.length === 0) {\n printHelp();\n process.exit(args.length === 0 ? 1 : 0);\n }\n\n const [stackArg, ciArg] = args;\n const validStacks = listSupportedStacks();\n const validCiSystems = listSupportedCiSystems();\n\n // Validate stack\n if (!validStacks.includes(stackArg as StackId)) {\n console.error(`Error: Unknown stack \"${stackArg}\"`);\n console.error(`Valid stacks: ${validStacks.join(\", \")}`);\n process.exit(1);\n }\n\n // Validate CI system if provided\n if (ciArg && !validCiSystems.includes(ciArg as CiSystem)) {\n console.error(`Error: Unknown CI system \"${ciArg}\"`);\n console.error(`Valid CI systems: ${validCiSystems.join(\", \")}`);\n process.exit(1);\n }\n\n // Load and output standards\n const standards = loadBaseline(\n stackArg as StackId,\n ciArg as CiSystem | undefined,\n );\n console.log(JSON.stringify(standards, null, 2));\n}\n\nmain();\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import { fileURLToPath } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport type {\n MasterJson,\n StackChecklistJson,\n StackId,\n CiSystem,\n} from \"./types.js\";\nimport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION } from \"./version.js\";\n\n// Re-export types for consumers\nexport type { MasterJson, StackChecklistJson, StackId, CiSystem };\n\n// Re-export version info (stable API contract)\nexport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION };\n\n// ESM equivalent of __dirname\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Path to config directory:\n// - When running from src/ (dev/test): use repo root config/\n// - When running from dist/ (installed): use dist/config/\nconst isDevMode = __dirname.includes(\"src\");\nconst configDir = isDevMode\n ? join(__dirname, \"..\", \"config\")\n : join(__dirname, \"config\");\n\n/** Load the master spec JSON from the packaged dist directory */\nexport function loadMasterSpec(): MasterJson {\n const filePath = join(configDir, \"standards.json\");\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** Load a stack-specific checklist (optionally filtered by CI system) */\nexport function loadBaseline(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n const suffix = ci ? `.${ci}` : \"\";\n const file = `standards.${stack}${suffix}.json`;\n const filePath = join(configDir, file);\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** List all supported stacks (derived from the master spec) */\nexport function listSupportedStacks(): readonly StackId[] {\n const spec = loadMasterSpec();\n return Object.keys(spec.stacks) as StackId[];\n}\n\n/** List all supported CI systems (derived from the master spec) */\nexport function listSupportedCiSystems(): readonly CiSystem[] {\n const spec = loadMasterSpec();\n return spec.ciSystems as CiSystem[];\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadBaseline - loads stack-specific standards checklist.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getStandards(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n return loadBaseline(stack, ci);\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadMasterSpec - loads the master standards schema.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getSchema(): MasterJson {\n return loadMasterSpec();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADF9D,yBAA8B;;;AEV9B,sBAA8B;AAC9B,qBAA6B;AAC7B,uBAA8B;AAgB9B,IAAMA,kBAAa,+BAAc,aAAe;AAChD,IAAM,gBAAY,0BAAQA,WAAU;AAKpC,IAAM,YAAY,UAAU,SAAS,KAAK;AAC1C,IAAM,YAAY,gBACd,uBAAK,WAAW,MAAM,QAAQ,QAC9B,uBAAK,WAAW,QAAQ;AAGrB,SAAS,iBAA6B;AAC3C,QAAM,eAAW,uBAAK,WAAW,gBAAgB;AACjD,SAAO,KAAK,UAAM,6BAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,aACd,OACA,IACoB;AACpB,QAAM,SAAS,KAAK,IAAI,EAAE,KAAK;AAC/B,QAAM,OAAO,aAAa,KAAK,GAAG,MAAM;AACxC,QAAM,eAAW,uBAAK,WAAW,IAAI;AACrC,SAAO,KAAK,UAAM,6BAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,sBAA0C;AACxD,QAAM,OAAO,eAAe;AAC5B,SAAO,OAAO,KAAK,KAAK,MAAM;AAChC;AAGO,SAAS,yBAA8C;AAC5D,QAAM,OAAO,eAAe;AAC5B,SAAO,KAAK;AACd;;;AFrCA,IAAMC,eAAU,kCAAc,aAAe;AAC7C,IAAM,MAAMA,SAAQ,iBAAiB;AAG9B,IAAM,UAAkB,IAAI;AAEnC,SAAS,YAAkB;AACzB,UAAQ,IAAI,mBAAmB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOpB,oBAAoB,EAAE,KAAK,IAAI,CAAC;AAAA,wBAC5B,uBAAuB,EAAE,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,CAK1D;AACD;AAEA,SAAS,OAAa;AACpB,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAGjC,MAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,IAAI,GAAG;AACrD,YAAQ,IAAI,OAAO;AACnB,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,MAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,GAAG;AACvE,cAAU;AACV,YAAQ,KAAK,KAAK,WAAW,IAAI,IAAI,CAAC;AAAA,EACxC;AAEA,QAAM,CAAC,UAAU,KAAK,IAAI;AAC1B,QAAM,cAAc,oBAAoB;AACxC,QAAM,iBAAiB,uBAAuB;AAG9C,MAAI,CAAC,YAAY,SAAS,QAAmB,GAAG;AAC9C,YAAQ,MAAM,yBAAyB,QAAQ,GAAG;AAClD,YAAQ,MAAM,iBAAiB,YAAY,KAAK,IAAI,CAAC,EAAE;AACvD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,MAAI,SAAS,CAAC,eAAe,SAAS,KAAiB,GAAG;AACxD,YAAQ,MAAM,6BAA6B,KAAK,GAAG;AACnD,YAAQ,MAAM,qBAAqB,eAAe,KAAK,IAAI,CAAC,EAAE;AAC9D,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,EACF;AACA,UAAQ,IAAI,KAAK,UAAU,WAAW,MAAM,CAAC,CAAC;AAChD;AAEA,KAAK;","names":["__filename","require"]}
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* repo-standards CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* repo-standards --version
|
|
7
|
+
* repo-standards --help
|
|
8
|
+
* repo-standards <stack> [ci-system]
|
|
9
|
+
*/
|
|
10
|
+
/** Package version - dynamically read from package.json for determinism */
|
|
11
|
+
declare const VERSION: string;
|
|
12
|
+
|
|
13
|
+
export { VERSION };
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* repo-standards CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* repo-standards --version
|
|
7
|
+
* repo-standards --help
|
|
8
|
+
* repo-standards <stack> [ci-system]
|
|
9
|
+
*/
|
|
10
|
+
/** Package version - dynamically read from package.json for determinism */
|
|
11
|
+
declare const VERSION: string;
|
|
12
|
+
|
|
13
|
+
export { VERSION };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { readFileSync } from "fs";
|
|
9
|
+
import { join, dirname } from "path";
|
|
10
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
11
|
+
var __dirname2 = dirname(__filename2);
|
|
12
|
+
var isDevMode = __dirname2.includes("src");
|
|
13
|
+
var configDir = isDevMode ? join(__dirname2, "..", "config") : join(__dirname2, "config");
|
|
14
|
+
function loadMasterSpec() {
|
|
15
|
+
const filePath = join(configDir, "standards.json");
|
|
16
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
17
|
+
}
|
|
18
|
+
function loadBaseline(stack, ci) {
|
|
19
|
+
const suffix = ci ? `.${ci}` : "";
|
|
20
|
+
const file = `standards.${stack}${suffix}.json`;
|
|
21
|
+
const filePath = join(configDir, file);
|
|
22
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
23
|
+
}
|
|
24
|
+
function listSupportedStacks() {
|
|
25
|
+
const spec = loadMasterSpec();
|
|
26
|
+
return Object.keys(spec.stacks);
|
|
27
|
+
}
|
|
28
|
+
function listSupportedCiSystems() {
|
|
29
|
+
const spec = loadMasterSpec();
|
|
30
|
+
return spec.ciSystems;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/cli.ts
|
|
34
|
+
var require2 = createRequire(import.meta.url);
|
|
35
|
+
var pkg = require2("../package.json");
|
|
36
|
+
var VERSION = pkg.version;
|
|
37
|
+
function printHelp() {
|
|
38
|
+
console.log(`repo-standards v${VERSION}
|
|
39
|
+
|
|
40
|
+
Usage:
|
|
41
|
+
repo-standards --version Print version and exit
|
|
42
|
+
repo-standards --help Print this help message
|
|
43
|
+
repo-standards <stack> [ci] Get standards for a stack (optional CI system)
|
|
44
|
+
|
|
45
|
+
Supported stacks: ${listSupportedStacks().join(", ")}
|
|
46
|
+
Supported CI systems: ${listSupportedCiSystems().join(", ")}
|
|
47
|
+
|
|
48
|
+
Examples:
|
|
49
|
+
repo-standards typescript-js
|
|
50
|
+
repo-standards python github-actions
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
function main() {
|
|
54
|
+
const args = process.argv.slice(2);
|
|
55
|
+
if (args.includes("--version") || args.includes("-V")) {
|
|
56
|
+
console.log(VERSION);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
if (args.includes("--help") || args.includes("-h") || args.length === 0) {
|
|
60
|
+
printHelp();
|
|
61
|
+
process.exit(args.length === 0 ? 1 : 0);
|
|
62
|
+
}
|
|
63
|
+
const [stackArg, ciArg] = args;
|
|
64
|
+
const validStacks = listSupportedStacks();
|
|
65
|
+
const validCiSystems = listSupportedCiSystems();
|
|
66
|
+
if (!validStacks.includes(stackArg)) {
|
|
67
|
+
console.error(`Error: Unknown stack "${stackArg}"`);
|
|
68
|
+
console.error(`Valid stacks: ${validStacks.join(", ")}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
if (ciArg && !validCiSystems.includes(ciArg)) {
|
|
72
|
+
console.error(`Error: Unknown CI system "${ciArg}"`);
|
|
73
|
+
console.error(`Valid CI systems: ${validCiSystems.join(", ")}`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
const standards = loadBaseline(
|
|
77
|
+
stackArg,
|
|
78
|
+
ciArg
|
|
79
|
+
);
|
|
80
|
+
console.log(JSON.stringify(standards, null, 2));
|
|
81
|
+
}
|
|
82
|
+
main();
|
|
83
|
+
export {
|
|
84
|
+
VERSION
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * repo-standards CLI\n *\n * Usage:\n * repo-standards --version\n * repo-standards --help\n * repo-standards <stack> [ci-system]\n */\n\nimport { createRequire } from \"node:module\";\nimport {\n loadBaseline,\n listSupportedStacks,\n listSupportedCiSystems,\n} from \"./index.js\";\nimport type { StackId, CiSystem } from \"./types.js\";\n\n// Dynamic version reading from package.json for determinism invariant compliance\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\") as { version: string };\n\n/** Package version - dynamically read from package.json for determinism */\nexport const VERSION: string = pkg.version;\n\nfunction printHelp(): void {\n console.log(`repo-standards v${VERSION}\n\nUsage:\n repo-standards --version Print version and exit\n repo-standards --help Print this help message\n repo-standards <stack> [ci] Get standards for a stack (optional CI system)\n\nSupported stacks: ${listSupportedStacks().join(\", \")}\nSupported CI systems: ${listSupportedCiSystems().join(\", \")}\n\nExamples:\n repo-standards typescript-js\n repo-standards python github-actions\n`);\n}\n\nfunction main(): void {\n const args = process.argv.slice(2);\n\n // Handle --version\n if (args.includes(\"--version\") || args.includes(\"-V\")) {\n console.log(VERSION);\n process.exit(0);\n }\n\n // Handle --help or no args\n if (args.includes(\"--help\") || args.includes(\"-h\") || args.length === 0) {\n printHelp();\n process.exit(args.length === 0 ? 1 : 0);\n }\n\n const [stackArg, ciArg] = args;\n const validStacks = listSupportedStacks();\n const validCiSystems = listSupportedCiSystems();\n\n // Validate stack\n if (!validStacks.includes(stackArg as StackId)) {\n console.error(`Error: Unknown stack \"${stackArg}\"`);\n console.error(`Valid stacks: ${validStacks.join(\", \")}`);\n process.exit(1);\n }\n\n // Validate CI system if provided\n if (ciArg && !validCiSystems.includes(ciArg as CiSystem)) {\n console.error(`Error: Unknown CI system \"${ciArg}\"`);\n console.error(`Valid CI systems: ${validCiSystems.join(\", \")}`);\n process.exit(1);\n }\n\n // Load and output standards\n const standards = loadBaseline(\n stackArg as StackId,\n ciArg as CiSystem | undefined,\n );\n console.log(JSON.stringify(standards, null, 2));\n}\n\nmain();\n","import { fileURLToPath } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport type {\n MasterJson,\n StackChecklistJson,\n StackId,\n CiSystem,\n} from \"./types.js\";\nimport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION } from \"./version.js\";\n\n// Re-export types for consumers\nexport type { MasterJson, StackChecklistJson, StackId, CiSystem };\n\n// Re-export version info (stable API contract)\nexport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION };\n\n// ESM equivalent of __dirname\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Path to config directory:\n// - When running from src/ (dev/test): use repo root config/\n// - When running from dist/ (installed): use dist/config/\nconst isDevMode = __dirname.includes(\"src\");\nconst configDir = isDevMode\n ? join(__dirname, \"..\", \"config\")\n : join(__dirname, \"config\");\n\n/** Load the master spec JSON from the packaged dist directory */\nexport function loadMasterSpec(): MasterJson {\n const filePath = join(configDir, \"standards.json\");\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** Load a stack-specific checklist (optionally filtered by CI system) */\nexport function loadBaseline(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n const suffix = ci ? `.${ci}` : \"\";\n const file = `standards.${stack}${suffix}.json`;\n const filePath = join(configDir, file);\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** List all supported stacks (derived from the master spec) */\nexport function listSupportedStacks(): readonly StackId[] {\n const spec = loadMasterSpec();\n return Object.keys(spec.stacks) as StackId[];\n}\n\n/** List all supported CI systems (derived from the master spec) */\nexport function listSupportedCiSystems(): readonly CiSystem[] {\n const spec = loadMasterSpec();\n return spec.ciSystems as CiSystem[];\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadBaseline - loads stack-specific standards checklist.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getStandards(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n return loadBaseline(stack, ci);\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadMasterSpec - loads the master standards schema.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getSchema(): MasterJson {\n return loadMasterSpec();\n}\n"],"mappings":";;;AAUA,SAAS,qBAAqB;;;ACV9B,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,MAAM,eAAe;AAgB9B,IAAMA,cAAa,cAAc,YAAY,GAAG;AAChD,IAAMC,aAAY,QAAQD,WAAU;AAKpC,IAAM,YAAYC,WAAU,SAAS,KAAK;AAC1C,IAAM,YAAY,YACd,KAAKA,YAAW,MAAM,QAAQ,IAC9B,KAAKA,YAAW,QAAQ;AAGrB,SAAS,iBAA6B;AAC3C,QAAM,WAAW,KAAK,WAAW,gBAAgB;AACjD,SAAO,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,aACd,OACA,IACoB;AACpB,QAAM,SAAS,KAAK,IAAI,EAAE,KAAK;AAC/B,QAAM,OAAO,aAAa,KAAK,GAAG,MAAM;AACxC,QAAM,WAAW,KAAK,WAAW,IAAI;AACrC,SAAO,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,sBAA0C;AACxD,QAAM,OAAO,eAAe;AAC5B,SAAO,OAAO,KAAK,KAAK,MAAM;AAChC;AAGO,SAAS,yBAA8C;AAC5D,QAAM,OAAO,eAAe;AAC5B,SAAO,KAAK;AACd;;;ADrCA,IAAMC,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,MAAMA,SAAQ,iBAAiB;AAG9B,IAAM,UAAkB,IAAI;AAEnC,SAAS,YAAkB;AACzB,UAAQ,IAAI,mBAAmB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOpB,oBAAoB,EAAE,KAAK,IAAI,CAAC;AAAA,wBAC5B,uBAAuB,EAAE,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,CAK1D;AACD;AAEA,SAAS,OAAa;AACpB,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAGjC,MAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,IAAI,GAAG;AACrD,YAAQ,IAAI,OAAO;AACnB,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,MAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,GAAG;AACvE,cAAU;AACV,YAAQ,KAAK,KAAK,WAAW,IAAI,IAAI,CAAC;AAAA,EACxC;AAEA,QAAM,CAAC,UAAU,KAAK,IAAI;AAC1B,QAAM,cAAc,oBAAoB;AACxC,QAAM,iBAAiB,uBAAuB;AAG9C,MAAI,CAAC,YAAY,SAAS,QAAmB,GAAG;AAC9C,YAAQ,MAAM,yBAAyB,QAAQ,GAAG;AAClD,YAAQ,MAAM,iBAAiB,YAAY,KAAK,IAAI,CAAC,EAAE;AACvD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,MAAI,SAAS,CAAC,eAAe,SAAS,KAAiB,GAAG;AACxD,YAAQ,MAAM,6BAA6B,KAAK,GAAG;AACnD,YAAQ,MAAM,qBAAqB,eAAe,KAAK,IAAI,CAAC,EAAE;AAC9D,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,EACF;AACA,UAAQ,IAAI,KAAK,UAAU,WAAW,MAAM,CAAC,CAAC;AAChD;AAEA,KAAK;","names":["__filename","__dirname","require"]}
|
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ var import_node_fs = require("fs");
|
|
|
41
41
|
var import_node_path = require("path");
|
|
42
42
|
|
|
43
43
|
// src/version.ts
|
|
44
|
-
var STANDARDS_VERSION = "4.0
|
|
44
|
+
var STANDARDS_VERSION = "4.2.0";
|
|
45
45
|
var STANDARDS_SCHEMA_VERSION = 4;
|
|
46
46
|
|
|
47
47
|
// src/index.ts
|
|
@@ -73,12 +73,6 @@ function getStandards(stack, ci) {
|
|
|
73
73
|
function getSchema() {
|
|
74
74
|
return loadMasterSpec();
|
|
75
75
|
}
|
|
76
|
-
if (importMetaUrl.startsWith("file:") && process.argv[1] === __filename2) {
|
|
77
|
-
console.log({
|
|
78
|
-
stacks: listSupportedStacks(),
|
|
79
|
-
ciSystems: listSupportedCiSystems()
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
76
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
77
|
0 && (module.exports = {
|
|
84
78
|
STANDARDS_SCHEMA_VERSION,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../node_modules/tsup/assets/cjs_shims.js","../src/version.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport type {\n MasterJson,\n StackChecklistJson,\n StackId,\n CiSystem,\n} from \"./types.js\";\nimport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION } from \"./version.js\";\n\n// Re-export types for consumers\nexport type { MasterJson, StackChecklistJson, StackId, CiSystem };\n\n// Re-export version info (stable API contract)\nexport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION };\n\n// ESM equivalent of __dirname\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Path to config directory:\n// - When running from src/ (dev/test): use repo root config/\n// - When running from dist/ (installed): use dist/config/\nconst isDevMode = __dirname.includes(\"src\");\nconst configDir = isDevMode\n ? join(__dirname, \"..\", \"config\")\n : join(__dirname, \"config\");\n\n/** Load the master spec JSON from the packaged dist directory */\nexport function loadMasterSpec(): MasterJson {\n const filePath = join(configDir, \"standards.json\");\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** Load a stack-specific checklist (optionally filtered by CI system) */\nexport function loadBaseline(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n const suffix = ci ? `.${ci}` : \"\";\n const file = `standards.${stack}${suffix}.json`;\n const filePath = join(configDir, file);\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** List all supported stacks (derived from the master spec) */\nexport function listSupportedStacks(): readonly StackId[] {\n const spec = loadMasterSpec();\n return Object.keys(spec.stacks) as StackId[];\n}\n\n/** List all supported CI systems (derived from the master spec) */\nexport function listSupportedCiSystems(): readonly CiSystem[] {\n const spec = loadMasterSpec();\n return spec.ciSystems as CiSystem[];\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadBaseline - loads stack-specific standards checklist.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getStandards(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n return loadBaseline(stack, ci);\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadMasterSpec - loads the master standards schema.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getSchema(): MasterJson {\n return loadMasterSpec();\n}\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../node_modules/tsup/assets/cjs_shims.js","../src/version.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport type {\n MasterJson,\n StackChecklistJson,\n StackId,\n CiSystem,\n} from \"./types.js\";\nimport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION } from \"./version.js\";\n\n// Re-export types for consumers\nexport type { MasterJson, StackChecklistJson, StackId, CiSystem };\n\n// Re-export version info (stable API contract)\nexport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION };\n\n// ESM equivalent of __dirname\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Path to config directory:\n// - When running from src/ (dev/test): use repo root config/\n// - When running from dist/ (installed): use dist/config/\nconst isDevMode = __dirname.includes(\"src\");\nconst configDir = isDevMode\n ? join(__dirname, \"..\", \"config\")\n : join(__dirname, \"config\");\n\n/** Load the master spec JSON from the packaged dist directory */\nexport function loadMasterSpec(): MasterJson {\n const filePath = join(configDir, \"standards.json\");\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** Load a stack-specific checklist (optionally filtered by CI system) */\nexport function loadBaseline(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n const suffix = ci ? `.${ci}` : \"\";\n const file = `standards.${stack}${suffix}.json`;\n const filePath = join(configDir, file);\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** List all supported stacks (derived from the master spec) */\nexport function listSupportedStacks(): readonly StackId[] {\n const spec = loadMasterSpec();\n return Object.keys(spec.stacks) as StackId[];\n}\n\n/** List all supported CI systems (derived from the master spec) */\nexport function listSupportedCiSystems(): readonly CiSystem[] {\n const spec = loadMasterSpec();\n return spec.ciSystems as CiSystem[];\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadBaseline - loads stack-specific standards checklist.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getStandards(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n return loadBaseline(stack, ci);\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadMasterSpec - loads the master standards schema.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getSchema(): MasterJson {\n return loadMasterSpec();\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","/**\n * AUTO-GENERATED at build time by scripts/build.ts\n * DO NOT EDIT MANUALLY\n *\n * This module provides version information for the repo-standards package.\n * Consumers should import from here instead of package.json to avoid\n * ESM/CJS interop issues.\n */\n\nexport const STANDARDS_VERSION = '4.2.0';\nexport const STANDARDS_SCHEMA_VERSION = 4;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADZ9D,sBAA8B;AAC9B,qBAA6B;AAC7B,uBAA8B;;;AEOvB,IAAM,oBAAoB;AAC1B,IAAM,2BAA2B;;;AFQxC,IAAMA,kBAAa,+BAAc,aAAe;AAChD,IAAM,gBAAY,0BAAQA,WAAU;AAKpC,IAAM,YAAY,UAAU,SAAS,KAAK;AAC1C,IAAM,YAAY,gBACd,uBAAK,WAAW,MAAM,QAAQ,QAC9B,uBAAK,WAAW,QAAQ;AAGrB,SAAS,iBAA6B;AAC3C,QAAM,eAAW,uBAAK,WAAW,gBAAgB;AACjD,SAAO,KAAK,UAAM,6BAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,aACd,OACA,IACoB;AACpB,QAAM,SAAS,KAAK,IAAI,EAAE,KAAK;AAC/B,QAAM,OAAO,aAAa,KAAK,GAAG,MAAM;AACxC,QAAM,eAAW,uBAAK,WAAW,IAAI;AACrC,SAAO,KAAK,UAAM,6BAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,sBAA0C;AACxD,QAAM,OAAO,eAAe;AAC5B,SAAO,OAAO,KAAK,KAAK,MAAM;AAChC;AAGO,SAAS,yBAA8C;AAC5D,QAAM,OAAO,eAAe;AAC5B,SAAO,KAAK;AACd;AAOO,SAAS,aACd,OACA,IACoB;AACpB,SAAO,aAAa,OAAO,EAAE;AAC/B;AAOO,SAAS,YAAwB;AACtC,SAAO,eAAe;AACxB;","names":["__filename"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -156,7 +156,7 @@ interface StackChecklistJson {
|
|
|
156
156
|
* Consumers should import from here instead of package.json to avoid
|
|
157
157
|
* ESM/CJS interop issues.
|
|
158
158
|
*/
|
|
159
|
-
declare const STANDARDS_VERSION = "4.0
|
|
159
|
+
declare const STANDARDS_VERSION = "4.2.0";
|
|
160
160
|
declare const STANDARDS_SCHEMA_VERSION = 4;
|
|
161
161
|
|
|
162
162
|
/** Load the master spec JSON from the packaged dist directory */
|
package/dist/index.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ interface StackChecklistJson {
|
|
|
156
156
|
* Consumers should import from here instead of package.json to avoid
|
|
157
157
|
* ESM/CJS interop issues.
|
|
158
158
|
*/
|
|
159
|
-
declare const STANDARDS_VERSION = "4.0
|
|
159
|
+
declare const STANDARDS_VERSION = "4.2.0";
|
|
160
160
|
declare const STANDARDS_SCHEMA_VERSION = 4;
|
|
161
161
|
|
|
162
162
|
/** Load the master spec JSON from the packaged dist directory */
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { readFileSync } from "fs";
|
|
|
4
4
|
import { join, dirname } from "path";
|
|
5
5
|
|
|
6
6
|
// src/version.ts
|
|
7
|
-
var STANDARDS_VERSION = "4.0
|
|
7
|
+
var STANDARDS_VERSION = "4.2.0";
|
|
8
8
|
var STANDARDS_SCHEMA_VERSION = 4;
|
|
9
9
|
|
|
10
10
|
// src/index.ts
|
|
@@ -36,12 +36,6 @@ function getStandards(stack, ci) {
|
|
|
36
36
|
function getSchema() {
|
|
37
37
|
return loadMasterSpec();
|
|
38
38
|
}
|
|
39
|
-
if (import.meta.url.startsWith("file:") && process.argv[1] === __filename2) {
|
|
40
|
-
console.log({
|
|
41
|
-
stacks: listSupportedStacks(),
|
|
42
|
-
ciSystems: listSupportedCiSystems()
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
39
|
export {
|
|
46
40
|
STANDARDS_SCHEMA_VERSION,
|
|
47
41
|
STANDARDS_VERSION,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/version.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport type {\n MasterJson,\n StackChecklistJson,\n StackId,\n CiSystem,\n} from \"./types.js\";\nimport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION } from \"./version.js\";\n\n// Re-export types for consumers\nexport type { MasterJson, StackChecklistJson, StackId, CiSystem };\n\n// Re-export version info (stable API contract)\nexport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION };\n\n// ESM equivalent of __dirname\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Path to config directory:\n// - When running from src/ (dev/test): use repo root config/\n// - When running from dist/ (installed): use dist/config/\nconst isDevMode = __dirname.includes(\"src\");\nconst configDir = isDevMode\n ? join(__dirname, \"..\", \"config\")\n : join(__dirname, \"config\");\n\n/** Load the master spec JSON from the packaged dist directory */\nexport function loadMasterSpec(): MasterJson {\n const filePath = join(configDir, \"standards.json\");\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** Load a stack-specific checklist (optionally filtered by CI system) */\nexport function loadBaseline(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n const suffix = ci ? `.${ci}` : \"\";\n const file = `standards.${stack}${suffix}.json`;\n const filePath = join(configDir, file);\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** List all supported stacks (derived from the master spec) */\nexport function listSupportedStacks(): readonly StackId[] {\n const spec = loadMasterSpec();\n return Object.keys(spec.stacks) as StackId[];\n}\n\n/** List all supported CI systems (derived from the master spec) */\nexport function listSupportedCiSystems(): readonly CiSystem[] {\n const spec = loadMasterSpec();\n return spec.ciSystems as CiSystem[];\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadBaseline - loads stack-specific standards checklist.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getStandards(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n return loadBaseline(stack, ci);\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadMasterSpec - loads the master standards schema.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getSchema(): MasterJson {\n return loadMasterSpec();\n}\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/version.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { readFileSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport type {\n MasterJson,\n StackChecklistJson,\n StackId,\n CiSystem,\n} from \"./types.js\";\nimport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION } from \"./version.js\";\n\n// Re-export types for consumers\nexport type { MasterJson, StackChecklistJson, StackId, CiSystem };\n\n// Re-export version info (stable API contract)\nexport { STANDARDS_VERSION, STANDARDS_SCHEMA_VERSION };\n\n// ESM equivalent of __dirname\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Path to config directory:\n// - When running from src/ (dev/test): use repo root config/\n// - When running from dist/ (installed): use dist/config/\nconst isDevMode = __dirname.includes(\"src\");\nconst configDir = isDevMode\n ? join(__dirname, \"..\", \"config\")\n : join(__dirname, \"config\");\n\n/** Load the master spec JSON from the packaged dist directory */\nexport function loadMasterSpec(): MasterJson {\n const filePath = join(configDir, \"standards.json\");\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** Load a stack-specific checklist (optionally filtered by CI system) */\nexport function loadBaseline(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n const suffix = ci ? `.${ci}` : \"\";\n const file = `standards.${stack}${suffix}.json`;\n const filePath = join(configDir, file);\n return JSON.parse(readFileSync(filePath, \"utf8\"));\n}\n\n/** List all supported stacks (derived from the master spec) */\nexport function listSupportedStacks(): readonly StackId[] {\n const spec = loadMasterSpec();\n return Object.keys(spec.stacks) as StackId[];\n}\n\n/** List all supported CI systems (derived from the master spec) */\nexport function listSupportedCiSystems(): readonly CiSystem[] {\n const spec = loadMasterSpec();\n return spec.ciSystems as CiSystem[];\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadBaseline - loads stack-specific standards checklist.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getStandards(\n stack: StackId,\n ci?: CiSystem,\n): StackChecklistJson {\n return loadBaseline(stack, ci);\n}\n\n/**\n * PUBLIC API CONTRACT (semver-governed)\n * Alias for loadMasterSpec - loads the master standards schema.\n * Breaking changes to this function signature require a major version bump.\n */\nexport function getSchema(): MasterJson {\n return loadMasterSpec();\n}\n","/**\n * AUTO-GENERATED at build time by scripts/build.ts\n * DO NOT EDIT MANUALLY\n *\n * This module provides version information for the repo-standards package.\n * Consumers should import from here instead of package.json to avoid\n * ESM/CJS interop issues.\n */\n\nexport const STANDARDS_VERSION = '4.2.0';\nexport const STANDARDS_SCHEMA_VERSION = 4;\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,MAAM,eAAe;;;ACOvB,IAAM,oBAAoB;AAC1B,IAAM,2BAA2B;;;ADQxC,IAAMA,cAAa,cAAc,YAAY,GAAG;AAChD,IAAMC,aAAY,QAAQD,WAAU;AAKpC,IAAM,YAAYC,WAAU,SAAS,KAAK;AAC1C,IAAM,YAAY,YACd,KAAKA,YAAW,MAAM,QAAQ,IAC9B,KAAKA,YAAW,QAAQ;AAGrB,SAAS,iBAA6B;AAC3C,QAAM,WAAW,KAAK,WAAW,gBAAgB;AACjD,SAAO,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,aACd,OACA,IACoB;AACpB,QAAM,SAAS,KAAK,IAAI,EAAE,KAAK;AAC/B,QAAM,OAAO,aAAa,KAAK,GAAG,MAAM;AACxC,QAAM,WAAW,KAAK,WAAW,IAAI;AACrC,SAAO,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;AAClD;AAGO,SAAS,sBAA0C;AACxD,QAAM,OAAO,eAAe;AAC5B,SAAO,OAAO,KAAK,KAAK,MAAM;AAChC;AAGO,SAAS,yBAA8C;AAC5D,QAAM,OAAO,eAAe;AAC5B,SAAO,KAAK;AACd;AAOO,SAAS,aACd,OACA,IACoB;AACpB,SAAO,aAAa,OAAO,EAAE;AAC/B;AAOO,SAAS,YAAwB;AACtC,SAAO,eAAe;AACxB;","names":["__filename","__dirname"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oddessentials/repo-standards",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0",
|
|
5
5
|
"description": "Standards and CI filtering utilities for multi-stack repository governance.",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"repo-standards": "./dist/cli.js"
|
|
9
|
+
},
|
|
7
10
|
"scripts": {
|
|
8
11
|
"dev": "ts-node-dev --respawn --transpile-only src/index.ts",
|
|
9
12
|
"build": "npm run validate:schema && tsx scripts/build.ts && tsup",
|
|
@@ -14,6 +17,7 @@
|
|
|
14
17
|
"test": "vitest run",
|
|
15
18
|
"typecheck": "tsc --noEmit",
|
|
16
19
|
"prepare": "husky",
|
|
20
|
+
"postinstall": "git config core.hooksPath .husky || true",
|
|
17
21
|
"ci": "npm run lint && npm run format:check && npm run typecheck && npm run test && npm run build",
|
|
18
22
|
"generate:standards": "tsx scripts/generate-standards.ts",
|
|
19
23
|
"validate:schema": "tsx scripts/validate-schema.ts",
|
|
@@ -50,10 +54,10 @@
|
|
|
50
54
|
"node": ">=22 <23"
|
|
51
55
|
},
|
|
52
56
|
"lint-staged": {
|
|
53
|
-
"*.{js,ts,mjs,json,md}": [
|
|
57
|
+
"*.{js,cjs,ts,mjs,json,md}": [
|
|
54
58
|
"prettier --write"
|
|
55
59
|
],
|
|
56
|
-
"*.{js,ts,mjs}": [
|
|
60
|
+
"*.{js,cjs,ts,mjs}": [
|
|
57
61
|
"eslint --fix"
|
|
58
62
|
]
|
|
59
63
|
},
|
|
@@ -89,6 +93,7 @@
|
|
|
89
93
|
"files": [
|
|
90
94
|
"dist/",
|
|
91
95
|
"README.md",
|
|
92
|
-
"LICENSE"
|
|
96
|
+
"LICENSE",
|
|
97
|
+
"scripts/"
|
|
93
98
|
]
|
|
94
99
|
}
|
package/scripts/build.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
// scripts/build.ts
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Build script for @oddessentials/repo-standards
|
|
6
|
+
* - Copies master config/standards.json to dist/config/
|
|
7
|
+
* - Generates stack-specific JSON artifacts into dist/config/
|
|
8
|
+
* - Ensures deterministic output (sorted keys, no timestamps)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { execSync } from "node:child_process";
|
|
12
|
+
import {
|
|
13
|
+
writeFileSync,
|
|
14
|
+
readFileSync,
|
|
15
|
+
mkdirSync,
|
|
16
|
+
copyFileSync,
|
|
17
|
+
readdirSync,
|
|
18
|
+
} from "node:fs";
|
|
19
|
+
import { resolve, join } from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
|
|
24
|
+
// Helper to sort object keys recursively for deterministic output
|
|
25
|
+
function sortObject(obj: unknown): unknown {
|
|
26
|
+
if (Array.isArray(obj)) return obj.map(sortObject);
|
|
27
|
+
if (obj && typeof obj === "object") {
|
|
28
|
+
const sorted: Record<string, unknown> = {};
|
|
29
|
+
Object.keys(obj as Record<string, unknown>)
|
|
30
|
+
.sort()
|
|
31
|
+
.forEach((key) => {
|
|
32
|
+
sorted[key] = sortObject((obj as Record<string, unknown>)[key]);
|
|
33
|
+
});
|
|
34
|
+
return sorted;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Ensure schema version matches package.json major version.
|
|
40
|
+
* - Auto-upgrades schema when package.json major is higher (for semantic-release)
|
|
41
|
+
* - Fails if schema is ahead of package (prevents manual drift)
|
|
42
|
+
*/
|
|
43
|
+
function syncSchemaVersion(rootDir: string): void {
|
|
44
|
+
const pkgPath = join(rootDir, "package.json");
|
|
45
|
+
const standardsPath = join(rootDir, "config", "standards.json");
|
|
46
|
+
|
|
47
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
48
|
+
const standards = JSON.parse(readFileSync(standardsPath, "utf8"));
|
|
49
|
+
|
|
50
|
+
// Extract major version from package.json (e.g., "2.1.0" -> 2)
|
|
51
|
+
const pkgMajor = parseInt(pkg.version.split(".")[0], 10);
|
|
52
|
+
|
|
53
|
+
if (pkgMajor > standards.version) {
|
|
54
|
+
// Auto-upgrade schema version when semantic-release bumps package.json
|
|
55
|
+
console.log(
|
|
56
|
+
`Upgrading schema version: ${standards.version} -> ${pkgMajor} (from package.json)`,
|
|
57
|
+
);
|
|
58
|
+
standards.version = pkgMajor;
|
|
59
|
+
writeFileSync(standardsPath, JSON.stringify(standards, null, 2) + "\n");
|
|
60
|
+
} else if (standards.version > pkgMajor) {
|
|
61
|
+
// Schema ahead of package = manual drift, fail build
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Schema version drift: standards.json version=${standards.version} ` +
|
|
64
|
+
`is ahead of package.json major=${pkgMajor}. ` +
|
|
65
|
+
`This should not happen - schema version is set by CI.`,
|
|
66
|
+
);
|
|
67
|
+
} else {
|
|
68
|
+
console.log(
|
|
69
|
+
`Schema version ${standards.version} matches package.json major`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Run the existing generator for each stack (and optional CI system)
|
|
75
|
+
function generateStack(stack: string, ci?: string) {
|
|
76
|
+
const args = ["scripts/generate-standards.ts", stack];
|
|
77
|
+
if (ci) args.push(ci);
|
|
78
|
+
const cmd = `npx tsx ${args.join(" ")}`;
|
|
79
|
+
console.log(`Generating ${stack}${ci ? " for " + ci : ""}`);
|
|
80
|
+
execSync(cmd, { stdio: "inherit" });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Generate src/version.ts with current package version
|
|
85
|
+
* This runs before TypeScript compilation so the values are baked in
|
|
86
|
+
*/
|
|
87
|
+
function generateVersionFile(rootDir: string): void {
|
|
88
|
+
const pkgPath = join(rootDir, "package.json");
|
|
89
|
+
const versionPath = join(rootDir, "src", "version.ts");
|
|
90
|
+
|
|
91
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
92
|
+
const standards = JSON.parse(
|
|
93
|
+
readFileSync(join(rootDir, "config", "standards.json"), "utf8"),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const content = `/**
|
|
97
|
+
* AUTO-GENERATED at build time by scripts/build.ts
|
|
98
|
+
* DO NOT EDIT MANUALLY
|
|
99
|
+
*
|
|
100
|
+
* This module provides version information for the repo-standards package.
|
|
101
|
+
* Consumers should import from here instead of package.json to avoid
|
|
102
|
+
* ESM/CJS interop issues.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
export const STANDARDS_VERSION = '${pkg.version}';
|
|
106
|
+
export const STANDARDS_SCHEMA_VERSION = ${standards.version};
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
writeFileSync(versionPath, content);
|
|
110
|
+
console.log(`Generated src/version.ts with version ${pkg.version}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function main() {
|
|
114
|
+
const rootDir = process.cwd();
|
|
115
|
+
const configSrc = resolve(rootDir, "config");
|
|
116
|
+
const configDest = resolve(rootDir, "dist", "config");
|
|
117
|
+
|
|
118
|
+
// Generate version.ts before TypeScript compilation
|
|
119
|
+
generateVersionFile(rootDir);
|
|
120
|
+
|
|
121
|
+
// Sync schema version with package.json major version (before generation)
|
|
122
|
+
syncSchemaVersion(rootDir);
|
|
123
|
+
|
|
124
|
+
// Ensure dist/config exists
|
|
125
|
+
mkdirSync(configDest, { recursive: true });
|
|
126
|
+
|
|
127
|
+
// Copy master standards.json first
|
|
128
|
+
copyFileSync(
|
|
129
|
+
join(configSrc, "standards.json"),
|
|
130
|
+
join(configDest, "standards.json"),
|
|
131
|
+
);
|
|
132
|
+
console.log("Copied master standards.json to dist/config/");
|
|
133
|
+
|
|
134
|
+
const stacks = ["typescript-js", "csharp-dotnet", "python", "rust", "go"];
|
|
135
|
+
const ciSystems = ["azure-devops", "github-actions"];
|
|
136
|
+
|
|
137
|
+
// Generate each stack without CI suffix
|
|
138
|
+
for (const stack of stacks) {
|
|
139
|
+
generateStack(stack);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Generate CI-specific views
|
|
143
|
+
for (const stack of stacks) {
|
|
144
|
+
for (const ci of ciSystems) {
|
|
145
|
+
generateStack(stack, ci);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Copy all generated files from config/ to dist/config/
|
|
150
|
+
const generatedFiles = readdirSync(configSrc).filter(
|
|
151
|
+
(f) => f.startsWith("standards.") && f.endsWith(".json"),
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
for (const file of generatedFiles) {
|
|
155
|
+
const srcPath = join(configSrc, file);
|
|
156
|
+
const destPath = join(configDest, file);
|
|
157
|
+
|
|
158
|
+
// Read, sort for determinism, and write
|
|
159
|
+
const data = JSON.parse(readFileSync(srcPath, "utf8"));
|
|
160
|
+
const sorted = sortObject(data);
|
|
161
|
+
writeFileSync(destPath, JSON.stringify(sorted, null, 2) + "\n");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
console.log(
|
|
165
|
+
`Build complete – ${generatedFiles.length} artifacts written to dist/config/`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ESM entrypoint check
|
|
170
|
+
if (process.argv[1] === __filename) {
|
|
171
|
+
main();
|
|
172
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// scripts/detect-bazel.test.ts
|
|
2
|
+
|
|
3
|
+
import { describe, it, expect } from "vitest";
|
|
4
|
+
import { detectBazel } from "./detect-bazel.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const fixtures = path.resolve(__dirname, "..", "test", "fixtures");
|
|
10
|
+
|
|
11
|
+
describe("detectBazel", () => {
|
|
12
|
+
it("detects bzlmod repo via MODULE.bazel", () => {
|
|
13
|
+
const result = detectBazel(path.join(fixtures, "bzlmod-repo"));
|
|
14
|
+
expect(result.detected).toBe(true);
|
|
15
|
+
expect(result.mode).toBe("bzlmod");
|
|
16
|
+
expect(result.markers).toContain("MODULE.bazel");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("detects .bazelversion as optional marker", () => {
|
|
20
|
+
const result = detectBazel(path.join(fixtures, "bzlmod-repo"));
|
|
21
|
+
expect(result.markers).toContain(".bazelversion");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("detects workspace repo via WORKSPACE.bazel", () => {
|
|
25
|
+
const result = detectBazel(path.join(fixtures, "workspace-repo"));
|
|
26
|
+
expect(result.detected).toBe(true);
|
|
27
|
+
expect(result.mode).toBe("workspace");
|
|
28
|
+
expect(result.markers).toContain("WORKSPACE.bazel");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("does NOT detect non-Bazel repo (regression)", () => {
|
|
32
|
+
const result = detectBazel(path.join(fixtures, "no-bazel-repo"));
|
|
33
|
+
expect(result.detected).toBe(false);
|
|
34
|
+
expect(result.mode).toBeUndefined();
|
|
35
|
+
expect(result.markers).toHaveLength(0);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("detects hybrid monorepo at root level only", () => {
|
|
39
|
+
const result = detectBazel(path.join(fixtures, "hybrid-monorepo"));
|
|
40
|
+
expect(result.detected).toBe(true);
|
|
41
|
+
expect(result.mode).toBe("bzlmod");
|
|
42
|
+
expect(result.markers).toContain("MODULE.bazel");
|
|
43
|
+
// Does NOT include nested BUILD files in markers
|
|
44
|
+
expect(result.markers).not.toContain("apps/web/BUILD.bazel");
|
|
45
|
+
expect(result.markers).not.toContain("libs/vendored/BUILD.bazel");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("prefers bzlmod over workspace when MODULE.bazel exists", () => {
|
|
49
|
+
// The bzlmod-repo fixture has MODULE.bazel, should be detected as bzlmod
|
|
50
|
+
const result = detectBazel(path.join(fixtures, "bzlmod-repo"));
|
|
51
|
+
expect(result.mode).toBe("bzlmod");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("does NOT detect Bazel when only nested BUILD files exist (no root markers)", () => {
|
|
55
|
+
// This validates the documented contract: detection uses repo-root markers only
|
|
56
|
+
const result = detectBazel(path.join(fixtures, "nested-build-only"));
|
|
57
|
+
expect(result.detected).toBe(false);
|
|
58
|
+
expect(result.mode).toBeUndefined();
|
|
59
|
+
expect(result.markers).toHaveLength(0);
|
|
60
|
+
});
|
|
61
|
+
});
|