-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: export meta object * Create honest-lamps-destroy.md
- Loading branch information
Showing
10 changed files
with
90 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"yaml-eslint-parser": patch | ||
--- | ||
|
||
feat: export meta object |
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,5 @@ | ||
{ | ||
"version-ci": { | ||
"IN_VERSION_CI_SCRIPT": "true" | ||
} | ||
} |
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
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,5 @@ | ||
// IMPORTANT! | ||
// This file has been automatically generated, | ||
// in order to update its content execute "npm run build:meta" | ||
export const name = "yaml-eslint-parser" as const; | ||
export const version = "1.2.1" as const; |
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,13 @@ | ||
import assert from "assert"; | ||
import * as parser from "../../src"; | ||
import { version } from "../../package.json"; | ||
const expectedMeta = { | ||
name: "yaml-eslint-parser", | ||
version, | ||
}; | ||
|
||
describe("Test for meta object", () => { | ||
it("A parser should have a meta object.", () => { | ||
assert.deepStrictEqual(parser.meta, expectedMeta); | ||
}); | ||
}); |
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,10 @@ | ||
import getReleasePlan from "@changesets/get-release-plan"; | ||
import path from "path"; | ||
|
||
/** Get new version string from changesets */ | ||
export async function getNewVersion(): Promise<string> { | ||
const releasePlan = await getReleasePlan(path.resolve(__dirname, "../..")); | ||
|
||
return releasePlan.releases.find(({ name }) => name === "yaml-eslint-parser")! | ||
.newVersion; | ||
} |
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,38 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { ESLint } from "eslint"; | ||
import { name, version } from "../package.json"; | ||
import { getNewVersion } from "./lib/changesets-util"; | ||
|
||
const META_PATH = path.join(__dirname, "../src/meta.ts"); | ||
|
||
void main(); | ||
|
||
/** main */ | ||
async function main() { | ||
if (!fs.existsSync(META_PATH)) { | ||
fs.writeFileSync(META_PATH, "", "utf8"); | ||
} | ||
const eslint = new ESLint({ fix: true }); | ||
const [result] = await eslint.lintText( | ||
`/* | ||
* IMPORTANT! | ||
* This file has been automatically generated, | ||
* in order to update its content execute "npm run build:meta" | ||
*/ | ||
export const name = ${JSON.stringify(name)} as const; | ||
export const version = ${JSON.stringify(await getVersion())} as const; | ||
`, | ||
{ filePath: META_PATH } | ||
); | ||
fs.writeFileSync(META_PATH, result.output!); | ||
} | ||
|
||
/** Get version */ | ||
function getVersion() { | ||
// eslint-disable-next-line no-process-env -- ignore | ||
if (process.env.IN_VERSION_CI_SCRIPT) { | ||
return getNewVersion(); | ||
} | ||
return version; | ||
} |
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