Skip to content

Commit 11ed4e4

Browse files
authored
feat!: upgrade to ESM
BREAKING CHANGE: The package is now ESM-only and no longer supports CommonJS imports.
1 parent 2dec6e5 commit 11ed4e4

File tree

17 files changed

+551
-2420
lines changed

17 files changed

+551
-2420
lines changed

.github/workflows/index.wac.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createWorkflow, NormalJob } from "../../src";
1+
import { createWorkflow, NormalJob } from "../../src/index.js";
22

33
const defaultEnv = {
44
NODE_OPTIONS: "--max_old_space_size=4096"
@@ -9,9 +9,9 @@ const checkoutInstallBuildTest: NormalJob["steps"] = [
99
uses: "actions/setup-node@v2",
1010
with: { "node-version": 14 }
1111
},
12-
{ uses: "actions/checkout@v2" },
12+
{ uses: "actions/checkout@v4" },
1313
{
14-
uses: "actions/cache@v2",
14+
uses: "actions/cache@v4",
1515
with: {
1616
path: ".yarn/cache",
1717
key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}"
@@ -24,7 +24,11 @@ const checkoutInstallBuildTest: NormalJob["steps"] = [
2424

2525
export const push = createWorkflow({
2626
name: "Push to main branch",
27-
on: "push",
27+
on: {
28+
push: {
29+
branches: ["main"]
30+
}
31+
},
2832
env: defaultEnv,
2933
jobs: {
3034
buildTestRelease: {
@@ -48,7 +52,7 @@ export const push = createWorkflow({
4852
});
4953

5054
export const pullRequests = createWorkflow({
51-
name: "Push to main branch",
55+
name: "Pull requests",
5256
on: "pull_request",
5357
env: defaultEnv,
5458
jobs: {

.github/workflows/pullRequests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s)
33
# and run "github-actions-wac build" (or "ghawac build") to regenerate this file.
44
# For more information, run "github-actions-wac --help".
5-
name: Push to main branch
5+
name: Pull requests
66
'on': pull_request
77
env:
88
NODE_OPTIONS: '--max_old_space_size=4096'
@@ -14,8 +14,8 @@ jobs:
1414
- uses: actions/setup-node@v2
1515
with:
1616
node-version: 14
17-
- uses: actions/checkout@v2
18-
- uses: actions/cache@v2
17+
- uses: actions/checkout@v4
18+
- uses: actions/cache@v4
1919
with:
2020
path: .yarn/cache
2121
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

.github/workflows/push.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
# and run "github-actions-wac build" (or "ghawac build") to regenerate this file.
44
# For more information, run "github-actions-wac --help".
55
name: Push to main branch
6-
'on': push
6+
'on':
7+
push:
8+
branches:
9+
- main
710
env:
811
NODE_OPTIONS: '--max_old_space_size=4096'
912
jobs:
@@ -14,8 +17,8 @@ jobs:
1417
- uses: actions/setup-node@v2
1518
with:
1619
node-version: 14
17-
- uses: actions/checkout@v2
18-
- uses: actions/cache@v2
20+
- uses: actions/checkout@v4
21+
- uses: actions/cache@v4
1922
with:
2023
path: .yarn/cache
2124
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

.idea/workspace.xml

Lines changed: 80 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

.swcrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"exclude": [".*?\/__tests__\/.*"],
2+
"exclude": [".*?/__tests__/.*"],
33
"jsc": {
44
"parser": {
55
"syntax": "typescript"
@@ -11,6 +11,6 @@
1111
"baseUrl": "."
1212
},
1313
"module": {
14-
"type": "commonjs"
14+
"type": "es6"
1515
}
1616
}

jest.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "github-actions-wac",
33
"version": "1.0.0",
4+
"type": "module",
45
"main": "index.js",
56
"description": "GitHub Actions - Workflows as Code (WaC).",
67
"repository": "[email protected]:adrians5j/github-actions-wac.git",
@@ -10,40 +11,42 @@
1011
"chokidar": "^3.5.2",
1112
"cosmiconfig": "^7.0.1",
1213
"debug": "^4.3.4",
13-
"fast-glob": "^3.2.11",
14+
"fast-glob": "^3.3.3",
1415
"js-yaml": "^4.1.0",
15-
"ts-node": "^10.8.1",
16-
"yargs": "^17.4.0"
16+
"tsx": "^4.20.5",
17+
"yargs": "^18.0.0"
1718
},
1819
"devDependencies": {
1920
"@swc/cli": "^0.1.51",
2021
"@swc/core": "^1.2.108",
21-
"@tsconfig/recommended": "^1.0.1",
22-
"@types/jest": "^28.1.3",
22+
"@tsconfig/node22": "^22.0.2",
23+
"@types/debug": "^4.1.12",
24+
"@types/js-yaml": "^4.0.5",
2325
"@types/node": "^16.7.13",
2426
"@types/node-fetch": "^2.6.2",
25-
"jest": "^28.1.2",
27+
"@types/yargs": "^17.0.33",
2628
"json-schema-to-typescript": "^11.0.1",
2729
"node-fetch": "^2.2.6",
28-
"prettier": "^2.4.1",
29-
"ts-jest": "^28.0.5",
30-
"typescript": "^4.7.4"
30+
"prettier": "^3.6.2",
31+
"typescript": "^5.9.2"
3132
},
3233
"peerDependencies": {
33-
"typescript": "^4.0.0"
34+
"typescript": "^5.9.2"
35+
},
36+
"engines": {
37+
"node": ">=22.0.0"
3438
},
3539
"bin": {
3640
"ghawac": "./bin.js",
3741
"github-actions-wac": "./bin.js"
3842
},
3943
"scripts": {
40-
"build": "rm -rf dist && swc src -d dist --source-maps --extensions '.ts' && tsc ./src/**/*.ts --outDir dist --declaration --emitDeclarationOnly",
44+
"build": "rm -rf dist && swc src -d dist --source-maps --extensions '.ts' && tsc --emitDeclarationOnly --declaration",
4145
"watch": "swc src -d dist --source-maps --extensions '.ts' --watch",
4246
"prepare-dist-for-release": "cp README.md dist/README.md && cp package.json dist/package.json",
43-
"generate-gh-actions-workflow-types": "ts-node scripts/generateGithubActionsWorkflowTypes.ts",
47+
"generate-gh-actions-workflow-types": "tsx scripts/generateGithubActionsWorkflowTypes.ts",
4448
"github-actions-wac": "node dist/bin.js",
45-
"ghawac": "node dist/bin.js",
46-
"test": "jest"
49+
"ghawac": "node dist/bin.js"
4750
},
4851
"release": {
4952
"branches": [

src/bin.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
#!/usr/bin/env node
2-
import * as yargs from "yargs";
3-
import { build } from "./commands/build";
4-
import { watch } from "./commands/watch";
5-
import { validate } from "./commands/validate";
2+
import "tsx/esm";
3+
import yargs from "yargs";
4+
import { hideBin } from "yargs/helpers";
65

7-
yargs
6+
import { build } from "./commands/build.js";
7+
import { watch } from "./commands/watch.js";
8+
import { validate } from "./commands/validate.js";
9+
10+
await yargs(hideBin(process.argv))
811
.scriptName("github-actions-wac")
9-
.usage("$0 <cmd> [args]")
12+
.usage("$0 <command> [options]")
1013
.command(
1114
"build",
12-
`Builds YAML from detected TypeScript ("*.wac.ts") workflow files.`,
13-
{},
15+
'Builds YAML from detected TypeScript ("*.wac.ts") workflow files.',
16+
() => {},
1417
build
1518
)
1619
.command(
1720
"watch",
18-
`Watches for changes in detected TypeScript ("*.wac.ts") workflow files and automatically generates YAML.`,
19-
{},
21+
'Watches for changes in detected TypeScript ("*.wac.ts") workflow files and automatically generates YAML.',
22+
() => {},
2023
watch
2124
)
2225
.command(
2326
"validate",
24-
`Ensures "*.wac.ts" files are in sync with generated YAML files.`,
25-
{},
27+
'Ensures "*.wac.ts" files are in sync with generated YAML files.',
28+
() => {},
2629
validate
2730
)
28-
.help().argv;
31+
.demandCommand(1, "You must specify a command")
32+
.strict()
33+
.help()
34+
.parse();

0 commit comments

Comments
 (0)