-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automate client version number dumps
- Loading branch information
1 parent
e95c5e9
commit e21d3d6
Showing
4 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* The version value is automatically replaced during builds. | ||
*/ | ||
export const USER_AGENT = '@scaleleap/selling-partner-api-sdk/0.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Syncs package.json version with constants file for release. | ||
* | ||
* Triggered inside `postversion` hook in package.json. | ||
* | ||
* See: https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-use-a-npm-build-script-that-requires-the-package-jsons-version | ||
*/ | ||
|
||
import { readFileSync, writeFileSync } from 'fs' | ||
import path from 'path' | ||
|
||
import { name, version } from '../package.json' | ||
import { USER_AGENT } from '../src/constants' | ||
|
||
const CONSTANTS_FILE = path.join(__dirname, '../lib/constants.js') | ||
|
||
const constants = readFileSync(CONSTANTS_FILE, { encoding: 'utf8' }) | ||
const replaced = constants.replace(USER_AGENT, `${name}/${version}`) | ||
|
||
writeFileSync(CONSTANTS_FILE, replaced, { encoding: 'utf8' }) |