Skip to content

Commit 80cfa85

Browse files
authored
fix: change how version is generated and parsed (#21)
1 parent d208d8b commit 80cfa85

9 files changed

Lines changed: 37 additions & 48 deletions

File tree

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @luist18
1+
* @neondatabase/product-engineering-workflow

__tests__/diff.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ describe('summary function', () => {
345345
)})) 🔒`
346346
)
347347
expect(result).toContain(
348-
`This comment was last updated at 1/1/2023 12:00:00 PM`
348+
`This comment was last updated at Sun, 01 Jan 2023 12:00:00 GMT`
349349
)
350350
})
351351

dist/index.js

Lines changed: 16 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "schema-diff",
33
"description": "Neon Schema Diff GitHub Action",
4-
"version": "0.0.1",
4+
"version": "1.0.1",
55
"author": "",
6-
"private": true,
6+
"private": false,
77
"repository": {
88
"type": "git",
9-
"url": "git+https://github.com/luist18/refactored-giggle"
9+
"url": "git+https://github.com/neondatabase/schema-diff-action"
1010
},
1111
"bugs": {
12-
"url": "https://github.com/luist18/refactored-giggle/issues"
12+
"url": "https://github.com/neondatabase/schema-diff-action/issues"
1313
},
1414
"keywords": [
1515
"actions",
@@ -23,7 +23,7 @@
2323
"node": ">=21"
2424
},
2525
"scripts": {
26-
"bundle": "npm run format:write && npm run package",
26+
"bundle": "npm run prebuild && npm run format:write && npm run package",
2727
"ci-test": "npx jest",
2828
"coverage": "npx make-coverage-badge --output-path ./docs/coverage.svg",
2929
"format:write": "npx prettier --write .",
@@ -32,6 +32,7 @@
3232
"local-action": "npx local-action . src/main.ts .env",
3333
"package": "npx ncc build src/index.ts -o dist --source-map --license licenses.txt",
3434
"package:watch": "npm run package -- --watch",
35+
"prebuild": "sh ./scripts/generate-version.sh",
3536
"test": "npx jest",
3637
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
3738
},

scripts/generate-version.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
version=$(node -p "require('./package.json').version")
4+
5+
printf "export const version = '%s'\n\n" "$version" >src/version.ts
6+
printf "// This file is auto-generated. Use 'npm run prebuild' when you need to update the version!\n" >>src/version.ts

src/diff.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import * as github from '@actions/github'
22
import { createApiClient, type Branch } from '@neondatabase/api-client'
33
import { createPatch } from 'diff'
4-
5-
import { pkg } from './pkg'
64
import { BranchComparisonInput, getBranchURL, PointInTime } from './utils'
5+
import { version } from './version'
76

87
const DIFF_COMMENT_IDENTIFIER =
98
'<!--- [schema diff GitHub action comment identifier] -->'
@@ -36,7 +35,7 @@ export async function diff(
3635
timeout: 60000,
3736
headers: {
3837
// action version from the package.json
39-
'User-Agent': `neon-schema-diff-action v${pkg()['version'] as string}`
38+
'User-Agent': `neon-schema-diff-action v${version}`
4039
}
4140
})
4241

@@ -178,7 +177,7 @@ Schema diff between the compare branch ([${compareBranch.name}](${compareBranchU
178177
179178
${diffContent}
180179
181-
This comment was last updated at ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}
180+
This comment was last updated at ${new Date().toUTCString()}
182181
`
183182
}
184183

src/pkg.ts

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

src/version.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const version = '1.0.1'
2+
3+
// This file is auto-generated. Use 'npm run prebuild' when you need to update the version!

0 commit comments

Comments
 (0)