reposets 0.4.0 → 0.4.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 +15 -14
- package/bin/reposets.d.ts +1 -0
- package/bin/reposets.js +25 -507
- package/cli/commands/credentials.js +74 -0
- package/cli/commands/doctor.js +154 -0
- package/cli/commands/init.js +147 -0
- package/cli/commands/list.js +49 -0
- package/cli/commands/sync.js +70 -0
- package/cli/commands/validate.js +53 -0
- package/errors.js +12 -0
- package/index.d.ts +1750 -1840
- package/index.js +19 -2
- package/lib/crypto.js +27 -0
- package/package.json +61 -73
- package/schemas/common.js +130 -0
- package/schemas/config.js +469 -0
- package/schemas/credentials.js +78 -0
- package/schemas/environment.js +70 -0
- package/schemas/ruleset.js +545 -0
- package/services/ConfigFiles.js +119 -0
- package/services/CredentialResolver.js +40 -0
- package/services/GitHubClient.js +875 -0
- package/services/OnePasswordClient.js +30 -0
- package/services/SyncEngine.js +580 -0
- package/services/SyncLogger.js +106 -0
- package/tsdoc-metadata.json +11 -11
- package/500.js +0 -3354
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Ref } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/services/SyncLogger.ts
|
|
4
|
+
var SyncLogger = class extends Context.Tag("SyncLogger")() {};
|
|
5
|
+
function pluralize(resource, count) {
|
|
6
|
+
if (count === 1) return resource;
|
|
7
|
+
if (resource === "ruleset") return "rulesets";
|
|
8
|
+
if (resource === "security feature") return "security features";
|
|
9
|
+
if (resource === "code scanning") return "code scanning";
|
|
10
|
+
return `${resource}s`;
|
|
11
|
+
}
|
|
12
|
+
function SyncLoggerLive(config) {
|
|
13
|
+
const { dryRun, logLevel, output } = config;
|
|
14
|
+
return Layer.effect(SyncLogger, Effect.gen(function* () {
|
|
15
|
+
const errors = yield* Ref.make([]);
|
|
16
|
+
const currentRepo = yield* Ref.make("");
|
|
17
|
+
function emit(line) {
|
|
18
|
+
if (output) return Ref.update(output, (lines) => [...lines, line]);
|
|
19
|
+
return Effect.sync(() => {
|
|
20
|
+
process.stdout.write(`${line}\n`);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function isVisible(tier) {
|
|
24
|
+
if (logLevel === "silent") return false;
|
|
25
|
+
const levels = [
|
|
26
|
+
"info",
|
|
27
|
+
"verbose",
|
|
28
|
+
"debug"
|
|
29
|
+
];
|
|
30
|
+
return levels.indexOf(logLevel) >= levels.indexOf(tier);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Format a verb with padding. Normal verbs (past tense) are padded to 8 chars.
|
|
34
|
+
* Dry-run verbs ("would " + present tense) are padded to 14 chars.
|
|
35
|
+
* The padded string is concatenated directly with the rest of the line (no extra space).
|
|
36
|
+
*/
|
|
37
|
+
function formatVerb(pastTense, presentTense) {
|
|
38
|
+
if (dryRun) return `would ${presentTense}`.padEnd(14);
|
|
39
|
+
return pastTense.padEnd(8);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
groupStart(name, repoCount) {
|
|
43
|
+
if (!isVisible("info")) return Effect.void;
|
|
44
|
+
return emit(`group: ${name} (${repoCount} ${repoCount === 1 ? "repo" : "repos"})`);
|
|
45
|
+
},
|
|
46
|
+
repoStart(owner, repo) {
|
|
47
|
+
const repoSlug = `${owner}/${repo}`;
|
|
48
|
+
if (!isVisible("info")) return Ref.set(currentRepo, repoSlug);
|
|
49
|
+
return Effect.gen(function* () {
|
|
50
|
+
yield* Ref.set(currentRepo, repoSlug);
|
|
51
|
+
yield* emit(` repo: ${repoSlug}`);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
repoSkip(owner, repo, reason) {
|
|
55
|
+
if (!isVisible("info")) return Effect.void;
|
|
56
|
+
return Effect.gen(function* () {
|
|
57
|
+
yield* emit(` repo: ${owner}/${repo}`);
|
|
58
|
+
yield* emit(` skip ${reason}`);
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
syncSummary(resource, count, detail) {
|
|
62
|
+
if (!isVisible("info")) return Effect.void;
|
|
63
|
+
return emit(` ${formatVerb("synced", "sync")}${count} ${pluralize(resource, count)}${detail ? ` (${detail})` : ""}`);
|
|
64
|
+
},
|
|
65
|
+
settingsApplied() {
|
|
66
|
+
if (!isVisible("info")) return Effect.void;
|
|
67
|
+
return emit(` ${formatVerb("applied", "apply")}settings`);
|
|
68
|
+
},
|
|
69
|
+
cleanupSummary(resource, count, names) {
|
|
70
|
+
if (!isVisible("info")) return Effect.void;
|
|
71
|
+
return emit(` ${formatVerb("deleted", "delete")}${count} ${pluralize(resource, count)}${names.length > 0 ? ` (${names.join(", ")})` : ""}`);
|
|
72
|
+
},
|
|
73
|
+
syncOperation(verb, resource, name, detail, source) {
|
|
74
|
+
if (!isVisible("verbose")) return Effect.void;
|
|
75
|
+
return emit(` ${formatVerb(verb, verb)}${resource}${name ? ` ${name}` : ""}${detail ? ` ${detail}` : ""}${source && isVisible("debug") ? ` <- ${source}` : ""}`);
|
|
76
|
+
},
|
|
77
|
+
syncError(context, message) {
|
|
78
|
+
if (!isVisible("info")) return Effect.void;
|
|
79
|
+
return Effect.gen(function* () {
|
|
80
|
+
const repo = yield* Ref.get(currentRepo);
|
|
81
|
+
yield* Ref.update(errors, (errs) => [...errs, {
|
|
82
|
+
repo,
|
|
83
|
+
context,
|
|
84
|
+
message
|
|
85
|
+
}]);
|
|
86
|
+
yield* emit(` error ${context}: ${message}`);
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
finish() {
|
|
90
|
+
if (!isVisible("info")) return Effect.void;
|
|
91
|
+
return Effect.gen(function* () {
|
|
92
|
+
const errs = yield* Ref.get(errors);
|
|
93
|
+
if (errs.length === 0) yield* emit("Sync complete!");
|
|
94
|
+
else {
|
|
95
|
+
const label = errs.length === 1 ? "error" : "errors";
|
|
96
|
+
yield* emit(`Sync complete with ${errs.length} ${label}:`);
|
|
97
|
+
for (const err of errs) yield* emit(` ${err.repo}: ${err.context} \u2014 ${err.message}`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { SyncLogger, SyncLoggerLive };
|
package/tsdoc-metadata.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.58.
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.58.9"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|