lula2 0.0.4 → 0.0.5-nightly.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/crawl.d.ts CHANGED
@@ -29,7 +29,7 @@ export declare function fetchRawFileViaAPI({ octokit, owner, repo, path, ref, }:
29
29
  ref: string;
30
30
  }): Promise<string>;
31
31
  /**
32
- * Extracts all @mapStart and @mapEnd blocks from the given content.
32
+ * Extracts all @lulaStart and @lulaEnd blocks from the given content.
33
33
  *
34
34
  * @param content - The content to extract blocks from.
35
35
  *
@@ -1 +1 @@
1
- {"version":3,"file":"crawl.d.ts","sourceRoot":"","sources":["../src/crawl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC;;;;GAIG;AACH,wBAAgB,YAAY,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAsBnF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,OAAO,EACP,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,GAAG,GACJ,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CA0BlB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,EAAE,CA0BF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,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Ac,OAAO,CAuDlC"}
package/dist/crawl.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import fs from "fs";
4
4
  import { Octokit } from "@octokit/rest";
5
5
  import { Command } from "commander";
6
+ import { createHash } from "crypto";
6
7
  /**
7
8
  * Get the pull request context from the environment or GitHub event payload.
8
9
  *
@@ -63,7 +64,7 @@ export async function fetchRawFileViaAPI({ octokit, owner, repo, path, ref, }) {
63
64
  throw new Error("Unexpected GitHub API response shape");
64
65
  }
65
66
  /**
66
- * Extracts all @mapStart and @mapEnd blocks from the given content.
67
+ * Extracts all @lulaStart and @lulaEnd blocks from the given content.
67
68
  *
68
69
  * @param content - The content to extract blocks from.
69
70
  *
@@ -74,8 +75,8 @@ export function extractMapBlocks(content) {
74
75
  const blocks = [];
75
76
  const stack = [];
76
77
  lines.forEach((line, idx) => {
77
- const start = line.match(/@mapStart\s+([a-f0-9-]+)/);
78
- const end = line.match(/@mapEnd\s+([a-f0-9-]+)/);
78
+ const start = line.match(/@lulaStart\s+([a-f0-9-]+)/);
79
+ const end = line.match(/@lulaEnd\s+([a-f0-9-]+)/);
79
80
  if (start) {
80
81
  stack.push({ uuid: start[1], line: idx });
81
82
  }
@@ -121,7 +122,7 @@ export function getChangedBlocks(oldText, newText) {
121
122
  export default function () {
122
123
  return new Command()
123
124
  .command("crawl")
124
- .description("Detect compliance-related changes between @mapStart and @mapEnd in PR files")
125
+ .description("Detect compliance-related changes between @lulaStart and @lulaEnd in PR files")
125
126
  .action(async () => {
126
127
  const { owner, repo, pull_number } = getPRContext();
127
128
  const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
@@ -138,7 +139,15 @@ export default function () {
138
139
  ]);
139
140
  const changedBlocks = getChangedBlocks(oldText, newText);
140
141
  for (const block of changedBlocks) {
141
- const commentBody = `**Compliance Alert**: \`${file.filename}\` changed between lines ${block.startLine + 1}–${block.endLine}.\nUUID \`${block.uuid}\` may be out of compliance. Please review.`;
142
+ const newBlockText = newText
143
+ .split("\n")
144
+ .slice(block.startLine, block.endLine)
145
+ .join("\n");
146
+ const blockSha256 = createHash("sha256").update(newBlockText).digest("hex");
147
+ const commentBody = `**Compliance Alert**:\`${file.filename}\` changed between lines ${block.startLine + 1}–${block.endLine}.` +
148
+ `\nUUID \`${block.uuid}\` may be out of compliance.` +
149
+ `\nSHA-256 of block contents: \`${blockSha256}\`.` +
150
+ `\n\n Please review the changes to ensure they meet compliance standards.`;
142
151
  console.log(`Commenting on ${file.filename}: ${commentBody}`);
143
152
  await octokit.issues.createComment({
144
153
  owner,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lula2",
3
- "version": "0.0.4",
3
+ "version": "0.0.5-nightly.0",
4
4
  "description": "A tool for managing compliance as code in your GitHub repositories.",
5
5
  "bin": "./dist/index.js",
6
6
  "main": "dist/index.js",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/defenseunicorns/lula-next.git"
14
+ "url": "git+https://github.com/defenseunicorns/lula.git"
15
15
  },
16
16
  "keywords": [
17
17
  "compliance",
@@ -21,9 +21,9 @@
21
21
  "author": "Defense Unicorns",
22
22
  "license": "Apache-2.0",
23
23
  "bugs": {
24
- "url": "https://github.com/defenseunicorns/lula-next/issues"
24
+ "url": "https://github.com/defenseunicorns/lula/issues"
25
25
  },
26
- "homepage": "https://github.com/defenseunicorns/lula-next#readme",
26
+ "homepage": "https://github.com/defenseunicorns/lula#readme",
27
27
  "files": [
28
28
  "/src",
29
29
  "/dist",
@@ -56,7 +56,7 @@
56
56
  "esbuild": "^0.25.1",
57
57
  "eslint": "^9.26.0",
58
58
  "eslint-config-prettier": "^10.0.2",
59
- "eslint-plugin-jsdoc": "^54.1.1",
59
+ "eslint-plugin-jsdoc": "^55.0.0",
60
60
  "globals": "^16.0.0",
61
61
  "husky": "^9.1.7",
62
62
  "prettier": "3.6.2",
package/src/crawl.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  import fs from "fs";
5
5
  import { Octokit } from "@octokit/rest";
6
6
  import { Command } from "commander";
7
+ import { createHash } from "crypto";
7
8
 
8
9
  type FileContentResponse = {
9
10
  content: string;
@@ -91,7 +92,7 @@ export async function fetchRawFileViaAPI({
91
92
  }
92
93
 
93
94
  /**
94
- * Extracts all @mapStart and @mapEnd blocks from the given content.
95
+ * Extracts all @lulaStart and @lulaEnd blocks from the given content.
95
96
  *
96
97
  * @param content - The content to extract blocks from.
97
98
  *
@@ -112,8 +113,8 @@ export function extractMapBlocks(content: string): {
112
113
  const stack: { uuid: string; line: number }[] = [];
113
114
 
114
115
  lines.forEach((line, idx) => {
115
- const start = line.match(/@mapStart\s+([a-f0-9-]+)/);
116
- const end = line.match(/@mapEnd\s+([a-f0-9-]+)/);
116
+ const start = line.match(/@lulaStart\s+([a-f0-9-]+)/);
117
+ const end = line.match(/@lulaEnd\s+([a-f0-9-]+)/);
117
118
 
118
119
  if (start) {
119
120
  stack.push({ uuid: start[1], line: idx });
@@ -171,7 +172,7 @@ export function getChangedBlocks(
171
172
  export default function (): Command {
172
173
  return new Command()
173
174
  .command("crawl")
174
- .description("Detect compliance-related changes between @mapStart and @mapEnd in PR files")
175
+ .description("Detect compliance-related changes between @lulaStart and @lulaEnd in PR files")
175
176
  .action(async () => {
176
177
  const { owner, repo, pull_number } = getPRContext();
177
178
  const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
@@ -192,7 +193,17 @@ export default function (): Command {
192
193
  const changedBlocks = getChangedBlocks(oldText, newText);
193
194
 
194
195
  for (const block of changedBlocks) {
195
- const commentBody = `**Compliance Alert**: \`${file.filename}\` changed between lines ${block.startLine + 1}–${block.endLine}.\nUUID \`${block.uuid}\` may be out of compliance. Please review.`;
196
+ const newBlockText = newText
197
+ .split("\n")
198
+ .slice(block.startLine, block.endLine)
199
+ .join("\n");
200
+
201
+ const blockSha256 = createHash("sha256").update(newBlockText).digest("hex");
202
+ const commentBody =
203
+ `**Compliance Alert**:\`${file.filename}\` changed between lines ${block.startLine + 1}–${block.endLine}.` +
204
+ `\nUUID \`${block.uuid}\` may be out of compliance.` +
205
+ `\nSHA-256 of block contents: \`${blockSha256}\`.` +
206
+ `\n\n Please review the changes to ensure they meet compliance standards.`;
196
207
  console.log(`Commenting on ${file.filename}: ${commentBody}`);
197
208
  await octokit.issues.createComment({
198
209
  owner,