@r_masseater/msch 0.93.0 → 0.95.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/README.md +1 -1
- package/dist/{base-revision-C9RxuIMK.mjs → base-revision-uiUwYlbc.mjs} +2 -2
- package/dist/{base-revision-C9RxuIMK.mjs.map → base-revision-uiUwYlbc.mjs.map} +1 -1
- package/dist/cargo-inputs.mjs +2 -2
- package/dist/changed.mjs +5 -5
- package/dist/cli.mjs +496 -382
- package/dist/cli.mjs.map +1 -1
- package/dist/collections-CdEHfcEj.mjs +6 -0
- package/dist/collections-CdEHfcEj.mjs.map +1 -0
- package/dist/config-BBdsNPSO.mjs.map +1 -1
- package/dist/config.mjs +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{define-lint-preset-GWsBHDRn.mjs → define-lint-preset-BjHY5WNt.mjs} +57 -38
- package/dist/define-lint-preset-BjHY5WNt.mjs.map +1 -0
- package/dist/exits.mjs +4 -4
- package/dist/{ignored-directories-Ce-45yzO.mjs → ignored-directories-BRRODOoG.mjs} +2 -2
- package/dist/{ignored-directories-Ce-45yzO.mjs.map → ignored-directories-BRRODOoG.mjs.map} +1 -1
- package/dist/index-skill-Bf5Ish11.mjs +19 -0
- package/dist/index-skill-Bf5Ish11.mjs.map +1 -0
- package/dist/judge.mjs +4 -4
- package/dist/lint.mjs +1 -1
- package/dist/{lookup-report-DVJg0K4Z.mjs → lookup-report-BWiDFlSS.mjs} +3 -3
- package/dist/{lookup-report-DVJg0K4Z.mjs.map → lookup-report-BWiDFlSS.mjs.map} +1 -1
- package/dist/{manifest-texts-B69vIp7o.mjs → manifest-texts-Bhlz2Z2_.mjs} +2 -2
- package/dist/{manifest-texts-B69vIp7o.mjs.map → manifest-texts-Bhlz2Z2_.mjs.map} +1 -1
- package/dist/{output-B_YPmKad.mjs → output-B4GNchqH.mjs} +3 -3
- package/dist/{output-B_YPmKad.mjs.map → output-B4GNchqH.mjs.map} +1 -1
- package/dist/oxlint.mjs +2 -2
- package/dist/package-routes-BdYpOLTv.mjs +73 -0
- package/dist/package-routes-BdYpOLTv.mjs.map +1 -0
- package/dist/{package-versions-PMKDR-bJ.mjs → package-versions-BLtKon6D.mjs} +4 -4
- package/dist/{package-versions-PMKDR-bJ.mjs.map → package-versions-BLtKon6D.mjs.map} +1 -1
- package/dist/{pass-records-CBvMwfN3.mjs → pass-records-ljpQ--tm.mjs} +4 -4
- package/dist/{pass-records-CBvMwfN3.mjs.map → pass-records-ljpQ--tm.mjs.map} +1 -1
- package/dist/{problem-CUIz4TEI.mjs → problem-Bi4Kgg9b.mjs} +2 -2
- package/dist/{problem-CUIz4TEI.mjs.map → problem-Bi4Kgg9b.mjs.map} +1 -1
- package/dist/publish.mjs +56 -100
- package/dist/publish.mjs.map +1 -1
- package/dist/{published-B5LA4ZlS.mjs → published-BGur-Htr.mjs} +9 -5
- package/dist/{published-B5LA4ZlS.mjs.map → published-BGur-Htr.mjs.map} +1 -1
- package/dist/published.mjs +15 -18
- package/dist/published.mjs.map +1 -1
- package/dist/refs.mjs +7 -7
- package/dist/refs.mjs.map +1 -1
- package/dist/registries-DePiYd3D.mjs +11 -0
- package/dist/registries-DePiYd3D.mjs.map +1 -0
- package/dist/{registry-releases-Dj6jH8Yt.mjs → registry-releases-CaO-8xAO.mjs} +3 -3
- package/dist/registry-releases-CaO-8xAO.mjs.map +1 -0
- package/dist/{repository-files-B6PEvKWe.mjs → repository-files-hbJpQ1i0.mjs} +9 -5
- package/dist/repository-files-hbJpQ1i0.mjs.map +1 -0
- package/dist/{runtime-C8OGDSk9.mjs → runtime-BdEuIL6Z.mjs} +2 -2
- package/dist/{runtime-C8OGDSk9.mjs.map → runtime-BdEuIL6Z.mjs.map} +1 -1
- package/dist/unbumped.mjs +5 -5
- package/dist/{upstream-exits-nTTh2qcD.mjs → upstream-exits-BC8ofnVa.mjs} +7 -7
- package/dist/{upstream-exits-nTTh2qcD.mjs.map → upstream-exits-BC8ofnVa.mjs.map} +1 -1
- package/dist/{upstream-record-DlluH3fY.mjs → upstream-record-I5ZgAwk-.mjs} +3 -2
- package/dist/{upstream-record-DlluH3fY.mjs.map → upstream-record-I5ZgAwk-.mjs.map} +1 -1
- package/dist/upstream.mjs +7 -8
- package/dist/upstream.mjs.map +1 -1
- package/dist/{workspace-projects-B-vCr6bx.mjs → workspace-projects-DnWDM8G1.mjs} +2 -2
- package/dist/{workspace-projects-B-vCr6bx.mjs.map → workspace-projects-DnWDM8G1.mjs.map} +1 -1
- package/dist/workspace-settings.mjs +4 -4
- package/package.json +4 -5
- package/skills/msch-checks/SKILL.md +3 -3
- package/skills/msch-publishing/SKILL.md +5 -5
- package/skills/msch-repository-config/SKILL.md +20 -33
- package/skills/msch-workspace-settings/SKILL.md +1 -0
- package/src/app/vite.d.ts +1 -34
- package/dist/credential-broker-PkIpsaMh.mjs +0 -29
- package/dist/credential-broker-PkIpsaMh.mjs.map +0 -1
- package/dist/define-lint-preset-GWsBHDRn.mjs.map +0 -1
- package/dist/owner-settings-BAh-fFKg.mjs +0 -122
- package/dist/owner-settings-BAh-fFKg.mjs.map +0 -1
- package/dist/package-routes-DQmhjX07.mjs +0 -82
- package/dist/package-routes-DQmhjX07.mjs.map +0 -1
- package/dist/registry-releases-Dj6jH8Yt.mjs.map +0 -1
- package/dist/repository-files-B6PEvKWe.mjs.map +0 -1
- package/dist/wake.d.mts +0 -1
- package/dist/wake.mjs +0 -34
- package/dist/wake.mjs.map +0 -1
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { r as RepositoryFiles } from "./repository-files-B6PEvKWe.mjs";
|
|
2
|
-
import { t as startedOnce } from "./started-once-muJbvD_I.mjs";
|
|
3
|
-
import { Array, Effect, Option, Schema, String, pipe } from "effect";
|
|
4
|
-
import { resolveConfigFromFile } from "vite-plus";
|
|
5
|
-
// src/shared/config/masseater-marketplace.json
|
|
6
|
-
var name = "masseater-dev";
|
|
7
|
-
var plugins = [{
|
|
8
|
-
"name": "kogane",
|
|
9
|
-
"source": {
|
|
10
|
-
"source": "npm",
|
|
11
|
-
"package": "@r_masseater/kogane"
|
|
12
|
-
},
|
|
13
|
-
"description": "Claude Code plugin that suggests existing workspaces of the current pnpm monorepo for each prompt, ranked with EmbeddingGemma 2 on the user's machine."
|
|
14
|
-
}, {
|
|
15
|
-
"name": "watashi",
|
|
16
|
-
"source": {
|
|
17
|
-
"source": "npm",
|
|
18
|
-
"package": "@r_masseater/watashi"
|
|
19
|
-
},
|
|
20
|
-
"description": "CLI for watashi (watashi.masseater.dev). Sends Claude Code transcripts from a Stop hook after masking secrets locally with h56m, and manages login and API tokens."
|
|
21
|
-
}];
|
|
22
|
-
// src/shared/lib/owner-settings.ts
|
|
23
|
-
const CONFIG_FILE = "vite.config.ts";
|
|
24
|
-
const TRAILING_SLASH = /\/*$/u;
|
|
25
|
-
const SCOPE_SEPARATOR = "/";
|
|
26
|
-
const PUBLIC_REGISTRY = "https://registry.npmjs.org/";
|
|
27
|
-
const MarketplaceSchema = Schema.Struct({
|
|
28
|
-
name: Schema.String,
|
|
29
|
-
repository: Schema.String,
|
|
30
|
-
plugins: Schema.Array(Schema.String)
|
|
31
|
-
});
|
|
32
|
-
const SkillSourceSchema = Schema.Struct({
|
|
33
|
-
repository: Schema.String,
|
|
34
|
-
root: Schema.String
|
|
35
|
-
});
|
|
36
|
-
const BrokerSchema = Schema.Struct({
|
|
37
|
-
url: Schema.String,
|
|
38
|
-
audience: Schema.String
|
|
39
|
-
});
|
|
40
|
-
const OptionalString = Schema.optional(Schema.String);
|
|
41
|
-
const PackagesSchema = Schema.Struct({
|
|
42
|
-
scope: OptionalString,
|
|
43
|
-
registry: OptionalString
|
|
44
|
-
});
|
|
45
|
-
const InstallsSchema = Schema.Struct({ registry: OptionalString });
|
|
46
|
-
const SkillsSchema = Schema.Union([SkillSourceSchema, Schema.Literal("marketplace")]);
|
|
47
|
-
const AgentsSchema = Schema.Struct({
|
|
48
|
-
marketplace: Schema.optional(MarketplaceSchema),
|
|
49
|
-
skills: Schema.optional(SkillsSchema)
|
|
50
|
-
});
|
|
51
|
-
const BrokerSetting = Schema.Union([BrokerSchema, Schema.Literal(false)]);
|
|
52
|
-
const MschSchema = Schema.Struct({
|
|
53
|
-
packages: Schema.optional(PackagesSchema),
|
|
54
|
-
installs: Schema.optional(InstallsSchema),
|
|
55
|
-
agents: Schema.optional(AgentsSchema),
|
|
56
|
-
broker: Schema.optional(BrokerSetting)
|
|
57
|
-
});
|
|
58
|
-
const Configured = Schema.Struct({ msch: MschSchema });
|
|
59
|
-
const decodeConfigured = Schema.decodeUnknownOption(Configured);
|
|
60
|
-
const withTrailingSlash = (url) => `${String.replace(TRAILING_SLASH, "")(url)}/`;
|
|
61
|
-
const scopeOf = (scope) => `${String.replace(TRAILING_SLASH, "")(scope)}${SCOPE_SEPARATOR}`;
|
|
62
|
-
const DEFAULT_SETTINGS = {
|
|
63
|
-
scope: "@r_masseater/",
|
|
64
|
-
publishRegistry: PUBLIC_REGISTRY,
|
|
65
|
-
installRegistry: "https://npm.flatt.tech/",
|
|
66
|
-
marketplace: {
|
|
67
|
-
name,
|
|
68
|
-
repository: "masseater/masseater.dev",
|
|
69
|
-
plugins: pipe(plugins, Array.map(({ name }) => name))
|
|
70
|
-
},
|
|
71
|
-
skills: {
|
|
72
|
-
repository: "masseater/skills",
|
|
73
|
-
root: "plugins/masseater-skills/skills"
|
|
74
|
-
},
|
|
75
|
-
broker: Option.some({
|
|
76
|
-
url: "https://credentials.masseater.dev/",
|
|
77
|
-
audience: "masseater-dev-credential-broker"
|
|
78
|
-
})
|
|
79
|
-
};
|
|
80
|
-
const brokerOf = (configured) => {
|
|
81
|
-
if (configured === false) return Option.none();
|
|
82
|
-
return pipe(Option.fromUndefinedOr(configured), Option.map(({ url, audience }) => ({
|
|
83
|
-
url: withTrailingSlash(url),
|
|
84
|
-
audience
|
|
85
|
-
})), Option.orElse(() => DEFAULT_SETTINGS.broker));
|
|
86
|
-
};
|
|
87
|
-
const packagesOf = ({ scope, registry }) => ({
|
|
88
|
-
scope: Option.match(Option.fromUndefinedOr(scope), {
|
|
89
|
-
onNone: () => DEFAULT_SETTINGS.scope,
|
|
90
|
-
onSome: scopeOf
|
|
91
|
-
}),
|
|
92
|
-
publishRegistry: withTrailingSlash(registry ?? DEFAULT_SETTINGS.publishRegistry)
|
|
93
|
-
});
|
|
94
|
-
const installsOf = ({ registry }) => ({ installRegistry: withTrailingSlash(registry ?? DEFAULT_SETTINGS.installRegistry) });
|
|
95
|
-
const agentsOf = ({ marketplace: configured, skills }) => ({
|
|
96
|
-
marketplace: configured ?? DEFAULT_SETTINGS.marketplace,
|
|
97
|
-
skills: skills ?? DEFAULT_SETTINGS.skills
|
|
98
|
-
});
|
|
99
|
-
const settingsOf = (config) => pipe(decodeConfigured(config), Option.map(({ msch: { packages = {}, installs = {}, agents = {}, broker } }) => ({
|
|
100
|
-
...packagesOf(packages),
|
|
101
|
-
...installsOf(installs),
|
|
102
|
-
...agentsOf(agents),
|
|
103
|
-
broker: brokerOf(broker)
|
|
104
|
-
})), Option.getOrElse(() => DEFAULT_SETTINGS));
|
|
105
|
-
const resolvedOnce = startedOnce();
|
|
106
|
-
const taggedError = Schema.TaggedError;
|
|
107
|
-
var OwnerConfigUnreadable = class extends taggedError()("OwnerConfigUnreadable", { file: Schema.String }) {};
|
|
108
|
-
const ownerSettings = Effect.fn("ownerSettings")(function* ownerSettings(root) {
|
|
109
|
-
const files = yield* RepositoryFiles;
|
|
110
|
-
const file = files.join(root, CONFIG_FILE);
|
|
111
|
-
if (!(yield* files.exists(file))) return DEFAULT_SETTINGS;
|
|
112
|
-
const config = yield* Effect.tryPromise({
|
|
113
|
-
try: () => resolvedOnce(file, () => resolveConfigFromFile(file)),
|
|
114
|
-
catch: () => OwnerConfigUnreadable.make({ file })
|
|
115
|
-
}).pipe(Effect.option);
|
|
116
|
-
return pipe(config, Option.map(settingsOf), Option.getOrElse(() => DEFAULT_SETTINGS));
|
|
117
|
-
});
|
|
118
|
-
const isPublicRegistry = (registry) => withTrailingSlash(registry) === PUBLIC_REGISTRY;
|
|
119
|
-
const scopeOfName = (name) => pipe(Option.liftPredicate(name, String.startsWith("@")), Option.flatMap((scoped) => pipe(String.indexOf(SCOPE_SEPARATOR)(scoped), Option.map((end) => String.takeLeft(scoped, end + 1)))));
|
|
120
|
-
export { scopeOfName as a, ownerSettings as i, PUBLIC_REGISTRY as n, withTrailingSlash as o, isPublicRegistry as r, DEFAULT_SETTINGS as t };
|
|
121
|
-
|
|
122
|
-
//# sourceMappingURL=owner-settings-BAh-fFKg.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"owner-settings-BAh-fFKg.mjs","names":["Str","marketplace.name","marketplace.plugins","Arr"],"sources":["../src/shared/config/masseater-marketplace.json","../src/shared/lib/owner-settings.ts"],"sourcesContent":["","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport marketplace from \"#/shared/config/masseater-marketplace.json\" with { type: \"json\" };\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { startedOnce } from \"./started-once.ts\";\n\nconst CONFIG_FILE = \"vite.config.ts\";\nconst TRAILING_SLASH = /\\/*$/u;\nconst SCOPE_SEPARATOR = \"/\";\n\nexport const PUBLIC_REGISTRY = \"https://registry.npmjs.org/\";\n\nconst MarketplaceSchema = Schema.Struct({\n name: Schema.String,\n repository: Schema.String,\n plugins: Schema.Array(Schema.String),\n});\nconst SkillSourceSchema = Schema.Struct({ repository: Schema.String, root: Schema.String });\nconst BrokerSchema = Schema.Struct({ url: Schema.String, audience: Schema.String });\nconst OptionalString = Schema.optional(Schema.String);\nconst PackagesSchema = Schema.Struct({ scope: OptionalString, registry: OptionalString });\nconst InstallsSchema = Schema.Struct({ registry: OptionalString });\nconst SkillsSchema = Schema.Union([SkillSourceSchema, Schema.Literal(\"marketplace\")]);\nconst AgentsSchema = Schema.Struct({\n marketplace: Schema.optional(MarketplaceSchema),\n skills: Schema.optional(SkillsSchema),\n});\nconst BrokerSetting = Schema.Union([BrokerSchema, Schema.Literal(false)]);\nconst MschSchema = Schema.Struct({\n packages: Schema.optional(PackagesSchema),\n installs: Schema.optional(InstallsSchema),\n agents: Schema.optional(AgentsSchema),\n broker: Schema.optional(BrokerSetting),\n});\n\nconst Configured = Schema.Struct({ msch: MschSchema });\nconst decodeConfigured = Schema.decodeUnknownOption(Configured);\n\ntype ConfiguredSettings = (typeof Configured.Type)[\"msch\"];\n\nexport type AgentMarketplace = typeof MarketplaceSchema.Type;\nexport type SkillSource = typeof SkillSourceSchema.Type;\nexport type CredentialBroker = typeof BrokerSchema.Type;\n\nexport interface OwnerSettings {\n readonly scope: string;\n readonly publishRegistry: string;\n readonly installRegistry: string;\n readonly marketplace: AgentMarketplace;\n readonly skills: SkillSource | \"marketplace\";\n readonly broker: Option.Option<CredentialBroker>;\n}\n\nexport const withTrailingSlash = (url: string): string =>\n `${Str.replace(TRAILING_SLASH, \"\")(url)}/`;\n\nconst scopeOf = (scope: string): string =>\n `${Str.replace(TRAILING_SLASH, \"\")(scope)}${SCOPE_SEPARATOR}`;\n\nexport const DEFAULT_SETTINGS: OwnerSettings = {\n scope: \"@r_masseater/\",\n publishRegistry: PUBLIC_REGISTRY,\n installRegistry: \"https://npm.flatt.tech/\",\n marketplace: {\n name: marketplace.name,\n repository: \"masseater/masseater.dev\",\n plugins: pipe(\n marketplace.plugins,\n Arr.map(({ name }) => name),\n ),\n },\n skills: { repository: \"masseater/skills\", root: \"plugins/masseater-skills/skills\" },\n broker: Option.some({\n url: \"https://credentials.masseater.dev/\",\n audience: \"masseater-dev-credential-broker\",\n }),\n};\n\nconst brokerOf = (configured: ConfiguredSettings[\"broker\"]): Option.Option<CredentialBroker> => {\n if (configured === false) {\n return Option.none();\n }\n return pipe(\n Option.fromUndefinedOr(configured),\n Option.map(({ url, audience }) => ({ url: withTrailingSlash(url), audience })),\n Option.orElse(() => DEFAULT_SETTINGS.broker),\n );\n};\n\nconst packagesOf = ({\n scope,\n registry,\n}: NonNullable<ConfiguredSettings[\"packages\"]>): Pick<\n OwnerSettings,\n \"scope\" | \"publishRegistry\"\n> => ({\n scope: Option.match(Option.fromUndefinedOr(scope), {\n onNone: () => DEFAULT_SETTINGS.scope,\n onSome: scopeOf,\n }),\n publishRegistry: withTrailingSlash(registry ?? DEFAULT_SETTINGS.publishRegistry),\n});\n\nconst installsOf = ({\n registry,\n}: NonNullable<ConfiguredSettings[\"installs\"]>): Pick<OwnerSettings, \"installRegistry\"> => ({\n installRegistry: withTrailingSlash(registry ?? DEFAULT_SETTINGS.installRegistry),\n});\n\nconst agentsOf = ({\n marketplace: configured,\n skills,\n}: NonNullable<ConfiguredSettings[\"agents\"]>): Pick<OwnerSettings, \"marketplace\" | \"skills\"> => ({\n marketplace: configured ?? DEFAULT_SETTINGS.marketplace,\n skills: skills ?? DEFAULT_SETTINGS.skills,\n});\n\nexport const settingsOf = (config: unknown): OwnerSettings =>\n pipe(\n decodeConfigured(config),\n Option.map(\n ({ msch: { packages = {}, installs = {}, agents = {}, broker } }): OwnerSettings => ({\n ...packagesOf(packages),\n ...installsOf(installs),\n ...agentsOf(agents),\n broker: brokerOf(broker),\n }),\n ),\n Option.getOrElse(() => DEFAULT_SETTINGS),\n );\n\nconst resolvedOnce = startedOnce<unknown>();\n\nconst taggedError = Schema.TaggedError;\n\nclass OwnerConfigUnreadable extends taggedError<\n OwnerConfigUnreadable,\n { readonly brand: unique symbol }\n>()(\"OwnerConfigUnreadable\", { file: Schema.String }) {}\n\nexport const ownerSettings = Effect.fn(\"ownerSettings\")(function* ownerSettings(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, CONFIG_FILE);\n const exists = yield* files.exists(file);\n if (!exists) {\n return DEFAULT_SETTINGS;\n }\n const config = yield* Effect.tryPromise({\n try: () => resolvedOnce(file, () => resolveConfigFromFile(file)),\n catch: () => OwnerConfigUnreadable.make({ file }),\n }).pipe(Effect.option);\n return pipe(\n config,\n Option.map(settingsOf),\n Option.getOrElse(() => DEFAULT_SETTINGS),\n );\n});\n\nexport const isPublicRegistry = (registry: string): boolean =>\n withTrailingSlash(registry) === PUBLIC_REGISTRY;\n\nexport const scopeOfName = (name: string): Option.Option<string> =>\n pipe(\n Option.liftPredicate(name, Str.startsWith(\"@\")),\n Option.flatMap((scoped) =>\n pipe(\n Str.indexOf(SCOPE_SEPARATOR)(scoped),\n Option.map((end) => Str.takeLeft(scoped, end + SCOPE_SEPARATOR.length)),\n ),\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;ACQA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAExB,MAAa,kBAAkB;AAE/B,MAAM,oBAAoB,OAAO,OAAO;CACtC,MAAM,OAAO;CACb,YAAY,OAAO;CACnB,SAAS,OAAO,MAAM,OAAO,MAAM;AACrC,CAAC;AACD,MAAM,oBAAoB,OAAO,OAAO;CAAE,YAAY,OAAO;CAAQ,MAAM,OAAO;AAAO,CAAC;AAC1F,MAAM,eAAe,OAAO,OAAO;CAAE,KAAK,OAAO;CAAQ,UAAU,OAAO;AAAO,CAAC;AAClF,MAAM,iBAAiB,OAAO,SAAS,OAAO,MAAM;AACpD,MAAM,iBAAiB,OAAO,OAAO;CAAE,OAAO;CAAgB,UAAU;AAAe,CAAC;AACxF,MAAM,iBAAiB,OAAO,OAAO,EAAE,UAAU,eAAe,CAAC;AACjE,MAAM,eAAe,OAAO,MAAM,CAAC,mBAAmB,OAAO,QAAQ,aAAa,CAAC,CAAC;AACpF,MAAM,eAAe,OAAO,OAAO;CACjC,aAAa,OAAO,SAAS,iBAAiB;CAC9C,QAAQ,OAAO,SAAS,YAAY;AACtC,CAAC;AACD,MAAM,gBAAgB,OAAO,MAAM,CAAC,cAAc,OAAO,QAAQ,KAAK,CAAC,CAAC;AACxE,MAAM,aAAa,OAAO,OAAO;CAC/B,UAAU,OAAO,SAAS,cAAc;CACxC,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js";
|
|
2
|
-
import { a as scopeOfName, i as ownerSettings, n as PUBLIC_REGISTRY, r as isPublicRegistry } from "./owner-settings-BAh-fFKg.mjs";
|
|
3
|
-
import { Array, Config, Context, Effect, Option, String, pipe } from "effect";
|
|
4
|
-
import { decodePackageJson } from "@r_masseater/masseater-utils/kestrion/npm";
|
|
5
|
-
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
6
|
-
// src/shared/lib/lookup.ts
|
|
7
|
-
const USER_AGENT = "msch (https://github.com/masseater/ecosystems/tree/main/libs/msch)";
|
|
8
|
-
/** @internal */
|
|
9
|
-
const JSON_ACCEPT = "application/json";
|
|
10
|
-
const requestOf = ({ url, token, accept }) => {
|
|
11
|
-
const request = HttpClientRequest.get(url).pipe(HttpClientRequest.setHeader("user-agent", USER_AGENT), HttpClientRequest.setHeader("accept", accept));
|
|
12
|
-
return Option.match(token, {
|
|
13
|
-
onNone: () => request,
|
|
14
|
-
onSome: (value) => HttpClientRequest.bearerToken(value)(request)
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
/** @internal */
|
|
18
|
-
const sent = (lookup) => HttpClient.HttpClient.pipe(Effect.flatMap((client) => client.execute(requestOf(lookup))));
|
|
19
|
-
/** @internal */
|
|
20
|
-
const fetched = (lookup) => sent(lookup).pipe(Effect.flatMap(HttpClientResponse.filterStatusOk));
|
|
21
|
-
/** @internal */
|
|
22
|
-
const jsonLookup = ({ url, token }) => ({
|
|
23
|
-
url,
|
|
24
|
-
token,
|
|
25
|
-
accept: JSON_ACCEPT
|
|
26
|
-
});
|
|
27
|
-
/** @internal */
|
|
28
|
-
const publicLookup = (url) => jsonLookup({
|
|
29
|
-
url,
|
|
30
|
-
token: Option.none()
|
|
31
|
-
});
|
|
32
|
-
/** @internal */
|
|
33
|
-
const githubToken = Config.option(Config.String("GH_TOKEN").pipe(Config.orElse(() => Config.String("GITHUB_TOKEN")))).pipe(Effect.orElseSucceed(() => Option.none()));
|
|
34
|
-
// src/shared/lib/package-routes.ts
|
|
35
|
-
/** @internal */
|
|
36
|
-
const PUBLIC_ROUTES = {
|
|
37
|
-
ownScopes: [],
|
|
38
|
-
registry: PUBLIC_REGISTRY,
|
|
39
|
-
token: Option.none()
|
|
40
|
-
};
|
|
41
|
-
const registryToken = (registry) => {
|
|
42
|
-
if (isPublicRegistry(registry)) return Effect.succeedNone;
|
|
43
|
-
return Config.option(Config.String("NODE_AUTH_TOKEN").pipe(Config.orElse(() => Config.String("GH_TOKEN")), Config.orElse(() => Config.String("GITHUB_TOKEN")))).pipe(Effect.orElseSucceed(() => Option.none()));
|
|
44
|
-
};
|
|
45
|
-
/** @internal */
|
|
46
|
-
const PackageRoutesOf = Context.Reference("msch/PackageRoutesOf", { defaultValue: () => PUBLIC_ROUTES });
|
|
47
|
-
/** @internal */
|
|
48
|
-
const packageRoutes = Effect.fn("packageRoutes")(function* packageRoutes(root) {
|
|
49
|
-
const { scope, publishRegistry } = yield* ownerSettings(root);
|
|
50
|
-
const manifests = yield* manifestTexts(root);
|
|
51
|
-
const token = yield* registryToken(publishRegistry);
|
|
52
|
-
return {
|
|
53
|
-
ownScopes: Array.dedupe([scope, ...pipe(manifests, Array.flatMap(({ text }) => pipe(decodePackageJson(text), Option.flatMap(({ name }) => Option.fromUndefinedOr(name)), Option.flatMap(scopeOfName), Option.toArray)))]),
|
|
54
|
-
registry: publishRegistry,
|
|
55
|
-
token
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
/** @internal */
|
|
59
|
-
const isOwnPackage = ({ ownScopes }) => (name) => Option.exists(scopeOfName(name), (scope) => Array.contains(ownScopes, scope));
|
|
60
|
-
/** @internal */
|
|
61
|
-
const packageLookup = (routes) => (name) => {
|
|
62
|
-
const path = String.replace("/", "%2f")(name);
|
|
63
|
-
if (isOwnPackage(routes)(name)) return jsonLookup({
|
|
64
|
-
url: `${routes.registry}${path}`,
|
|
65
|
-
token: routes.token
|
|
66
|
-
});
|
|
67
|
-
return jsonLookup({
|
|
68
|
-
url: `${PUBLIC_REGISTRY}${path}`,
|
|
69
|
-
token: Option.none()
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
const ABBREVIATED = "application/vnd.npm.install-v1+json";
|
|
73
|
-
/** @internal */
|
|
74
|
-
const abbreviatedLookup = (routes) => (name) => ({
|
|
75
|
-
...packageLookup(routes)(name),
|
|
76
|
-
accept: ABBREVIATED
|
|
77
|
-
});
|
|
78
|
-
/** @internal */
|
|
79
|
-
const abbreviatedPackument = (routes) => (name) => sent(abbreviatedLookup(routes)(name));
|
|
80
|
-
export { packageLookup as a, githubToken as c, sent as d, isOwnPackage as i, jsonLookup as l, abbreviatedLookup as n, packageRoutes as o, abbreviatedPackument as r, fetched as s, PackageRoutesOf as t, publicLookup as u };
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=package-routes-DQmhjX07.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-routes-DQmhjX07.mjs","names":["Arr","Str"],"sources":["../src/shared/lib/lookup.ts","../src/shared/lib/package-routes.ts"],"sourcesContent":["import { Config, Effect, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\nimport type { HttpClientError } from \"effect/http\";\n\nconst USER_AGENT = \"msch (https://github.com/masseater/ecosystems/tree/main/libs/msch)\";\n\n/** @internal */\nexport const JSON_ACCEPT = \"application/json\";\n\n/** @internal */\nexport interface Lookup {\n readonly url: string;\n readonly token: Option.Option<string>;\n readonly accept: string;\n}\n\nconst requestOf = ({ url, token, accept }: Lookup): HttpClientRequest.HttpClientRequest => {\n const request = HttpClientRequest.get(url).pipe(\n HttpClientRequest.setHeader(\"user-agent\", USER_AGENT),\n HttpClientRequest.setHeader(\"accept\", accept),\n );\n return Option.match(token, {\n onNone: () => request,\n onSome: (value) => HttpClientRequest.bearerToken(value)(request),\n });\n};\n\n/** @internal */\nexport const sent = (\n lookup: Lookup,\n): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n HttpClientError.HttpClientError,\n HttpClient.HttpClient\n> => HttpClient.HttpClient.pipe(Effect.flatMap((client) => client.execute(requestOf(lookup))));\n\n/** @internal */\nexport const fetched = (\n lookup: Lookup,\n): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n HttpClientError.HttpClientError,\n HttpClient.HttpClient\n> => sent(lookup).pipe(Effect.flatMap(HttpClientResponse.filterStatusOk));\n\n/** @internal */\nexport const jsonLookup = ({\n url,\n token,\n}: {\n readonly url: string;\n readonly token: Option.Option<string>;\n}): Lookup => ({\n url,\n token,\n accept: JSON_ACCEPT,\n});\n\n/** @internal */\nexport const publicLookup = (url: string): Lookup => jsonLookup({ url, token: Option.none() });\n\n/** @internal */\nexport const githubToken: Effect.Effect<Option.Option<string>> = Config.option(\n Config.String(\"GH_TOKEN\").pipe(Config.orElse(() => Config.String(\"GITHUB_TOKEN\"))),\n).pipe(Effect.orElseSucceed(() => Option.none<string>()));\n","import { decodePackageJson } from \"@r_masseater/masseater-utils/kestrion/npm\";\nimport { Array as Arr, Config, Context, Effect, Option, String as Str, pipe } from \"effect\";\nimport type { HttpClient, HttpClientError, HttpClientResponse } from \"effect/http\";\n\nimport { jsonLookup, sent } from \"./lookup.ts\";\nimport type { Lookup } from \"./lookup.ts\";\nimport { manifestTexts } from \"./manifest-texts.ts\";\nimport { PUBLIC_REGISTRY, isPublicRegistry, ownerSettings, scopeOfName } from \"./owner-settings.ts\";\n\n/** @internal */\nexport interface PackageRoutes {\n readonly ownScopes: readonly string[];\n readonly registry: string;\n readonly token: Option.Option<string>;\n}\n\n/** @internal */\nexport const PUBLIC_ROUTES: PackageRoutes = {\n ownScopes: [],\n registry: PUBLIC_REGISTRY,\n token: Option.none(),\n};\n\nconst registryToken = (registry: string): Effect.Effect<Option.Option<string>> => {\n if (isPublicRegistry(registry)) {\n return Effect.succeedNone;\n }\n return Config.option(\n Config.String(\"NODE_AUTH_TOKEN\").pipe(\n Config.orElse(() => Config.String(\"GH_TOKEN\")),\n Config.orElse(() => Config.String(\"GITHUB_TOKEN\")),\n ),\n ).pipe(Effect.orElseSucceed(() => Option.none<string>()));\n};\n\n/** @internal */\nexport const PackageRoutesOf = Context.Reference<PackageRoutes>(\"msch/PackageRoutesOf\", {\n defaultValue: () => PUBLIC_ROUTES,\n});\n\n/** @internal */\nexport const packageRoutes = Effect.fn(\"packageRoutes\")(function* packageRoutes(root: string) {\n const { scope, publishRegistry } = yield* ownerSettings(root);\n const manifests = yield* manifestTexts(root);\n const token = yield* registryToken(publishRegistry);\n const ownScopes = Arr.dedupe([\n scope,\n ...pipe(\n manifests,\n Arr.flatMap(({ text }) =>\n pipe(\n decodePackageJson(text),\n Option.flatMap(({ name }) => Option.fromUndefinedOr(name)),\n Option.flatMap(scopeOfName),\n Option.toArray,\n ),\n ),\n ),\n ]);\n const routes: PackageRoutes = { ownScopes, registry: publishRegistry, token };\n return routes;\n});\n\n/** @internal */\nexport const isOwnPackage =\n ({ ownScopes }: PackageRoutes) =>\n (name: string): boolean =>\n Option.exists(scopeOfName(name), (scope) => Arr.contains(ownScopes, scope));\n\n/** @internal */\nexport const packageLookup =\n (routes: PackageRoutes) =>\n (name: string): Lookup => {\n const path = Str.replace(\"/\", \"%2f\")(name);\n if (isOwnPackage(routes)(name)) {\n return jsonLookup({ url: `${routes.registry}${path}`, token: routes.token });\n }\n return jsonLookup({ url: `${PUBLIC_REGISTRY}${path}`, token: Option.none() });\n };\n\nconst ABBREVIATED = \"application/vnd.npm.install-v1+json\";\n\n/** @internal */\nexport const abbreviatedLookup =\n (routes: PackageRoutes) =>\n (name: string): Lookup => ({ ...packageLookup(routes)(name), accept: ABBREVIATED });\n\n/** @internal */\nexport const abbreviatedPackument =\n (routes: PackageRoutes) =>\n (\n name: string,\n ): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n HttpClientError.HttpClientError,\n HttpClient.HttpClient\n > =>\n sent(abbreviatedLookup(routes)(name));\n"],"mappings":";;;;;;AAIA,MAAM,aAAa;;AAG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,oBAAoB,cACtB,CAAC;;AAGD,MAAa,gBAAgB,OAAO,GAAG,eAAe,CAAC,CAAC,UAAU,cAAc,MAAc;CAC5F,MAAM,EAAE,OAAO,oBAAoB,OAAO,cAAc,IAAI;CAC5D,MAAM,YAAY,OAAO,cAAc,IAAI;CAC3C,MAAM,QAAQ,OAAO,cAAc,eAAe;CAgBlD,OAAO;EADyB,WAddA,MAAI,OAAO,CAC3B,OACA,GAAG,KACD,WACAA,MAAI,SAAS,EAAE,WACb,KACE,kBAAkB,IAAI,GACtB,OAAO,SAAS,EAAE,WAAW,OAAO,gBAAgB,IAAI,CAAC,GACzD,OAAO,QAAQ,WAAW,GAC1B,OAAO,OACT,CACF,CACF,CACF,CACwC;EAAG,UAAU;EAAiB;CAC1D;AACd,CAAC;;AAGD,MAAa,gBACV,EAAE,iBACF,SACC,OAAO,OAAO,YAAY,IAAI,IAAI,UAAUA,MAAI,SAAS,WAAW,KAAK,CAAC;;AAG9E,MAAa,iBACV,YACA,SAAyB;CACxB,MAAM,OAAOC,OAAI,QAAQ,KAAK,KAAK,CAAC,CAAC,IAAI;CACzC,IAAI,aAAa,MAAM,CAAC,CAAC,IAAI,GAC3B,OAAO,WAAW;EAAE,KAAK,GAAG,OAAO,WAAW;EAAQ,OAAO,OAAO;CAAM,CAAC;CAE7E,OAAO,WAAW;EAAE,KAAK,GAAG,kBAAkB;EAAQ,OAAO,OAAO,KAAK;CAAE,CAAC;AAC9E;AAEF,MAAM,cAAc;;AAGpB,MAAa,qBACV,YACA,UAA0B;CAAE,GAAG,cAAc,MAAM,CAAC,CAAC,IAAI;CAAG,QAAQ;AAAY;;AAGnF,MAAa,wBACV,YAEC,SAMA,KAAK,kBAAkB,MAAM,CAAC,CAAC,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry-releases-Dj6jH8Yt.mjs","names":["Arr","Rec"],"sources":["../src/shared/lib/registry-releases.ts"],"sourcesContent":["import { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\nimport { HttpClientResponse } from \"effect/http\";\nimport type { HttpClient, HttpClientError } from \"effect/http\";\n\nimport { fetched, publicLookup, sent } from \"./lookup.ts\";\nimport { PackageRoutesOf, packageLookup } from \"./package-routes.ts\";\n\nconst CRATES = \"https://crates.io/api/v1/crates/\";\n\nconst DECLARING_SECTIONS = [\"optionalDependencies\", \"peerDependencies\", \"dependencies\"] as const;\nconst Dependencies = Schema.Record(Schema.String, Schema.String);\nconst NpmVersion = Schema.Record(Schema.String, Schema.Unknown);\nconst decodeDependencies = Schema.decodeUnknownOption(Dependencies);\nconst NOT_FOUND = 404;\nconst NOT_PUBLISHED: Release = { versions: [], latestDependencies: {} };\nconst NpmPackument = Schema.Struct({\n \"dist-tags\": Schema.Struct({ latest: Schema.String }),\n versions: Schema.Record(Schema.String, NpmVersion),\n});\nconst Crate = Schema.Struct({\n crate: Schema.Struct({\n max_stable_version: Schema.NullOr(Schema.String),\n newest_version: Schema.String,\n }),\n versions: Schema.Array(Schema.Struct({ num: Schema.String, yanked: Schema.Boolean })),\n});\nconst CrateDependencies = Schema.Struct({\n dependencies: Schema.Array(Schema.Struct({ crate_id: Schema.String, req: Schema.String })),\n});\n\ntype NpmVersionType = typeof NpmVersion.Type;\n\n/** @internal */\nexport type LookupError = HttpClientError.HttpClientError | Schema.SchemaError;\n\n/** @internal */\nexport type Registry = \"npm\" | \"crate\";\n\n/** @internal */\nexport interface Release {\n readonly versions: readonly string[];\n readonly latestDependencies: Readonly<Record<string, string>>;\n}\n\nconst declaredBy = (version: NpmVersionType): Readonly<Record<string, string>> =>\n pipe(\n DECLARING_SECTIONS,\n Arr.flatMap((section) =>\n pipe(\n decodeDependencies(version[section]),\n Option.map(Rec.toEntries),\n Option.getOrElse((): readonly (readonly [string, string])[] => []),\n ),\n ),\n Rec.fromEntries,\n );\n\nconst releaseOfPackument = ({\n \"dist-tags\": tags,\n versions,\n}: typeof NpmPackument.Type): Release => ({\n versions: Rec.keys(versions),\n latestDependencies: pipe(\n Rec.get(versions, tags.latest),\n Option.map(declaredBy),\n Option.getOrElse(() => ({})),\n ),\n});\n\nconst npmRelease = (name: string): Effect.Effect<Release, LookupError, HttpClient.HttpClient> =>\n PackageRoutesOf.pipe(\n Effect.flatMap((routes) => sent(packageLookup(routes)(name))),\n Effect.flatMap((response) => {\n if (response.status === NOT_FOUND) {\n return Effect.succeed(NOT_PUBLISHED);\n }\n return HttpClientResponse.filterStatusOk(response).pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(NpmPackument)),\n Effect.map(releaseOfPackument),\n );\n }),\n );\n\nconst crateRelease = Effect.fn(\"crateRelease\")(function* lookupCrate(name: string) {\n const found = yield* fetched(publicLookup(`${CRATES}${name}`)).pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(Crate)),\n );\n const latest = found.crate.max_stable_version ?? found.crate.newest_version;\n const { dependencies } = yield* fetched(\n publicLookup(`${CRATES}${name}/${latest}/dependencies`),\n ).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(CrateDependencies)));\n const release: Release = {\n versions: pipe(\n found.versions,\n Arr.filter(({ yanked }) => !yanked),\n Arr.map(({ num }) => num),\n ),\n latestDependencies: Rec.fromEntries(\n pipe(\n dependencies,\n Arr.map(({ crate_id: crateId, req }) => [crateId, req] as const),\n ),\n ),\n };\n return release;\n});\n\n/** @internal */\nexport const registryRelease = Effect.fn(\"registryRelease\")(function* registryRelease(\n registry: Registry,\n name: string,\n) {\n if (registry === \"npm\") {\n return yield* npmRelease(name);\n }\n return yield* crateRelease(name);\n});\n"],"mappings":";;;;AAOA,MAAM,SAAS;AAEf,MAAM,qBAAqB;CAAC;CAAwB;CAAoB;AAAc;AACtF,MAAM,eAAe,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM;AAC/D,MAAM,aAAa,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;AAC9D,MAAM,qBAAqB,OAAO,oBAAoB,YAAY;AAClE,MAAM,YAA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D,OAAO,IAAI,kBAAkB,CAC/B;AACF,CAAC,CACH;AAEF,MAAM,eAAe,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,YAAY,MAAc;CACjF,MAAM,QAAQ,OAAO,QAAQ,aAAa,GAAG,SAAS,MAAM,CAAC,CAAC,CAAC,KAC7D,OAAO,QAAQ,mBAAmB,eAAe,KAAK,CAAC,CACzD;CACA,MAAM,SAAS,MAAM,MAAM,sBAAsB,MAAM,MAAM;CAC7D,MAAM,EAAE,iBAAiB,OAAO,QAC9B,aAAa,GAAG,SAAS,KAAK,GAAG,OAAO,cAAc,CACxD,CAAC,CAAC,KAAK,OAAO,QAAQ,mBAAmB,eAAe,iBAAiB,CAAC,CAAC;CAc3E,OAAO;EAZL,UAAU,KACR,MAAM,UACND,MAAI,QAAQ,EAAE,aAAa,CAAC,MAAM,GAClCA,MAAI,KAAK,EAAE,UAAU,GAAG,CAC1B;EACA,oBAAoBC,OAAI,YACtB,KACE,cACAD,MAAI,KAAK,EAAE,UAAU,SAAS,UAAU,CAAC,SAAS,GAAG,CAAU,CACjE,CACF;CAEW;AACf,CAAC;;AAGD,MAAa,kBAAkB,OAAO,GAAG,iBAAiB,CAAC,CAAC,UAAU,gBACpE,UACA,MACA;CACA,IAAI,aAAa,OACf,OAAO,OAAO,WAAW,IAAI;CAE/B,OAAO,OAAO,aAAa,IAAI;AACjC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository-files-B6PEvKWe.mjs","names":["Str","Str","Arr"],"sources":["../../lint-host/src/shared/lib/collections.ts","../src/shared/lib/tool-name.ts","../src/shared/lib/repository-files.ts"],"sourcesContent":["import { Array as Arr, Option, Order, Record as Rec, String as Str, pipe } from \"effect\";\n\nconst byKey = Order.mapInput(Str.Order, ([key]: readonly [string, unknown]) => key);\n\nexport const sortedRecord = <Value>(\n entries: readonly (readonly [string, Value])[],\n): Readonly<Record<string, Value>> => Rec.fromEntries(Arr.sort(entries, byKey));\n\nconst NEXT = 1;\n\nexport interface Grouped<Head, Item> {\n readonly head: Head;\n readonly items: readonly Item[];\n}\n\nexport const groupedUnder =\n <Item, Head>(asHead: (item: Item) => Option.Option<Head>) =>\n (closes: (head: Head, item: Item) => boolean) =>\n (items: readonly Item[]): readonly Grouped<Head, Item>[] =>\n pipe(\n items,\n Arr.flatMap((item, index) =>\n pipe(\n asHead(item),\n Option.map((head): Grouped<Head, Item> => ({\n head,\n items: pipe(\n items,\n Arr.drop(index + NEXT),\n Arr.takeWhile((next) => !closes(head, next)),\n ),\n })),\n Option.toArray,\n ),\n ),\n );\n\nexport const ancestorsBy =\n <Node>(parentOf: (node: Node) => Option.Option<Node>) =>\n (node: Node): readonly Node[] =>\n Arr.unfold(parentOf(node), (current) =>\n pipe(\n current,\n Option.map((found) => [found, parentOf(found)] as const),\n ),\n );\n\nexport const groupOf =\n (name: string) =>\n (found: RegExpMatchArray | null): Option.Option<string> =>\n pipe(\n Option.fromNullishOr(found),\n Option.flatMap((match) => Option.fromNullishOr(match.groups)),\n Option.flatMap((groups) => Option.fromNullishOr(groups[name])),\n );\n","export const TOOL_NAME = \"msch\";\n","import {\n NodeChildProcessSpawner,\n NodeFileSystem,\n NodePath,\n NodeStdio,\n} from \"@effect/platform-node-shared\";\nimport { groupOf } from \"@masseater.dev/lint-host/collections\";\nimport { CACHE_DIRECTORY_NAME } from \"@r_masseater/masseater-utils/plugin-kit\";\nimport {\n Array as Arr,\n Context,\n Effect,\n FileSystem,\n Layer,\n Option,\n Path,\n Stream,\n String as Str,\n pipe,\n} from \"effect\";\nimport { Digest } from \"effect/crypto\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { TOOL_NAME } from \"#/shared/lib/tool-name.ts\";\n\n/** @internal */\nexport const nodeServicesLayer = Layer.provideMerge(\n NodeChildProcessSpawner.layer,\n Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeStdio.layer),\n);\n\nconst MISSING_SIZE = 0;\nconst MILLISECONDS = 1000;\nconst GENERATED_PATHSPEC = \":(attr:linguist-generated)\";\nconst OWNED_PATHSPECS = [\":(exclude,attr:linguist-vendored)\", \":(exclude,attr:linguist-generated)\"];\nexport const NODE_MODULES = \"node_modules\";\n\n/** @internal */\nexport const MSCH_CACHE = [NODE_MODULES, CACHE_DIRECTORY_NAME, TOOL_NAME] as const;\nconst LISTED_ARGS = [\"--cached\", \"--others\", \"--exclude-standard\", `--exclude=${NODE_MODULES}/`];\nconst IGNORED_ARGS = [\"--others\", \"--ignored\", \"--exclude-standard\"];\nconst TRACKED_ARGS = [\"--cached\"];\nconst STAGED_ARGS = [\"--stage\"];\nconst LINK_ENTRY = /^120000 \\S+ \\d+\\t(?<name>.+)$/u;\n\nexport class RepositoryFiles extends Context.Service<\n RepositoryFiles,\n {\n readonly readFile: (file: string) => Effect.Effect<Option.Option<string>>;\n readonly exists: (file: string) => Effect.Effect<boolean>;\n readonly realPath: (file: string) => Effect.Effect<string>;\n readonly readDirectory: (directory: string) => Effect.Effect<readonly string[]>;\n readonly walkDirectory: (directory: string) => Effect.Effect<readonly string[]>;\n readonly writeFile: (file: string, text: string) => Effect.Effect<void>;\n readonly removeFile: (file: string) => Effect.Effect<void>;\n readonly hash: (text: string) => Effect.Effect<string>;\n readonly hashFile: (file: string) => Effect.Effect<Option.Option<string>>;\n readonly generatedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly listedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly ownedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly linkedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly readLink: (file: string) => Effect.Effect<Option.Option<string>>;\n readonly mergeBase: (root: string, revision: string) => Effect.Effect<Option.Option<string>>;\n readonly changedFiles: (root: string, revision: string) => Effect.Effect<readonly string[]>;\n readonly readAtRevision: (\n root: string,\n revision: string,\n name: string,\n ) => Effect.Effect<Option.Option<string>>;\n readonly committedAt: (root: string, name: string) => Effect.Effect<Option.Option<number>>;\n readonly matchingFiles: (\n root: string,\n pathspecs: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly trackedFiles: (\n root: string,\n pathspecs: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly ignoredPaths: (\n root: string,\n paths: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly ignoredFiles: (\n root: string,\n pathspecs: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly isDirectory: (file: string) => Effect.Effect<Option.Option<boolean>>;\n readonly fileSize: (file: string) => Effect.Effect<number>;\n readonly join: (...segments: readonly string[]) => string;\n readonly resolve: (...segments: readonly string[]) => string;\n readonly relative: (from: string, to: string) => string;\n readonly dirname: (file: string) => string;\n readonly basename: (file: string) => string;\n }\n>()(\"@r_masseater/msch/shared/lib/repository-files/RepositoryFiles\") {}\n\nconst SUCCESS = 0;\n\ntype GitText = (root: string, args: readonly string[]) => Effect.Effect<Option.Option<string>>;\n\nconst gitTextService = Effect.gen(function* gitTextService() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const gitText: GitText = (root, args) =>\n Effect.gen(function* readText() {\n const handle = yield* ChildProcess.make(\"git\", args, { cwd: root, stdin: \"ignore\" });\n const text = yield* handle.stdout.pipe(Stream.decodeText(), Stream.mkString);\n const code = yield* handle.exitCode;\n return Option.liftPredicate(text, () => code === SUCCESS);\n }).pipe(\n Effect.scoped,\n Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),\n Effect.orElseSucceed(() => Option.none<string>()),\n );\n return gitText;\n});\n\ntype GitPaths = (\n root: string,\n args: readonly string[],\n separator: string,\n) => Effect.Effect<readonly string[]>;\n\nconst gitPathsService = Effect.gen(function* gitPathsService() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const gitPaths: GitPaths = (root, args, separator) =>\n Effect.gen(function* listPaths() {\n const handle = yield* ChildProcess.make(\"git\", args, {\n cwd: root,\n stdin: \"ignore\",\n });\n const listed = yield* handle.stdout.pipe(Stream.decodeText(), Stream.mkString);\n return pipe(Str.split(listed, separator), Arr.filter(Str.isNonEmpty));\n }).pipe(\n Effect.scoped,\n Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),\n Effect.orElseSucceed((): readonly string[] => []),\n );\n return gitPaths;\n});\n\nconst linkName = (entry: string): readonly string[] =>\n Option.toArray(groupOf(\"name\")(LINK_ENTRY.exec(entry)));\n\ntype CacheOperations = Pick<\n typeof RepositoryFiles.Service,\n \"walkDirectory\" | \"writeFile\" | \"removeFile\" | \"hash\" | \"hashFile\"\n>;\n\nconst encoder = new TextEncoder();\n\nconst cacheOperations = (\n fs: FileSystem.FileSystem,\n path: Path.Path,\n digest: Digest.Digest[\"Service\"],\n): CacheOperations => ({\n walkDirectory: (directory) =>\n fs\n .readDirectory(directory, { recursive: true })\n .pipe(Effect.orElseSucceed((): readonly string[] => [])),\n writeFile: (file, text) =>\n fs\n .makeDirectory(path.dirname(file), { recursive: true })\n .pipe(Effect.andThen(fs.writeFileString(file, text)), Effect.ignore),\n removeFile: (file) => fs.remove(file, { force: true }).pipe(Effect.ignore),\n hash: (text) => digest.digestHex(Digest.sha256, encoder.encode(text)),\n hashFile: (file) =>\n fs.readFile(file).pipe(\n Effect.flatMap((bytes) => digest.digestHex(Digest.sha256, bytes)),\n Effect.option,\n ),\n});\n\nconst gitFiles =\n (gitPaths: GitPaths) =>\n (root: string, args: readonly string[]): Effect.Effect<readonly string[]> =>\n gitPaths(root, [\"ls-files\", \"-z\", ...args], \"\\0\");\n\nconst gitOperations = (\n gitPaths: GitPaths,\n gitText: GitText,\n): Pick<\n RepositoryFiles[\"Service\"],\n | \"changedFiles\"\n | \"committedAt\"\n | \"ignoredFiles\"\n | \"ignoredPaths\"\n | \"linkedFiles\"\n | \"listedFiles\"\n | \"matchingFiles\"\n | \"mergeBase\"\n | \"ownedFiles\"\n | \"readAtRevision\"\n | \"trackedFiles\"\n> => {\n const files = gitFiles(gitPaths);\n return {\n listedFiles: (root) => files(root, LISTED_ARGS),\n ownedFiles: (root) => files(root, [...LISTED_ARGS, \"--\", ...OWNED_PATHSPECS]),\n linkedFiles: (root) => files(root, STAGED_ARGS).pipe(Effect.map(Arr.flatMap(linkName))),\n mergeBase: (root, revision) =>\n gitText(root, [\"merge-base\", \"HEAD\", revision]).pipe(\n Effect.map(Option.map(Str.trim)),\n Effect.map(Option.filter(Str.isNonEmpty)),\n ),\n changedFiles: (root, revision) =>\n gitPaths(root, [\"diff\", \"--name-only\", \"--no-renames\", \"-z\", revision], \"\\0\"),\n readAtRevision: (root, revision, name) => gitText(root, [\"show\", `${revision}:${name}`]),\n committedAt: (root, name) =>\n gitText(root, [\"log\", \"-1\", \"--format=%ct\", \"HEAD\", \"--\", name]).pipe(\n Effect.map(Option.map(Str.trim)),\n Effect.map(Option.filter(Str.isNonEmpty)),\n Effect.map(Option.map((seconds) => Number(seconds) * MILLISECONDS)),\n ),\n matchingFiles: (root, pathspecs) => files(root, [...LISTED_ARGS, \"--\", ...pathspecs]),\n trackedFiles: (root, pathspecs) => files(root, [...TRACKED_ARGS, \"--\", ...pathspecs]),\n ignoredFiles: (root, pathspecs) => files(root, [...IGNORED_ARGS, \"--\", ...pathspecs]),\n ignoredPaths: (root, paths) => gitPaths(root, [\"check-ignore\", \"--\", ...paths], \"\\n\"),\n };\n};\n\nexport const nodeRepositoryFiles = Layer.effect(\n RepositoryFiles,\n Effect.gen(function* nodeRepositoryFiles() {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const digest = yield* Digest.Digest;\n const gitPaths = yield* gitPathsService;\n const gitText = yield* gitTextService;\n return RepositoryFiles.of({\n generatedFiles: (root) =>\n gitFiles(gitPaths)(root, [\"--\", GENERATED_PATHSPEC]).pipe(\n Effect.map(Arr.map((file) => path.join(root, file))),\n ),\n ...gitOperations(gitPaths, gitText),\n readLink: (file) => fs.readLink(file).pipe(Effect.option),\n readFile: (file) => fs.readFileString(file).pipe(Effect.option),\n exists: (file) => fs.exists(file).pipe(Effect.orElseSucceed(() => false)),\n realPath: (file) => fs.realPath(file).pipe(Effect.orElseSucceed(() => file)),\n readDirectory: (directory) =>\n fs.readDirectory(directory).pipe(Effect.orElseSucceed((): readonly string[] => [])),\n ...cacheOperations(fs, path, digest),\n isDirectory: (file) =>\n fs.stat(file).pipe(\n Effect.map((info) => info.type === \"Directory\"),\n Effect.option,\n ),\n fileSize: (file) =>\n fs.stat(file).pipe(\n Effect.map((info) => Number(info.size)),\n Effect.orElseSucceed(() => MISSING_SIZE),\n ),\n join: (...segments) => path.join(...segments),\n resolve: (...segments) => path.resolve(...segments),\n relative: (from, to) => path.relative(from, to),\n dirname: (file) => path.dirname(file),\n basename: (file) => path.basename(file),\n });\n }),\n).pipe(Layer.provide(nodeServicesLayer), Layer.provide(Digest.layerWebCrypto));\n"],"mappings":";;;;;AAEc,MAAM,SAASA,OAAI,QAAQ,CAAC,SAAqC,GAAG;AA6ClF,MAAa,WACV,UACA,UACC,KACE,OAAO,cAAc,KAAK,GAC1B,OAAO,SAAS,UAAU,OAAO,cAAc,MAAM,MAAM,CAAC,GAC5D,OAAO,SAAS,WAAW,OAAO,cAAc,OAAO,KAAK,CAAC,CAC/D;;ACtDJ,MAAa,YAAY;;;AC0BzB,MAAa,oBAAoB,MAAM,aACrC,wBAAwB,OACxB,MAAM,SAAS,eAAe,OAAO,SAAS,OAAO,UAAU,KAAK,CACtE;AAEA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB,CAAC,qCAAqC,oCAAoC;AAClG,MAAa,eAAe;;AAG5B,MAAa,aAAa;CAAC;CAAc;CAAsB;AAAS;AACxE,MAAM,cAAc;CAAC;CAAY;CAAY;CAAsB,aAAa,aAAa;AAAE;AAC/F,MAAM,eAAe;CAAC;CAAY;CAAa;AAAoB;AACnE,MAAM,eAAe,CAAC,UAAU;AAChC,MAAM,cAAc,CAAC,SAAS;AAC9B,MAAM,aAAa;AAEnB,IAAa,kBAAb,cAAqC,QAA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AAC,KAAK,OAAO,MAAM;EAC9D,SAAS,SAAS,GAAG,OAAO,IAAI,CAAC,CAAC,KAAK,OAAO,oBAAoB,KAAK,CAAC;EACxE,WAAW,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,OAAO,oBAAoB,IAAI,CAAC;EAC3E,gBAAgB,cACd,GAAG,cAAc,SAAS,CAAC,CAAC,KAAK,OAAO,oBAAuC,CAAC,CAAC,CAAC;EACpF,GAAG,gBAAgB,IAAI,MAAM,MAAM;EACnC,cAAc,SACZ,GAAG,KAAK,IAAI,CAAC,CAAC,KACZ,OAAO,KAAK,SAAS,KAAK,SAAS,WAAW,GAC9C,OAAO,MACT;EACF,WAAW,SACT,GAAG,KAAK,IAAI,CAAC,CAAC,KACZ,OAAO,KAAK,SAAS,OAAO,KAAK,IAAI,CAAC,GACtC,OAAO,oBAAoB,YAAY,CACzC;EACF,OAAO,GAAG,aAAa,KAAK,KAAK,GAAG,QAAQ;EAC5C,UAAU,GAAG,aAAa,KAAK,QAAQ,GAAG,QAAQ;EAClD,WAAW,MAAM,OAAO,KAAK,SAAS,MAAM,EAAE;EAC9C,UAAU,SAAS,KAAK,QAAQ,IAAI;EACpC,WAAW,SAAS,KAAK,SAAS,IAAI;CACxC,CAAC;AACH,CAAC,CACH,CAAC,CAAC,KAAK,MAAM,QAAQ,iBAAiB,GAAG,MAAM,QAAQ,OAAO,cAAc,CAAC"}
|
package/dist/wake.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
package/dist/wake.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { t as runCli } from "./runtime-C8OGDSk9.mjs";
|
|
3
|
-
import { n as repositoryBroker, t as actionsOidcToken } from "./credential-broker-PkIpsaMh.mjs";
|
|
4
|
-
import { Boolean, Console, Effect, Option, Schema } from "effect";
|
|
5
|
-
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
6
|
-
import { Command } from "effect/cli";
|
|
7
|
-
// src/features/wake-project/model/wake.ts
|
|
8
|
-
const Woken = Schema.Struct({ woken: Schema.Boolean });
|
|
9
|
-
const askBroker = Effect.fn("wake.askBroker")(function* askBroker(broker, oidc) {
|
|
10
|
-
const client = yield* HttpClient.HttpClient;
|
|
11
|
-
const request = HttpClientRequest.post(`${broker.url}wake/main-red`).pipe(HttpClientRequest.bearerToken(oidc));
|
|
12
|
-
const response = yield* HttpClient.filterStatusOk(client).execute(request);
|
|
13
|
-
const { woken } = yield* HttpClientResponse.schemaBodyJson(Woken)(response);
|
|
14
|
-
return yield* Console.log(Boolean.match(woken, {
|
|
15
|
-
onTrue: () => "Asked the project to fix main",
|
|
16
|
-
onFalse: () => "Asked recently: skipped"
|
|
17
|
-
}));
|
|
18
|
-
});
|
|
19
|
-
/** @internal */
|
|
20
|
-
const wakeOnRedMain = Effect.fn("wake.redMain")(function* wakeOnRedMain() {
|
|
21
|
-
const broker = yield* repositoryBroker;
|
|
22
|
-
if (Option.isNone(broker)) return yield* Console.log("msch.broker is false: no credential broker to tell");
|
|
23
|
-
const oidc = yield* actionsOidcToken(broker.value);
|
|
24
|
-
if (Option.isNone(oidc)) return yield* Console.log("Not running in GitHub Actions: nothing to tell the broker");
|
|
25
|
-
return yield* askBroker(broker.value, oidc.value);
|
|
26
|
-
});
|
|
27
|
-
// package.json
|
|
28
|
-
var version = "0.93.0";
|
|
29
|
-
// bin/msch-wake.ts
|
|
30
|
-
const command = Command.make("msch-wake", {}, () => wakeOnRedMain()).pipe(Command.withDescription("Tells the credential broker that this GitHub Actions run failed, so the project gets asked to fix it"));
|
|
31
|
-
runCli("msch-wake")(Command.run(command, { version }));
|
|
32
|
-
export {};
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=wake.mjs.map
|
package/dist/wake.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wake.mjs","names":["Bool","manifest.version"],"sources":["../src/features/wake-project/model/wake.ts","../package.json","../bin/msch-wake.ts"],"sourcesContent":["import { Boolean as Bool, Console, Effect, Option, Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\n\nimport { actionsOidcToken, repositoryBroker } from \"#/shared/lib/credential-broker.ts\";\nimport type { CredentialBroker } from \"#/shared/lib/owner-settings.ts\";\n\nconst Woken = Schema.Struct({ woken: Schema.Boolean });\n\nconst askBroker = Effect.fn(\"wake.askBroker\")(function* askBroker(\n broker: CredentialBroker,\n oidc: string,\n) {\n const client = yield* HttpClient.HttpClient;\n const request = HttpClientRequest.post(`${broker.url}wake/main-red`).pipe(\n HttpClientRequest.bearerToken(oidc),\n );\n const response = yield* HttpClient.filterStatusOk(client).execute(request);\n const { woken } = yield* HttpClientResponse.schemaBodyJson(Woken)(response);\n return yield* Console.log(\n Bool.match(woken, {\n onTrue: () => \"Asked the project to fix main\",\n onFalse: () => \"Asked recently: skipped\",\n }),\n );\n});\n\n/** @internal */\nexport const wakeOnRedMain = Effect.fn(\"wake.redMain\")(function* wakeOnRedMain() {\n const broker = yield* repositoryBroker;\n if (Option.isNone(broker)) {\n return yield* Console.log(\"msch.broker is false: no credential broker to tell\");\n }\n const oidc = yield* actionsOidcToken(broker.value);\n if (Option.isNone(oidc)) {\n return yield* Console.log(\"Not running in GitHub Actions: nothing to tell the broker\");\n }\n return yield* askBroker(broker.value, oidc.value);\n});\n","","#!/usr/bin/env node\nimport { Command } from \"effect/cli\";\n\nimport { runCli } from \"#/app/runtime.ts\";\nimport { wakeOnRedMain } from \"#/features/wake-project/index.ts\";\nimport manifest from \"#package.json\" with { type: \"json\" };\n\nconst command = Command.make(\"msch-wake\", {}, () => wakeOnRedMain()).pipe(\n Command.withDescription(\n \"Tells the credential broker that this GitHub Actions run failed, so the project gets asked to fix it\",\n ),\n);\n\nrunCli(\"msch-wake\")(Command.run(command, { version: manifest.version }));\n"],"mappings":";;;;;;;AAMA,MAAM,QAAQ,OAAO,OAAO,EAAE,OAAO,OAAO,QAAQ,CAAC;AAErD,MAAM,YAAY,OAAO,GAAG,gBAAgB,CAAC,CAAC,UAAU,UACtD,QACA,MACA;CACA,MAAM,SAAS,OAAO,WAAW;CACjC,MAAM,UAAU,kBAAkB,KAAK,GAAG,OAAO,IAAI,cAAc,CAAC,CAAC,KACnE,kBAAkB,YAAY,IAAI,CACpC;CACA,MAAM,WAAW,OAAO,WAAW,eAAe,MAAM,CAAC,CAAC,QAAQ,OAAO;CACzE,MAAM,EAAE,UAAU,OAAO,mBAAmB,eAAe,KAAK,CAAC,CAAC,QAAQ;CAC1E,OAAO,OAAO,QAAQ,IACpBA,QAAK,MAAM,OAAO;EAChB,cAAc;EACd,eAAe;CACjB,CAAC,CACH;AACF,CAAC;;AAGD,MAAa,gBAAgB,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,gBAAgB;CAC/E,MAAM,SAAS,OAAO;CACtB,IAAI,OAAO,OAAO,MAAM,GACtB,OAAO,OAAO,QAAQ,IAAI,oDAAoD;CAEhF,MAAM,OAAO,OAAO,iBAAiB,OAAO,KAAK;CACjD,IAAI,OAAO,OAAO,IAAI,GACpB,OAAO,OAAO,QAAQ,IAAI,2DAA2D;CAEvF,OAAO,OAAO,UAAU,OAAO,OAAO,KAAK,KAAK;AAClD,CAAC;;;;AE9BD,MAAM,UAAU,QAAQ,KAAK,aAAa,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,KACnE,QAAQ,gBACN,sGACF,CACF;AAEA,OAAO,WAAW,CAAC,CAAC,QAAQ,IAAI,SAAS,EAAWC,QAAiB,CAAC,CAAC"}
|