@gspothq/cli 0.1.1 → 0.1.2
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/README.md +7 -4
- package/dist/gspot.js +55 -65
- package/gspot.schema.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,14 +4,17 @@ gspot lints AI-generated code and writes rules for AI coding agents.
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
Commit your work, then run:
|
|
8
|
-
|
|
9
7
|
```sh
|
|
10
8
|
npm install --save-dev --save-exact @gspothq/cli
|
|
11
|
-
git add package.json package-lock.json
|
|
12
|
-
git commit -m "build: Add gspot"
|
|
13
9
|
npx gspot init
|
|
14
10
|
npx gspot install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Check
|
|
14
|
+
|
|
15
|
+
Check your current files:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
15
18
|
npx gspot check
|
|
16
19
|
```
|
|
17
20
|
|
package/dist/gspot.js
CHANGED
|
@@ -2289,7 +2289,7 @@ var rulesSchema = z2.strictObject({
|
|
|
2289
2289
|
var name = "@gspothq/cli";
|
|
2290
2290
|
var package_default = {
|
|
2291
2291
|
name,
|
|
2292
|
-
version: "0.1.
|
|
2292
|
+
version: "0.1.2",
|
|
2293
2293
|
publishConfig: {
|
|
2294
2294
|
access: "public"
|
|
2295
2295
|
},
|
|
@@ -10179,7 +10179,6 @@ var GIT_SOURCE_ARGV = ["rev-parse", "--is-bare-repository", "--absolute-git-dir"
|
|
|
10179
10179
|
var GIT_TOP_LEVEL_ARGV = ["rev-parse", "--show-toplevel"];
|
|
10180
10180
|
var GIT_DIRECTORY_ARGV = ["rev-parse", "--absolute-git-dir"];
|
|
10181
10181
|
var ORIGIN_URL_SETTING = "remote.origin.url";
|
|
10182
|
-
var GIT_STATUS_ARGUMENTS = ["status", "--porcelain"];
|
|
10183
10182
|
var GIT_WORK_TREE_VARIABLE = "GIT_WORK_TREE";
|
|
10184
10183
|
var GIT_VARIABLE_PREFIX = "GIT_";
|
|
10185
10184
|
var NOT_REPOSITORY_MESSAGE = "fatal: not a git repository (or any ";
|
|
@@ -20108,19 +20107,6 @@ function initPlanText(plan) {
|
|
|
20108
20107
|
}
|
|
20109
20108
|
|
|
20110
20109
|
// packages/cli/src/commands/init/command.ts
|
|
20111
|
-
function assertCleanTree(root, options) {
|
|
20112
|
-
if (options.isDryRun)
|
|
20113
|
-
return;
|
|
20114
|
-
const status = runGitBlocking(root, [...GIT_STATUS_ARGUMENTS]);
|
|
20115
|
-
if (status.code !== 0)
|
|
20116
|
-
throw new GspotError("git", [`Git status failed (exit ${String(status.code)}): ${status.stderr.trim()}`]);
|
|
20117
|
-
const changed = status.stdout.split(`
|
|
20118
|
-
`).filter((line) => line.trim() !== "");
|
|
20119
|
-
if (changed.length > 0)
|
|
20120
|
-
throw new GspotError("settings", [
|
|
20121
|
-
`The working tree has ${String(changed.length)} uncommitted change(s). Commit or stash them before gspot init: Git then keeps every file init replaces, and you review its changes separately.`
|
|
20122
|
-
]);
|
|
20123
|
-
}
|
|
20124
20110
|
function printDetection(inputs, detected, tooling, applicable) {
|
|
20125
20111
|
const { repo, manifests } = inputs;
|
|
20126
20112
|
const tools = [...new Set(tooling.toolFiles.map((config) => config.tool))].toSorted((a, b) => a.localeCompare(b));
|
|
@@ -20193,8 +20179,6 @@ function registerInit(program) {
|
|
|
20193
20179
|
async function planInit(root, options) {
|
|
20194
20180
|
const manifests = configurationManifests();
|
|
20195
20181
|
const repo = await readRepository(root, [], []);
|
|
20196
|
-
if (repo.hasGit)
|
|
20197
|
-
assertCleanTree(root, options);
|
|
20198
20182
|
const packageManifests = await readDependencyFiles(root, repo.files);
|
|
20199
20183
|
const scopes = findScopes(repo.files, packageManifests, manifests.values());
|
|
20200
20184
|
const inputs = { root, repo, packageManifests, scopes, manifests };
|
|
@@ -23172,6 +23156,58 @@ async function bashSafety(input) {
|
|
|
23172
23156
|
import { join as join41 } from "node:path";
|
|
23173
23157
|
import { writeFileSync as writeFileSync12 } from "node:fs";
|
|
23174
23158
|
|
|
23159
|
+
// packages/cli/src/repository/revisions/objects.ts
|
|
23160
|
+
async function listRevisionEntries(root, source, cancelSignal) {
|
|
23161
|
+
if (source.kind === "index")
|
|
23162
|
+
return parseIndexRevision(await readIndexEntries(root, cancelSignal));
|
|
23163
|
+
const read = await runGitForBytes(root, [...TREE_ENTRIES_ARGV, source.hash], { cancelSignal });
|
|
23164
|
+
if (read.code !== 0)
|
|
23165
|
+
throw new GspotError("git", [
|
|
23166
|
+
`Git could not read the entries of this revision: ${read.stderr.trim()}. Resolve Git errors before checking again.`
|
|
23167
|
+
]);
|
|
23168
|
+
return parseTreeEntries(read.stdout);
|
|
23169
|
+
}
|
|
23170
|
+
async function visitGitBlobs(root, requested, visit, cancelSignal) {
|
|
23171
|
+
const objects = [...new Set(requested)];
|
|
23172
|
+
if (objects.length === 0)
|
|
23173
|
+
return;
|
|
23174
|
+
const result = await runGit(root, [...BLOBS_ARGV], {
|
|
23175
|
+
stdin: objects.join(`
|
|
23176
|
+
`) + `
|
|
23177
|
+
`,
|
|
23178
|
+
cancelSignal
|
|
23179
|
+
}, async (chunks) => {
|
|
23180
|
+
await visit(parseGitBlobs(chunks, objects));
|
|
23181
|
+
});
|
|
23182
|
+
if (result.code !== 0)
|
|
23183
|
+
throw new GspotError("git", [`Git could not read the objects of this revision: ${result.stderr.trim()}`]);
|
|
23184
|
+
}
|
|
23185
|
+
async function readBlobs(root, requested, cancelSignal) {
|
|
23186
|
+
const blobs = new Map;
|
|
23187
|
+
await visitGitBlobs(root, requested, async (objects) => {
|
|
23188
|
+
for await (const [hash, bytes] of objects)
|
|
23189
|
+
blobs.set(hash, bytes);
|
|
23190
|
+
}, cancelSignal);
|
|
23191
|
+
return requested.map((hash) => blobs.get(hash));
|
|
23192
|
+
}
|
|
23193
|
+
async function readHead(root, cancelSignal) {
|
|
23194
|
+
const options = { cancelSignal };
|
|
23195
|
+
const head = await runGit(root, [...HEAD_ARGV], options);
|
|
23196
|
+
if (head.code === 0)
|
|
23197
|
+
return head.stdout.trim();
|
|
23198
|
+
const failure = new GspotError("git", ["Cannot read committed Git history. Restore HEAD and check again."]);
|
|
23199
|
+
if (head.code !== 1)
|
|
23200
|
+
throw failure;
|
|
23201
|
+
const symbolic = await runGit(root, [...SYMBOLIC_HEAD_ARGV], options);
|
|
23202
|
+
if (symbolic.code !== 0)
|
|
23203
|
+
throw failure;
|
|
23204
|
+
return;
|
|
23205
|
+
}
|
|
23206
|
+
async function listHeadEntries(root, cancelSignal) {
|
|
23207
|
+
const head = await readHead(root, cancelSignal);
|
|
23208
|
+
return head === undefined ? [] : listRevisionEntries(root, { kind: "commit", hash: head }, cancelSignal);
|
|
23209
|
+
}
|
|
23210
|
+
|
|
23175
23211
|
// packages/cli/src/repository/revisions/changes.ts
|
|
23176
23212
|
async function listRemoteHeads(root, cancelSignal) {
|
|
23177
23213
|
const lines = await gitLines(root, [...REMOTE_HEADS_ARGV], {
|
|
@@ -23242,6 +23278,8 @@ async function readPushBase(root, cancelSignal) {
|
|
|
23242
23278
|
async function pushedCommits(root, commits, cancelSignal) {
|
|
23243
23279
|
if (commits !== undefined)
|
|
23244
23280
|
return commits;
|
|
23281
|
+
if (await readHead(root, cancelSignal) === undefined)
|
|
23282
|
+
return [];
|
|
23245
23283
|
const base = await readPushBase(root, cancelSignal);
|
|
23246
23284
|
const listed = await runGit(root, ["rev-list", `${base}..HEAD`, "--"], {
|
|
23247
23285
|
cancelSignal
|
|
@@ -25854,54 +25892,6 @@ function readmeShape(input) {
|
|
|
25854
25892
|
import { join as join56 } from "node:path";
|
|
25855
25893
|
import { writeFileSync as writeFileSync16, appendFileSync } from "node:fs";
|
|
25856
25894
|
|
|
25857
|
-
// packages/cli/src/repository/revisions/objects.ts
|
|
25858
|
-
async function listRevisionEntries(root, source, cancelSignal) {
|
|
25859
|
-
if (source.kind === "index")
|
|
25860
|
-
return parseIndexRevision(await readIndexEntries(root, cancelSignal));
|
|
25861
|
-
const read = await runGitForBytes(root, [...TREE_ENTRIES_ARGV, source.hash], { cancelSignal });
|
|
25862
|
-
if (read.code !== 0)
|
|
25863
|
-
throw new GspotError("git", [
|
|
25864
|
-
`Git could not read the entries of this revision: ${read.stderr.trim()}. Resolve Git errors before checking again.`
|
|
25865
|
-
]);
|
|
25866
|
-
return parseTreeEntries(read.stdout);
|
|
25867
|
-
}
|
|
25868
|
-
async function visitGitBlobs(root, requested, visit, cancelSignal) {
|
|
25869
|
-
const objects = [...new Set(requested)];
|
|
25870
|
-
if (objects.length === 0)
|
|
25871
|
-
return;
|
|
25872
|
-
const result = await runGit(root, [...BLOBS_ARGV], {
|
|
25873
|
-
stdin: objects.join(`
|
|
25874
|
-
`) + `
|
|
25875
|
-
`,
|
|
25876
|
-
cancelSignal
|
|
25877
|
-
}, async (chunks) => {
|
|
25878
|
-
await visit(parseGitBlobs(chunks, objects));
|
|
25879
|
-
});
|
|
25880
|
-
if (result.code !== 0)
|
|
25881
|
-
throw new GspotError("git", [`Git could not read the objects of this revision: ${result.stderr.trim()}`]);
|
|
25882
|
-
}
|
|
25883
|
-
async function readBlobs(root, requested, cancelSignal) {
|
|
25884
|
-
const blobs = new Map;
|
|
25885
|
-
await visitGitBlobs(root, requested, async (objects) => {
|
|
25886
|
-
for await (const [hash, bytes] of objects)
|
|
25887
|
-
blobs.set(hash, bytes);
|
|
25888
|
-
}, cancelSignal);
|
|
25889
|
-
return requested.map((hash) => blobs.get(hash));
|
|
25890
|
-
}
|
|
25891
|
-
async function listHeadEntries(root, cancelSignal) {
|
|
25892
|
-
const options = { cancelSignal };
|
|
25893
|
-
const head = await runGit(root, [...HEAD_ARGV], options);
|
|
25894
|
-
if (head.code === 0)
|
|
25895
|
-
return listRevisionEntries(root, { kind: "commit", hash: head.stdout.trim() }, cancelSignal);
|
|
25896
|
-
const failure = new GspotError("git", ["Cannot read committed Git history. Restore HEAD and check again."]);
|
|
25897
|
-
if (head.code !== 1)
|
|
25898
|
-
throw failure;
|
|
25899
|
-
const symbolic = await runGit(root, [...SYMBOLIC_HEAD_ARGV], options);
|
|
25900
|
-
if (symbolic.code !== 0)
|
|
25901
|
-
throw failure;
|
|
25902
|
-
return [];
|
|
25903
|
-
}
|
|
25904
|
-
|
|
25905
25895
|
// packages/cli/src/config/checks/general/secrets.ts
|
|
25906
25896
|
var CHANGE_LINE = new RegExp(`^:[0-7]{6} (100644|100755|120000) ${HASH_SOURCE} (${HASH_SOURCE}) [AMT]$`, "u");
|
|
25907
25897
|
var DIFF_TREE = [
|
package/gspot.schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://unpkg.com/@gspothq/cli@0.1.
|
|
3
|
+
"$id": "https://unpkg.com/@gspothq/cli@0.1.2/gspot.schema.json",
|
|
4
4
|
"title": "gspot.toml",
|
|
5
5
|
"description": "The settings of gspot for one repository.",
|
|
6
6
|
"type": "object",
|