@intentius/chant-lexicon-github 0.0.18
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/integrity.json +31 -0
- package/dist/manifest.json +15 -0
- package/dist/meta.json +135 -0
- package/dist/rules/deprecated-action-version.ts +49 -0
- package/dist/rules/detect-secrets.ts +53 -0
- package/dist/rules/extract-inline-structs.ts +62 -0
- package/dist/rules/file-job-limit.ts +49 -0
- package/dist/rules/gha006.ts +58 -0
- package/dist/rules/gha009.ts +42 -0
- package/dist/rules/gha011.ts +40 -0
- package/dist/rules/gha017.ts +32 -0
- package/dist/rules/gha018.ts +40 -0
- package/dist/rules/gha019.ts +72 -0
- package/dist/rules/job-timeout.ts +59 -0
- package/dist/rules/missing-recommended-inputs.ts +61 -0
- package/dist/rules/no-hardcoded-secrets.ts +46 -0
- package/dist/rules/no-raw-expressions.ts +51 -0
- package/dist/rules/suggest-cache.ts +71 -0
- package/dist/rules/use-condition-builders.ts +45 -0
- package/dist/rules/use-matrix-builder.ts +44 -0
- package/dist/rules/use-typed-actions.ts +47 -0
- package/dist/rules/validate-concurrency.ts +66 -0
- package/dist/rules/yaml-helpers.ts +129 -0
- package/dist/skills/chant-github.md +29 -0
- package/dist/skills/github-actions-patterns.md +93 -0
- package/dist/types/index.d.ts +358 -0
- package/package.json +33 -0
- package/src/codegen/docs-cli.ts +3 -0
- package/src/codegen/docs.ts +1138 -0
- package/src/codegen/generate-cli.ts +36 -0
- package/src/codegen/generate-lexicon.ts +58 -0
- package/src/codegen/generate-typescript.ts +149 -0
- package/src/codegen/generate.ts +141 -0
- package/src/codegen/naming.ts +57 -0
- package/src/codegen/package.ts +65 -0
- package/src/codegen/parse.ts +700 -0
- package/src/codegen/patches.ts +46 -0
- package/src/composites/cache.ts +25 -0
- package/src/composites/checkout.ts +31 -0
- package/src/composites/composites.test.ts +675 -0
- package/src/composites/deploy-environment.ts +77 -0
- package/src/composites/docker-build.ts +120 -0
- package/src/composites/download-artifact.ts +24 -0
- package/src/composites/go-ci.ts +91 -0
- package/src/composites/index.ts +26 -0
- package/src/composites/node-ci.ts +71 -0
- package/src/composites/node-pipeline.ts +151 -0
- package/src/composites/python-ci.ts +92 -0
- package/src/composites/setup-go.ts +24 -0
- package/src/composites/setup-node.ts +26 -0
- package/src/composites/setup-python.ts +24 -0
- package/src/composites/upload-artifact.ts +27 -0
- package/src/coverage.ts +49 -0
- package/src/expression.test.ts +147 -0
- package/src/expression.ts +214 -0
- package/src/generated/index.d.ts +358 -0
- package/src/generated/index.ts +29 -0
- package/src/generated/lexicon-github.json +135 -0
- package/src/generated/runtime.ts +4 -0
- package/src/import/generator.test.ts +110 -0
- package/src/import/generator.ts +119 -0
- package/src/import/parser.test.ts +98 -0
- package/src/import/parser.ts +73 -0
- package/src/index.ts +53 -0
- package/src/lint/post-synth/gha006.ts +58 -0
- package/src/lint/post-synth/gha009.ts +42 -0
- package/src/lint/post-synth/gha011.ts +40 -0
- package/src/lint/post-synth/gha017.ts +32 -0
- package/src/lint/post-synth/gha018.ts +40 -0
- package/src/lint/post-synth/gha019.ts +72 -0
- package/src/lint/post-synth/post-synth.test.ts +318 -0
- package/src/lint/post-synth/yaml-helpers.ts +129 -0
- package/src/lint/rules/data/deprecated-versions.ts +13 -0
- package/src/lint/rules/data/known-actions.ts +13 -0
- package/src/lint/rules/data/recommended-inputs.ts +10 -0
- package/src/lint/rules/data/secret-patterns.ts +31 -0
- package/src/lint/rules/deprecated-action-version.ts +49 -0
- package/src/lint/rules/detect-secrets.ts +53 -0
- package/src/lint/rules/extract-inline-structs.ts +62 -0
- package/src/lint/rules/file-job-limit.ts +49 -0
- package/src/lint/rules/index.ts +17 -0
- package/src/lint/rules/job-timeout.ts +59 -0
- package/src/lint/rules/missing-recommended-inputs.ts +61 -0
- package/src/lint/rules/no-hardcoded-secrets.ts +46 -0
- package/src/lint/rules/no-raw-expressions.ts +51 -0
- package/src/lint/rules/rules.test.ts +365 -0
- package/src/lint/rules/suggest-cache.ts +71 -0
- package/src/lint/rules/use-condition-builders.ts +45 -0
- package/src/lint/rules/use-matrix-builder.ts +44 -0
- package/src/lint/rules/use-typed-actions.ts +47 -0
- package/src/lint/rules/validate-concurrency.ts +66 -0
- package/src/lsp/completions.test.ts +9 -0
- package/src/lsp/completions.ts +20 -0
- package/src/lsp/hover.test.ts +9 -0
- package/src/lsp/hover.ts +38 -0
- package/src/package-cli.ts +42 -0
- package/src/plugin.test.ts +128 -0
- package/src/plugin.ts +408 -0
- package/src/serializer.test.ts +270 -0
- package/src/serializer.ts +383 -0
- package/src/skills/github-actions-patterns.md +93 -0
- package/src/spec/fetch.ts +55 -0
- package/src/validate-cli.ts +19 -0
- package/src/validate.test.ts +12 -0
- package/src/validate.ts +32 -0
- package/src/variables.ts +44 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* CLI entry point for GitHub Actions lexicon generation.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { dirname } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { generate, writeGeneratedFiles } from "./generate";
|
|
9
|
+
|
|
10
|
+
const pkgDir = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
const verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
|
|
14
|
+
const force = process.argv.includes("--force") || process.argv.includes("-f");
|
|
15
|
+
|
|
16
|
+
console.error("Generating GitHub Actions lexicon...");
|
|
17
|
+
|
|
18
|
+
const result = await generate({ verbose, force });
|
|
19
|
+
writeGeneratedFiles(result, pkgDir);
|
|
20
|
+
|
|
21
|
+
console.error(
|
|
22
|
+
`Generated ${result.resources} entities, ${result.properties} property types, ${result.enums} enums`,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (result.warnings.length > 0) {
|
|
26
|
+
console.error(`${result.warnings.length} warnings:`);
|
|
27
|
+
for (const w of result.warnings) {
|
|
28
|
+
console.error(` ${w.file}: ${w.error}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main().catch((err) => {
|
|
34
|
+
console.error("Generation failed:", err);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lexicon JSON generator — produces lexicon-github.json with metadata
|
|
3
|
+
* for all GitHub Actions entities.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { PropertyConstraints } from "@intentius/chant/codegen/json-schema";
|
|
7
|
+
import type { GitHubParseResult } from "./parse";
|
|
8
|
+
import { githubShortName } from "./parse";
|
|
9
|
+
import type { NamingStrategy } from "./naming";
|
|
10
|
+
import {
|
|
11
|
+
buildRegistry,
|
|
12
|
+
serializeRegistry,
|
|
13
|
+
type RegistryResource,
|
|
14
|
+
} from "@intentius/chant/codegen/generate-registry";
|
|
15
|
+
|
|
16
|
+
export interface LexiconEntry {
|
|
17
|
+
resourceType: string;
|
|
18
|
+
kind: "resource" | "property";
|
|
19
|
+
lexicon: "github";
|
|
20
|
+
deprecatedProperties?: string[];
|
|
21
|
+
constraints?: Record<string, PropertyConstraints>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Generate the lexicon-github.json content.
|
|
26
|
+
*/
|
|
27
|
+
export function generateLexiconJSON(
|
|
28
|
+
results: GitHubParseResult[],
|
|
29
|
+
naming: NamingStrategy,
|
|
30
|
+
): string {
|
|
31
|
+
const registryResources: RegistryResource[] = results.map((r) => ({
|
|
32
|
+
typeName: r.resource.typeName,
|
|
33
|
+
attributes: r.resource.attributes,
|
|
34
|
+
properties: r.resource.properties,
|
|
35
|
+
propertyTypes: r.propertyTypes.map((pt) => ({ name: pt.name, specType: pt.defType })),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const entries = buildRegistry<LexiconEntry>(registryResources, naming, {
|
|
39
|
+
shortName: githubShortName,
|
|
40
|
+
buildEntry: (resource, _tsName, _attrs, propConstraints) => {
|
|
41
|
+
const r = results.find((res) => res.resource.typeName === resource.typeName);
|
|
42
|
+
return {
|
|
43
|
+
resourceType: resource.typeName,
|
|
44
|
+
kind: (r?.isProperty ? "property" : "resource") as "resource" | "property",
|
|
45
|
+
lexicon: "github" as const,
|
|
46
|
+
...(r?.resource.deprecatedProperties?.length && { deprecatedProperties: r.resource.deprecatedProperties }),
|
|
47
|
+
...(propConstraints && Object.keys(propConstraints).length > 0 && { constraints: propConstraints }),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
buildPropertyEntry: (resourceType, propertyType) => ({
|
|
51
|
+
resourceType: `${resourceType}.${propertyType}`,
|
|
52
|
+
kind: "property" as const,
|
|
53
|
+
lexicon: "github" as const,
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return serializeRegistry(entries);
|
|
58
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript declaration file generator — produces index.d.ts with all
|
|
3
|
+
* GitHub Actions entity classes.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { GitHubParseResult } from "./parse";
|
|
7
|
+
import { githubShortName } from "./parse";
|
|
8
|
+
import type { NamingStrategy } from "./naming";
|
|
9
|
+
import { propertyTypeName, extractDefName } from "./naming";
|
|
10
|
+
import {
|
|
11
|
+
writeResourceClass,
|
|
12
|
+
writePropertyClass,
|
|
13
|
+
writeEnumType,
|
|
14
|
+
type DtsProperty,
|
|
15
|
+
type DtsAttribute,
|
|
16
|
+
} from "@intentius/chant/codegen/generate-typescript";
|
|
17
|
+
|
|
18
|
+
interface ResourceEntry {
|
|
19
|
+
tsName: string;
|
|
20
|
+
properties: DtsProperty[];
|
|
21
|
+
attributes: DtsAttribute[];
|
|
22
|
+
remap: Map<string, string>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface EnumEntry {
|
|
26
|
+
tsName: string;
|
|
27
|
+
values: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generate the complete .d.ts file content.
|
|
32
|
+
*/
|
|
33
|
+
export function generateTypeScriptDeclarations(
|
|
34
|
+
results: GitHubParseResult[],
|
|
35
|
+
naming: NamingStrategy,
|
|
36
|
+
): string {
|
|
37
|
+
const lines: string[] = [];
|
|
38
|
+
lines.push("// Code generated by chant github generate. DO NOT EDIT.");
|
|
39
|
+
|
|
40
|
+
const resources: ResourceEntry[] = [];
|
|
41
|
+
const enums: EnumEntry[] = [];
|
|
42
|
+
|
|
43
|
+
for (const r of results) {
|
|
44
|
+
const typeName = r.resource.typeName;
|
|
45
|
+
const tsName = naming.resolve(typeName);
|
|
46
|
+
if (!tsName) continue;
|
|
47
|
+
|
|
48
|
+
const shortName = githubShortName(typeName);
|
|
49
|
+
const remap = new Map<string, string>();
|
|
50
|
+
for (const pt of r.propertyTypes) {
|
|
51
|
+
const defName = extractDefName(pt.name, shortName);
|
|
52
|
+
remap.set(pt.name, propertyTypeName(tsName, defName));
|
|
53
|
+
}
|
|
54
|
+
for (const e of r.enums) {
|
|
55
|
+
const defName = extractDefName(e.name, shortName);
|
|
56
|
+
remap.set(e.name, propertyTypeName(tsName, defName));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const dtsProps: DtsProperty[] = r.resource.properties.map((p) => ({
|
|
60
|
+
name: p.name,
|
|
61
|
+
type: p.tsType,
|
|
62
|
+
required: p.required,
|
|
63
|
+
description: p.description,
|
|
64
|
+
}));
|
|
65
|
+
const dtsAttrs: DtsAttribute[] = r.resource.attributes.map((a) => ({
|
|
66
|
+
name: a.name,
|
|
67
|
+
type: a.tsType,
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
resources.push({ tsName, properties: dtsProps, attributes: dtsAttrs, remap });
|
|
71
|
+
|
|
72
|
+
for (const alias of naming.aliases(typeName)) {
|
|
73
|
+
resources.push({ tsName: alias, properties: dtsProps, attributes: dtsAttrs, remap });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for (const e of r.enums) {
|
|
77
|
+
const defName = extractDefName(e.name, shortName);
|
|
78
|
+
const eName = propertyTypeName(tsName, defName);
|
|
79
|
+
enums.push({ tsName: eName, values: e.values });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
resources.sort((a, b) => a.tsName.localeCompare(b.tsName));
|
|
84
|
+
enums.sort((a, b) => a.tsName.localeCompare(b.tsName));
|
|
85
|
+
|
|
86
|
+
lines.push("");
|
|
87
|
+
lines.push("// --- GitHub Actions Entity classes ---");
|
|
88
|
+
for (const re of resources) {
|
|
89
|
+
writeResourceClass(lines, re.tsName, re.properties, re.attributes, re.remap);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (enums.length > 0) {
|
|
93
|
+
lines.push("");
|
|
94
|
+
lines.push("// --- Enum types ---");
|
|
95
|
+
for (const ee of enums) {
|
|
96
|
+
writeEnumType(lines, ee.tsName, ee.values);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
lines.push("");
|
|
101
|
+
lines.push(staticTypeScript());
|
|
102
|
+
lines.push("");
|
|
103
|
+
|
|
104
|
+
return lines.join("\n");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function staticTypeScript(): string {
|
|
108
|
+
const lines: string[] = [];
|
|
109
|
+
|
|
110
|
+
// Inline Expression interface so dist/types/index.d.ts is self-contained
|
|
111
|
+
lines.push("// --- Expression type (inlined for portability) ---");
|
|
112
|
+
lines.push("");
|
|
113
|
+
lines.push("export declare class Expression {");
|
|
114
|
+
lines.push(" constructor(raw: string);");
|
|
115
|
+
lines.push(" toString(): string;");
|
|
116
|
+
lines.push(" valueOf(): string;");
|
|
117
|
+
lines.push(" eq(value: string | Expression): Expression;");
|
|
118
|
+
lines.push(" ne(value: string | Expression): Expression;");
|
|
119
|
+
lines.push(" and(other: Expression): Expression;");
|
|
120
|
+
lines.push(" or(other: Expression): Expression;");
|
|
121
|
+
lines.push(" not(): Expression;");
|
|
122
|
+
lines.push("}");
|
|
123
|
+
|
|
124
|
+
lines.push("");
|
|
125
|
+
lines.push("// --- GitHub Context Variables ---");
|
|
126
|
+
lines.push("");
|
|
127
|
+
lines.push("export declare const GitHub: {");
|
|
128
|
+
const ghVars = [
|
|
129
|
+
"Ref", "RefName", "RefType", "Sha", "Actor", "TriggeringActor",
|
|
130
|
+
"Repository", "RepositoryOwner", "EventName", "Event",
|
|
131
|
+
"RunId", "RunNumber", "RunAttempt", "Workflow", "WorkflowRef",
|
|
132
|
+
"Workspace", "Token", "Job", "HeadRef", "BaseRef",
|
|
133
|
+
"ServerUrl", "ApiUrl", "GraphqlUrl", "Action", "ActionPath",
|
|
134
|
+
];
|
|
135
|
+
for (const v of ghVars) {
|
|
136
|
+
lines.push(` readonly ${v}: Expression;`);
|
|
137
|
+
}
|
|
138
|
+
lines.push("};");
|
|
139
|
+
|
|
140
|
+
lines.push("");
|
|
141
|
+
lines.push("export declare const Runner: {");
|
|
142
|
+
const runnerVars = ["Os", "Arch", "Name", "Temp", "ToolCache"];
|
|
143
|
+
for (const v of runnerVars) {
|
|
144
|
+
lines.push(` readonly ${v}: Expression;`);
|
|
145
|
+
}
|
|
146
|
+
lines.push("};");
|
|
147
|
+
|
|
148
|
+
return lines.join("\n");
|
|
149
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Actions generation pipeline — uses core generatePipeline
|
|
3
|
+
* with GitHub-specific fetch, parse, naming, and generation callbacks.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
generatePipeline,
|
|
8
|
+
writeGeneratedArtifacts,
|
|
9
|
+
type GenerateOptions,
|
|
10
|
+
type GenerateResult,
|
|
11
|
+
type GeneratePipelineConfig,
|
|
12
|
+
} from "@intentius/chant/codegen/generate";
|
|
13
|
+
import { fetchSchemas } from "../spec/fetch";
|
|
14
|
+
import { parseWorkflowSchema, type GitHubParseResult } from "./parse";
|
|
15
|
+
import { NamingStrategy, propertyTypeName, extractDefName } from "./naming";
|
|
16
|
+
import { githubShortName } from "./parse";
|
|
17
|
+
import { generateLexiconJSON } from "./generate-lexicon";
|
|
18
|
+
import { generateTypeScriptDeclarations } from "./generate-typescript";
|
|
19
|
+
import {
|
|
20
|
+
generateRuntimeIndex as coreGenerateRuntimeIndex,
|
|
21
|
+
type RuntimeIndexEntry,
|
|
22
|
+
type RuntimeIndexPropertyEntry,
|
|
23
|
+
} from "@intentius/chant/codegen/generate-runtime-index";
|
|
24
|
+
|
|
25
|
+
export type { GenerateResult };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Run the full GitHub Actions generation pipeline.
|
|
29
|
+
*/
|
|
30
|
+
export async function generate(opts: GenerateOptions = {}): Promise<GenerateResult> {
|
|
31
|
+
let pendingResults: GitHubParseResult[] = [];
|
|
32
|
+
|
|
33
|
+
const config: GeneratePipelineConfig<GitHubParseResult> = {
|
|
34
|
+
fetchSchemas: async (fetchOpts) => {
|
|
35
|
+
return fetchSchemas(fetchOpts.force);
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
parseSchema: (_typeName, data) => {
|
|
39
|
+
const results = parseWorkflowSchema(data);
|
|
40
|
+
if (results.length === 0) return null;
|
|
41
|
+
pendingResults = results.slice(1);
|
|
42
|
+
return results[0];
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
createNaming: (results) => new NamingStrategy(results),
|
|
46
|
+
|
|
47
|
+
augmentResults: (results, _opts, log) => {
|
|
48
|
+
if (pendingResults.length > 0) {
|
|
49
|
+
results.push(...pendingResults);
|
|
50
|
+
log(`Added ${pendingResults.length} additional entities from single schema`);
|
|
51
|
+
pendingResults = [];
|
|
52
|
+
}
|
|
53
|
+
log(`Total: ${results.length} GitHub Actions entity schemas`);
|
|
54
|
+
return { results };
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
generateRegistry: (results, naming) => {
|
|
58
|
+
return generateLexiconJSON(results, naming as NamingStrategy);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
generateTypes: (results, naming) => {
|
|
62
|
+
return generateTypeScriptDeclarations(results, naming as NamingStrategy);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
generateRuntimeIndex: (results, naming) => {
|
|
66
|
+
return generateRuntimeIndex(results, naming as NamingStrategy);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return generatePipeline(config, opts);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Write generated artifacts to disk.
|
|
75
|
+
*/
|
|
76
|
+
export function writeGeneratedFiles(result: GenerateResult, baseDir: string): void {
|
|
77
|
+
writeGeneratedArtifacts({
|
|
78
|
+
baseDir,
|
|
79
|
+
files: {
|
|
80
|
+
"lexicon-github.json": result.lexiconJSON,
|
|
81
|
+
"index.d.ts": result.typesDTS,
|
|
82
|
+
"index.ts": result.indexTS,
|
|
83
|
+
"runtime.ts": `/**\n * Runtime factory constructors — re-exported from core.\n */\nexport { createResource, createProperty } from "@intentius/chant/runtime";\n`,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Generate the runtime index.ts with factory constructor exports.
|
|
90
|
+
*/
|
|
91
|
+
function generateRuntimeIndex(
|
|
92
|
+
results: GitHubParseResult[],
|
|
93
|
+
naming: NamingStrategy,
|
|
94
|
+
): string {
|
|
95
|
+
const resourceEntries: RuntimeIndexEntry[] = [];
|
|
96
|
+
const propertyEntries: RuntimeIndexPropertyEntry[] = [];
|
|
97
|
+
|
|
98
|
+
for (const r of results) {
|
|
99
|
+
const typeName = r.resource.typeName;
|
|
100
|
+
const tsName = naming.resolve(typeName);
|
|
101
|
+
if (!tsName) continue;
|
|
102
|
+
|
|
103
|
+
const attrs: Record<string, string> = {};
|
|
104
|
+
|
|
105
|
+
if (r.isProperty) {
|
|
106
|
+
propertyEntries.push({ tsName, resourceType: typeName });
|
|
107
|
+
for (const alias of naming.aliases(typeName)) {
|
|
108
|
+
propertyEntries.push({ tsName: alias, resourceType: typeName });
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
resourceEntries.push({ tsName, resourceType: typeName, attrs });
|
|
112
|
+
for (const alias of naming.aliases(typeName)) {
|
|
113
|
+
resourceEntries.push({ tsName: alias, resourceType: typeName, attrs });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const shortName = githubShortName(typeName);
|
|
118
|
+
const ptAliases = naming.propertyTypeAliases(typeName);
|
|
119
|
+
for (const pt of r.propertyTypes) {
|
|
120
|
+
const defName = extractDefName(pt.name, shortName);
|
|
121
|
+
const ptName = propertyTypeName(tsName, defName);
|
|
122
|
+
const ptType = `${typeName}.${pt.defType}`;
|
|
123
|
+
propertyEntries.push({ tsName: ptName, resourceType: ptType });
|
|
124
|
+
|
|
125
|
+
if (ptAliases) {
|
|
126
|
+
const aliasName = ptAliases.get(defName);
|
|
127
|
+
if (aliasName) {
|
|
128
|
+
propertyEntries.push({ tsName: aliasName, resourceType: ptType });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return coreGenerateRuntimeIndex(resourceEntries, propertyEntries, {
|
|
135
|
+
lexiconName: "github",
|
|
136
|
+
pseudoReExports: {
|
|
137
|
+
names: ["GitHub", "Runner"],
|
|
138
|
+
from: "../variables",
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Actions naming strategy — flat namespace with few collisions.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
NamingStrategy as CoreNamingStrategy,
|
|
7
|
+
type NamingConfig,
|
|
8
|
+
type NamingInput,
|
|
9
|
+
} from "@intentius/chant/codegen/naming";
|
|
10
|
+
import { githubShortName, githubServiceName, type GitHubParseResult } from "./parse";
|
|
11
|
+
|
|
12
|
+
export { propertyTypeName, extractDefName } from "@intentius/chant/codegen/naming";
|
|
13
|
+
|
|
14
|
+
const githubNamingConfig: NamingConfig = {
|
|
15
|
+
priorityNames: {
|
|
16
|
+
"GitHub::Actions::Workflow": "Workflow",
|
|
17
|
+
"GitHub::Actions::Job": "Job",
|
|
18
|
+
"GitHub::Actions::ReusableWorkflowCallJob": "ReusableWorkflowCallJob",
|
|
19
|
+
"GitHub::Actions::Step": "Step",
|
|
20
|
+
"GitHub::Actions::Strategy": "Strategy",
|
|
21
|
+
"GitHub::Actions::Permissions": "Permissions",
|
|
22
|
+
"GitHub::Actions::Concurrency": "Concurrency",
|
|
23
|
+
"GitHub::Actions::Container": "Container",
|
|
24
|
+
"GitHub::Actions::Service": "Service",
|
|
25
|
+
"GitHub::Actions::Environment": "Environment",
|
|
26
|
+
"GitHub::Actions::Defaults": "Defaults",
|
|
27
|
+
"GitHub::Actions::PushTrigger": "PushTrigger",
|
|
28
|
+
"GitHub::Actions::PullRequestTrigger": "PullRequestTrigger",
|
|
29
|
+
"GitHub::Actions::PullRequestTargetTrigger": "PullRequestTargetTrigger",
|
|
30
|
+
"GitHub::Actions::ScheduleTrigger": "ScheduleTrigger",
|
|
31
|
+
"GitHub::Actions::WorkflowDispatchTrigger": "WorkflowDispatchTrigger",
|
|
32
|
+
"GitHub::Actions::WorkflowCallTrigger": "WorkflowCallTrigger",
|
|
33
|
+
"GitHub::Actions::WorkflowRunTrigger": "WorkflowRunTrigger",
|
|
34
|
+
"GitHub::Actions::RepositoryDispatchTrigger": "RepositoryDispatchTrigger",
|
|
35
|
+
"GitHub::Actions::WorkflowInput": "WorkflowInput",
|
|
36
|
+
"GitHub::Actions::WorkflowOutput": "WorkflowOutput",
|
|
37
|
+
"GitHub::Actions::WorkflowSecret": "WorkflowSecret",
|
|
38
|
+
},
|
|
39
|
+
priorityAliases: {},
|
|
40
|
+
priorityPropertyAliases: {},
|
|
41
|
+
serviceAbbreviations: {},
|
|
42
|
+
shortName: githubShortName,
|
|
43
|
+
serviceName: githubServiceName,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* GitHub Actions naming strategy.
|
|
48
|
+
*/
|
|
49
|
+
export class NamingStrategy extends CoreNamingStrategy {
|
|
50
|
+
constructor(results: GitHubParseResult[]) {
|
|
51
|
+
const inputs: NamingInput[] = results.map((r) => ({
|
|
52
|
+
typeName: r.resource.typeName,
|
|
53
|
+
propertyTypes: r.propertyTypes,
|
|
54
|
+
}));
|
|
55
|
+
super(inputs, githubNamingConfig);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Actions lexicon packaging — delegates to core packagePipeline.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
import { readFileSync } from "fs";
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
import { join, dirname } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
import type { IntrinsicDef } from "@intentius/chant/lexicon";
|
|
11
|
+
import {
|
|
12
|
+
packagePipeline,
|
|
13
|
+
collectSkills,
|
|
14
|
+
type PackageOptions,
|
|
15
|
+
type PackageResult,
|
|
16
|
+
} from "@intentius/chant/codegen/package";
|
|
17
|
+
import { generate } from "./generate";
|
|
18
|
+
|
|
19
|
+
export type { PackageOptions, PackageResult };
|
|
20
|
+
|
|
21
|
+
const pkgDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Package the GitHub Actions lexicon into a distributable BundleSpec.
|
|
25
|
+
*/
|
|
26
|
+
export async function packageLexicon(opts: PackageOptions = {}): Promise<PackageResult> {
|
|
27
|
+
const pkgJson = JSON.parse(readFileSync(join(pkgDir, "..", "package.json"), "utf-8"));
|
|
28
|
+
|
|
29
|
+
return packagePipeline(
|
|
30
|
+
{
|
|
31
|
+
generate: (genOpts) => generate({ verbose: genOpts.verbose, force: genOpts.force }),
|
|
32
|
+
|
|
33
|
+
buildManifest: (_genResult) => {
|
|
34
|
+
const intrinsics: IntrinsicDef[] = [
|
|
35
|
+
{
|
|
36
|
+
name: "expression",
|
|
37
|
+
description: "${{ }} expression wrapper for GitHub Actions contexts",
|
|
38
|
+
outputKey: "expression",
|
|
39
|
+
isTag: false,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
name: "github",
|
|
45
|
+
version: pkgJson.version ?? "0.0.0",
|
|
46
|
+
chantVersion: ">=0.1.0",
|
|
47
|
+
namespace: "GitHub",
|
|
48
|
+
intrinsics,
|
|
49
|
+
pseudoParameters: {},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
srcDir: pkgDir,
|
|
54
|
+
|
|
55
|
+
collectSkills: () => {
|
|
56
|
+
const { githubPlugin } = require("../plugin");
|
|
57
|
+
const skillDefs = githubPlugin.skills?.() ?? [];
|
|
58
|
+
return collectSkills(skillDefs);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
version: pkgJson.version ?? "0.0.0",
|
|
62
|
+
},
|
|
63
|
+
opts,
|
|
64
|
+
);
|
|
65
|
+
}
|