File tree Expand file tree Collapse file tree 10 files changed +88
-4
lines changed Expand file tree Collapse file tree 10 files changed +88
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " svelte-eslint-parser " : minor
3+ ---
4+
5+ feat: export meta object
Original file line number Diff line number Diff line change 1+ {
2+ "version-ci": {
3+ "IN_VERSION_CI_SCRIPT": "true"
4+ }
5+ }
Original file line number Diff line number Diff line change 3333 id : changesets
3434 uses : changesets/action@v1
3535 with :
36+ # this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
37+ version : yarn version:ci
3638 # This expects you to have a script called release which does a build for your packages and calls changeset publish
3739 publish : yarn release
3840 commit : " chore: release svelte-eslint-parser"
Original file line number Diff line number Diff line change 2626 ],
2727 "scripts" : {
2828 "benchmark" : " yarn ts benchmark/index.ts" ,
29- "build" : " tsc --project ./tsconfig.build.json" ,
29+ "build" : " yarn build:meta && yarn build:tsc" ,
30+ "build:meta" : " yarn ts ./tools/update-meta.ts" ,
31+ "build:tsc" : " tsc --project ./tsconfig.build.json" ,
3032 "clean" : " rimraf .nyc_output lib coverage" ,
3133 "cover" : " nyc --reporter=lcov yarn test" ,
3234 "debug" : " yarn mocha \" tests/src/**/*.ts\" --reporter dot --timeout 60000" ,
4042 "release" : " changeset publish" ,
4143 "test" : " yarn mocha \" tests/src/**/*.ts\" --reporter dot --timeout 60000" ,
4244 "ts" : " node -r esbuild-register" ,
43- "update-fixtures" : " yarn ts ./tools/update-fixtures.ts"
45+ "update-fixtures" : " yarn ts ./tools/update-fixtures.ts" ,
46+ "version:ci" : " env-cmd -e version-ci yarn build:meta && changeset version"
4447 },
4548 "peerDependencies" : {
4649 "svelte" : " ^3.37.0"
7174 "@typescript-eslint/parser" : " ~5.59.0" ,
7275 "benchmark" : " ^2.1.4" ,
7376 "chai" : " ^4.3.4" ,
77+ "env-cmd" : " ^10.1.0" ,
7478 "esbuild" : " ^0.17.0" ,
7579 "esbuild-register" : " ^3.3.3" ,
7680 "eslint" : " ^8.2.0" ,
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ import * as AST from "./ast";
33import { traverseNodes } from "./traverse" ;
44import { KEYS } from "./visitor-keys" ;
55import { ParseError } from "./errors" ;
6+ export * as meta from "./meta" ;
7+ export { name } from "./meta" ;
68
79export { AST , ParseError } ;
810
9- export const name = "svelte-eslint-parser" ;
10-
1111// parser
1212export { parseForESLint } ;
1313// Keys
Original file line number Diff line number Diff line change 1+ // IMPORTANT!
2+ // This file has been automatically generated,
3+ // in order to update its content execute "yarn build:meta"
4+ export const name = "svelte-eslint-parser" as const ;
5+ export const version = "0.27.0" as const ;
Original file line number Diff line number Diff line change 1+ import assert from "assert" ;
2+ import * as parser from "../../src" ;
3+ import { version } from "../../package.json" ;
4+ const expectedMeta = {
5+ name : "svelte-eslint-parser" ,
6+ version,
7+ } ;
8+
9+ describe ( "Test for meta object" , ( ) => {
10+ it ( "A parser should have a meta object." , ( ) => {
11+ assert . deepStrictEqual ( parser . meta , expectedMeta ) ;
12+ } ) ;
13+ } ) ;
Original file line number Diff line number Diff line change 1+ import getReleasePlan from "@changesets/get-release-plan" ;
2+ import path from "path" ;
3+
4+ /** Get new version string from changesets */
5+ export async function getNewVersion ( ) : Promise < string > {
6+ const releasePlan = await getReleasePlan ( path . resolve ( __dirname , "../.." ) ) ;
7+
8+ return releasePlan . releases . find (
9+ ( { name } ) => name === "svelte-eslint-parser"
10+ ) ! . newVersion ;
11+ }
Original file line number Diff line number Diff line change 1+ import fs from "fs" ;
2+ import path from "path" ;
3+ import { ESLint } from "eslint" ;
4+ import { name , version } from "../package.json" ;
5+ import { getNewVersion } from "./lib/changesets-util" ;
6+
7+ const META_PATH = path . join ( __dirname , "../src/meta.ts" ) ;
8+
9+ void main ( ) ;
10+
11+ /** main */
12+ async function main ( ) {
13+ if ( ! fs . existsSync ( META_PATH ) ) {
14+ fs . writeFileSync ( META_PATH , "" , "utf8" ) ;
15+ }
16+ const eslint = new ESLint ( { fix : true } ) ;
17+ const [ result ] = await eslint . lintText (
18+ `/*
19+ * IMPORTANT!
20+ * This file has been automatically generated,
21+ * in order to update its content execute "yarn build:meta"
22+ */
23+ export const name = ${ JSON . stringify ( name ) } as const;
24+ export const version = ${ JSON . stringify ( await getVersion ( ) ) } as const;
25+ ` ,
26+ { filePath : META_PATH }
27+ ) ;
28+ fs . writeFileSync ( META_PATH , result . output ! ) ;
29+ }
30+
31+ /** Get version */
32+ function getVersion ( ) {
33+ // eslint-disable-next-line no-process-env -- ignore
34+ if ( process . env . IN_VERSION_CI_SCRIPT ) {
35+ return getNewVersion ( ) ;
36+ }
37+ return version ;
38+ }
Original file line number Diff line number Diff line change 1111 "noUnusedLocals" : true ,
1212 "noUnusedParameters" : true ,
1313 "esModuleInterop" : true ,
14+ "resolveJsonModule" : true ,
1415
1516 "skipLibCheck" : true
1617 },
You can’t perform that action at this time.
0 commit comments