@intentius/chant-lexicon-gitlab 0.0.12 → 0.0.14
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/integrity.json +5 -5
- package/dist/manifest.json +1 -1
- package/package.json +3 -2
- package/src/codegen/docs.ts +28 -82
- package/src/codegen/typecheck.test.ts +24 -0
- package/src/codegen/typecheck.ts +4 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
GitLab CI lexicon for [chant](https://intentius.io/chant/) — declare CI/CD pipelines as typed TypeScript that serializes to `.gitlab-ci.yml`.
|
|
4
4
|
|
|
5
|
-
This package provides typed constructors for all GitLab CI keywords (Jobs, Workflows,
|
|
5
|
+
This package provides typed constructors for all GitLab CI keywords (Jobs, Workflows, Default, and property types like Artifacts, Cache, Image, Rule, Environment, and Trigger), the `CI` pseudo-parameter object for predefined variables, the `reference()` intrinsic for YAML `!reference` tags, and GitLab-specific lint rules. It also includes LSP and MCP server support for editor completions and hover.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install --save-dev @intentius/chant @intentius/chant-lexicon-gitlab
|
package/dist/integrity.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "xxhash64",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "fc31254013f297f8",
|
|
5
5
|
"meta.json": "c663c6c63748a9d0",
|
|
6
6
|
"types/index.d.ts": "64e65524615be023",
|
|
7
7
|
"rules/missing-stage.ts": "6d5379e74209a735",
|
|
8
8
|
"rules/missing-script.ts": "923dde9acb46cc28",
|
|
9
9
|
"rules/deprecated-only-except.ts": "1f5a8c785777fb03",
|
|
10
10
|
"rules/artifact-no-expiry.ts": "26874cb6adfbca26",
|
|
11
|
+
"rules/wgl012.ts": "3d188d13fb2236c0",
|
|
11
12
|
"rules/wgl011.ts": "b6b97e5104d91267",
|
|
12
13
|
"rules/wgl015.ts": "d7e9e080994f985",
|
|
13
|
-
"rules/wgl012.ts": "3d188d13fb2236c0",
|
|
14
|
-
"rules/yaml-helpers.ts": "b5416b80369484f2",
|
|
15
14
|
"rules/wgl010.ts": "1548cad287cdf286",
|
|
16
|
-
"rules/wgl014.ts": "6248a852888e8028",
|
|
17
15
|
"rules/wgl013.ts": "3519c933e23fc605",
|
|
16
|
+
"rules/wgl014.ts": "6248a852888e8028",
|
|
17
|
+
"rules/yaml-helpers.ts": "b5416b80369484f2",
|
|
18
18
|
"skills/chant-gitlab.md": "4393eb63e0b84b7f"
|
|
19
19
|
},
|
|
20
|
-
"composite": "
|
|
20
|
+
"composite": "cb4aab25c84e3aa4"
|
|
21
21
|
}
|
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-gitlab",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": ["src/", "dist/"],
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
"generate": "bun run src/codegen/generate-cli.ts",
|
|
19
19
|
"bundle": "bun run src/package-cli.ts",
|
|
20
20
|
"validate": "bun run src/validate-cli.ts",
|
|
21
|
+
"docs": "bun run src/codegen/docs-cli.ts",
|
|
21
22
|
"prepack": "bun run bundle && bun run validate"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@intentius/chant": "0.0.
|
|
25
|
+
"@intentius/chant": "0.0.13"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"typescript": "^5.9.3"
|
package/src/codegen/docs.ts
CHANGED
|
@@ -30,7 +30,7 @@ npm install --save-dev @intentius/chant-lexicon-gitlab
|
|
|
30
30
|
|
|
31
31
|
{{file:docs-snippets/src/quickstart.ts}}
|
|
32
32
|
|
|
33
|
-
The lexicon provides **3 resources** (Job, Workflow, Default), **
|
|
33
|
+
The lexicon provides **3 resources** (Job, Workflow, Default), **16 property types** (Image, Cache, Artifacts, Rule, Environment, Trigger, Need, Service, and more), the \`CI\` pseudo-parameter object for predefined variables, and the \`reference()\` intrinsic for YAML \`!reference\` tags.
|
|
34
34
|
`;
|
|
35
35
|
|
|
36
36
|
const outputFormat = `The GitLab lexicon serializes resources into **\`.gitlab-ci.yml\` YAML**. Keys are
|
|
@@ -130,7 +130,7 @@ build-app:
|
|
|
130
130
|
|
|
131
131
|
## Resource types
|
|
132
132
|
|
|
133
|
-
The lexicon provides 3 resource types and
|
|
133
|
+
The lexicon provides 3 resource types and 16 property types:
|
|
134
134
|
|
|
135
135
|
### Resources
|
|
136
136
|
|
|
@@ -156,6 +156,10 @@ The lexicon provides 3 resource types and 13 property types:
|
|
|
156
156
|
| \`Parallel\` | Job | Job parallelization (matrix builds) |
|
|
157
157
|
| \`Release\` | Job | GitLab Release creation |
|
|
158
158
|
| \`AutoCancel\` | Workflow | Pipeline auto-cancellation settings |
|
|
159
|
+
| \`Need\` | Job | Job dependency for DAG-mode execution |
|
|
160
|
+
| \`Inherit\` | Job | Controls which global defaults a job inherits |
|
|
161
|
+
| \`Service\` | Job, Default | Sidecar service container (e.g. Docker-in-Docker, databases) |
|
|
162
|
+
| \`WorkflowRule\` | Workflow | Conditional rules for pipeline-level execution |
|
|
159
163
|
|
|
160
164
|
## Shared config
|
|
161
165
|
|
|
@@ -218,7 +222,7 @@ deploy:
|
|
|
218
222
|
when: manual
|
|
219
223
|
\`\`\`
|
|
220
224
|
|
|
221
|
-
The \`
|
|
225
|
+
The \`if\` property maps directly to \`if:\` in the YAML. Use the \`CI\` pseudo-parameter object for type-safe variable references.
|
|
222
226
|
|
|
223
227
|
## Environments
|
|
224
228
|
|
|
@@ -473,23 +477,23 @@ bun test # runs the example's tests
|
|
|
473
477
|
|
|
474
478
|
## Getting Started
|
|
475
479
|
|
|
476
|
-
\`examples/getting-started/\` — a
|
|
480
|
+
\`examples/getting-started/\` — a 2-stage Node.js pipeline with build and test jobs.
|
|
477
481
|
|
|
478
482
|
\`\`\`
|
|
479
483
|
src/
|
|
480
|
-
├── config.ts # Shared config:
|
|
481
|
-
└── pipeline.ts # Job definitions: build, test
|
|
484
|
+
├── config.ts # Shared config: image, cache
|
|
485
|
+
└── pipeline.ts # Job definitions: build, test
|
|
482
486
|
\`\`\`
|
|
483
487
|
|
|
484
488
|
### Shared configuration
|
|
485
489
|
|
|
486
|
-
\`config.ts\` extracts reusable objects —
|
|
490
|
+
\`config.ts\` extracts reusable objects — image and cache — so jobs stay concise:
|
|
487
491
|
|
|
488
492
|
{{file:getting-started/src/config.ts}}
|
|
489
493
|
|
|
490
494
|
### Pipeline jobs
|
|
491
495
|
|
|
492
|
-
\`pipeline.ts\` defines
|
|
496
|
+
\`pipeline.ts\` defines two jobs that import shared config:
|
|
493
497
|
|
|
494
498
|
{{file:getting-started/src/pipeline.ts}}
|
|
495
499
|
|
|
@@ -501,64 +505,45 @@ src/
|
|
|
501
505
|
stages:
|
|
502
506
|
- build
|
|
503
507
|
- test
|
|
504
|
-
- deploy
|
|
505
508
|
|
|
506
509
|
build:
|
|
507
510
|
stage: build
|
|
508
|
-
image:
|
|
511
|
+
image:
|
|
512
|
+
name: node:20-alpine
|
|
509
513
|
cache:
|
|
510
|
-
key: $CI_COMMIT_REF_SLUG
|
|
514
|
+
key: '$CI_COMMIT_REF_SLUG'
|
|
511
515
|
paths:
|
|
512
516
|
- node_modules/
|
|
513
517
|
policy: pull-push
|
|
514
518
|
script:
|
|
515
|
-
- npm
|
|
519
|
+
- npm install
|
|
516
520
|
- npm run build
|
|
517
|
-
artifacts:
|
|
518
|
-
paths:
|
|
519
|
-
- dist/
|
|
520
|
-
expire_in: 1 hour
|
|
521
521
|
|
|
522
522
|
test:
|
|
523
523
|
stage: test
|
|
524
|
-
image:
|
|
524
|
+
image:
|
|
525
|
+
name: node:20-alpine
|
|
525
526
|
cache:
|
|
526
|
-
key: $CI_COMMIT_REF_SLUG
|
|
527
|
+
key: '$CI_COMMIT_REF_SLUG'
|
|
527
528
|
paths:
|
|
528
529
|
- node_modules/
|
|
529
530
|
policy: pull-push
|
|
530
531
|
script:
|
|
531
|
-
- npm
|
|
532
|
+
- npm install
|
|
532
533
|
- npm test
|
|
533
534
|
artifacts:
|
|
534
|
-
paths:
|
|
535
|
-
- coverage/
|
|
536
|
-
expire_in: 1 week
|
|
537
535
|
reports:
|
|
538
536
|
junit: coverage/junit.xml
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
deploy:
|
|
544
|
-
stage: deploy
|
|
545
|
-
image: node:20-alpine
|
|
546
|
-
script:
|
|
547
|
-
- npm run deploy
|
|
548
|
-
environment:
|
|
549
|
-
name: production
|
|
550
|
-
url: https://example.com
|
|
551
|
-
rules:
|
|
552
|
-
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
553
|
-
when: manual
|
|
537
|
+
paths:
|
|
538
|
+
- coverage/
|
|
539
|
+
expire_in: '1 week'
|
|
554
540
|
\`\`\`
|
|
555
541
|
|
|
556
542
|
**Patterns demonstrated:**
|
|
557
543
|
|
|
558
|
-
1. **Shared config** — reusable
|
|
559
|
-
2. **
|
|
560
|
-
3. **
|
|
561
|
-
4. **JUnit reports** — test artifacts include JUnit XML for GitLab MR display
|
|
544
|
+
1. **Shared config** — reusable image and cache extracted into \`config.ts\`
|
|
545
|
+
2. **JUnit reports** — test artifacts include JUnit XML for GitLab MR display
|
|
546
|
+
3. **Stage ordering** — stages collected automatically from job declarations
|
|
562
547
|
|
|
563
548
|
## Docker Build
|
|
564
549
|
|
|
@@ -613,48 +598,9 @@ export const deployInfra = new Job({
|
|
|
613
598
|
|
|
614
599
|
### Service pipeline (API)
|
|
615
600
|
|
|
616
|
-
Builds a Docker image, pushes to ECR, and deploys the API service stack with cross-stack parameter passing
|
|
617
|
-
|
|
618
|
-
\`\`\`typescript
|
|
619
|
-
import { Job, Image, Service, Need, Rule } from "@intentius/chant-lexicon-gitlab";
|
|
620
|
-
import { CI } from "@intentius/chant-lexicon-gitlab";
|
|
621
|
-
|
|
622
|
-
const ECR_URL = "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com";
|
|
623
|
-
const ECR_REPO = "alb-api";
|
|
624
|
-
const fullImage = \\\`\\\${ECR_URL}/\\\${ECR_REPO}\\\`;
|
|
625
|
-
|
|
626
|
-
const dockerImage = new Image({ name: "docker:27-cli" });
|
|
627
|
-
const dind = new Service({ name: "docker:27-dind", alias: "docker" });
|
|
628
|
-
|
|
629
|
-
export const buildImage = new Job({
|
|
630
|
-
stage: "build",
|
|
631
|
-
image: dockerImage,
|
|
632
|
-
services: [dind],
|
|
633
|
-
variables: { DOCKER_TLS_CERTDIR: "/certs" },
|
|
634
|
-
before_script: [
|
|
635
|
-
"apk add --no-cache aws-cli",
|
|
636
|
-
\\\`aws ecr get-login-password | docker login --username AWS --password-stdin \\\${ECR_URL}\\\`,
|
|
637
|
-
],
|
|
638
|
-
script: [
|
|
639
|
-
\\\`docker build -t \\\${fullImage}:\\\${CI.CommitRefSlug} .\\\`,
|
|
640
|
-
\\\`docker push \\\${fullImage}:\\\${CI.CommitRefSlug}\\\`,
|
|
641
|
-
],
|
|
642
|
-
rules: [new Rule({ if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH" })],
|
|
643
|
-
});
|
|
601
|
+
Builds a Docker image, pushes to ECR, and deploys the API service stack with cross-stack parameter passing. The full source lives in the cross-lexicon example \`examples/gitlab-aws-alb-api/\`:
|
|
644
602
|
|
|
645
|
-
|
|
646
|
-
stage: "deploy",
|
|
647
|
-
image: new Image({ name: "amazon/aws-cli:latest" }),
|
|
648
|
-
needs: [new Need({ job: "build-image" })],
|
|
649
|
-
script: [
|
|
650
|
-
// Fetch shared ALB outputs and map to CF parameter overrides
|
|
651
|
-
"OUTPUTS=$(aws cloudformation describe-stacks --stack-name shared-alb --query 'Stacks[0].Outputs' --output json)",
|
|
652
|
-
'PARAMS=$(echo "$OUTPUTS" | jq -r \\'[...output-to-param mapping...] | join(" ")\\')',
|
|
653
|
-
"aws cloudformation deploy --template-file templates/template.json --stack-name shared-alb-api --capabilities CAPABILITY_IAM --no-fail-on-empty-changeset --parameter-overrides $PARAMS",
|
|
654
|
-
],
|
|
655
|
-
rules: [new Rule({ if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH" })],
|
|
656
|
-
});
|
|
657
|
-
\`\`\`
|
|
603
|
+
{{file:../../../examples/gitlab-aws-alb-api/src/pipeline.ts}}
|
|
658
604
|
|
|
659
605
|
**Key patterns:**
|
|
660
606
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, test, expect } from "bun:test";
|
|
2
|
+
import { typecheckDTS } from "./typecheck";
|
|
3
|
+
|
|
4
|
+
describe("typecheckDTS", () => {
|
|
5
|
+
test("passes valid .d.ts content", async () => {
|
|
6
|
+
const result = await typecheckDTS("export declare class Foo { bar: string; }");
|
|
7
|
+
expect(result.ok).toBe(true);
|
|
8
|
+
expect(result.diagnostics).toHaveLength(0);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("fails on syntax errors", async () => {
|
|
12
|
+
const result = await typecheckDTS("export declare class { }"); // missing class name
|
|
13
|
+
expect(result.ok).toBe(false);
|
|
14
|
+
expect(result.diagnostics.length).toBeGreaterThan(0);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("fails on undefined type references", async () => {
|
|
18
|
+
const result = await typecheckDTS(
|
|
19
|
+
"export declare class Foo { bar: UndefinedType; }",
|
|
20
|
+
);
|
|
21
|
+
expect(result.ok).toBe(false);
|
|
22
|
+
expect(result.diagnostics.length).toBeGreaterThan(0);
|
|
23
|
+
});
|
|
24
|
+
});
|