Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/index.wac.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createWorkflow, NormalJob } from "../../src";
import { createWorkflow, NormalJob } from "../../src/index.js";

const defaultEnv = {
NODE_OPTIONS: "--max_old_space_size=4096"
Expand All @@ -9,9 +9,9 @@ const checkoutInstallBuildTest: NormalJob["steps"] = [
uses: "actions/setup-node@v2",
with: { "node-version": 14 }
},
{ uses: "actions/checkout@v2" },
{ uses: "actions/checkout@v4" },
{
uses: "actions/cache@v2",
uses: "actions/cache@v4",
with: {
path: ".yarn/cache",
key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}"
Expand All @@ -24,7 +24,11 @@ const checkoutInstallBuildTest: NormalJob["steps"] = [

export const push = createWorkflow({
name: "Push to main branch",
on: "push",
on: {
push: {
branches: ["main"]
}
},
env: defaultEnv,
jobs: {
buildTestRelease: {
Expand All @@ -48,7 +52,7 @@ export const push = createWorkflow({
});

export const pullRequests = createWorkflow({
name: "Push to main branch",
name: "Pull requests",
on: "pull_request",
env: defaultEnv,
jobs: {
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pullRequests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s)
# and run "github-actions-wac build" (or "ghawac build") to regenerate this file.
# For more information, run "github-actions-wac --help".
name: Push to main branch
name: Pull requests
'on': pull_request
env:
NODE_OPTIONS: '--max_old_space_size=4096'
Expand All @@ -14,8 +14,8 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: .yarn/cache
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# and run "github-actions-wac build" (or "ghawac build") to regenerate this file.
# For more information, run "github-actions-wac --help".
name: Push to main branch
'on': push
'on':
push:
branches:
- main
env:
NODE_OPTIONS: '--max_old_space_size=4096'
jobs:
Expand All @@ -14,8 +17,8 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: .yarn/cache
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
Expand Down
101 changes: 80 additions & 21 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
4 changes: 2 additions & 2 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"exclude": [".*?\/__tests__\/.*"],
"exclude": [".*?/__tests__/.*"],
"jsc": {
"parser": {
"syntax": "typescript"
Expand All @@ -11,6 +11,6 @@
"baseUrl": "."
},
"module": {
"type": "commonjs"
"type": "es6"
}
}
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

31 changes: 17 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "github-actions-wac",
"version": "1.0.0",
"type": "module",
"main": "index.js",
"description": "GitHub Actions - Workflows as Code (WaC).",
"repository": "git@github.com:adrians5j/github-actions-wac.git",
Expand All @@ -10,40 +11,42 @@
"chokidar": "^3.5.2",
"cosmiconfig": "^7.0.1",
"debug": "^4.3.4",
"fast-glob": "^3.2.11",
"fast-glob": "^3.3.3",
"js-yaml": "^4.1.0",
"ts-node": "^10.8.1",
"yargs": "^17.4.0"
"tsx": "^4.20.5",
"yargs": "^18.0.0"
},
"devDependencies": {
"@swc/cli": "^0.1.51",
"@swc/core": "^1.2.108",
"@tsconfig/recommended": "^1.0.1",
"@types/jest": "^28.1.3",
"@tsconfig/node22": "^22.0.2",
"@types/debug": "^4.1.12",
"@types/js-yaml": "^4.0.5",
"@types/node": "^16.7.13",
"@types/node-fetch": "^2.6.2",
"jest": "^28.1.2",
"@types/yargs": "^17.0.33",
"json-schema-to-typescript": "^11.0.1",
"node-fetch": "^2.2.6",
"prettier": "^2.4.1",
"ts-jest": "^28.0.5",
"typescript": "^4.7.4"
"prettier": "^3.6.2",
"typescript": "^5.9.2"
},
"peerDependencies": {
"typescript": "^4.0.0"
"typescript": "^5.9.2"
},
"engines": {
"node": ">=22.0.0"
},
"bin": {
"ghawac": "./bin.js",
"github-actions-wac": "./bin.js"
},
"scripts": {
"build": "rm -rf dist && swc src -d dist --source-maps --extensions '.ts' && tsc ./src/**/*.ts --outDir dist --declaration --emitDeclarationOnly",
"build": "rm -rf dist && swc src -d dist --source-maps --extensions '.ts' && tsc --emitDeclarationOnly --declaration",
"watch": "swc src -d dist --source-maps --extensions '.ts' --watch",
"prepare-dist-for-release": "cp README.md dist/README.md && cp package.json dist/package.json",
"generate-gh-actions-workflow-types": "ts-node scripts/generateGithubActionsWorkflowTypes.ts",
"generate-gh-actions-workflow-types": "tsx scripts/generateGithubActionsWorkflowTypes.ts",
"github-actions-wac": "node dist/bin.js",
"ghawac": "node dist/bin.js",
"test": "jest"
"ghawac": "node dist/bin.js"
},
"release": {
"branches": [
Expand Down
32 changes: 19 additions & 13 deletions src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
#!/usr/bin/env node
import * as yargs from "yargs";
import { build } from "./commands/build";
import { watch } from "./commands/watch";
import { validate } from "./commands/validate";
import "tsx/esm";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";

yargs
import { build } from "./commands/build.js";
import { watch } from "./commands/watch.js";
import { validate } from "./commands/validate.js";

await yargs(hideBin(process.argv))
.scriptName("github-actions-wac")
.usage("$0 <cmd> [args]")
.usage("$0 <command> [options]")
.command(
"build",
`Builds YAML from detected TypeScript ("*.wac.ts") workflow files.`,
{},
'Builds YAML from detected TypeScript ("*.wac.ts") workflow files.',
() => {},
build
)
.command(
"watch",
`Watches for changes in detected TypeScript ("*.wac.ts") workflow files and automatically generates YAML.`,
{},
'Watches for changes in detected TypeScript ("*.wac.ts") workflow files and automatically generates YAML.',
() => {},
watch
)
.command(
"validate",
`Ensures "*.wac.ts" files are in sync with generated YAML files.`,
{},
'Ensures "*.wac.ts" files are in sync with generated YAML files.',
() => {},
validate
)
.help().argv;
.demandCommand(1, "You must specify a command")
.strict()
.help()
.parse();
Loading