File tree 10 files changed +88
-4
lines changed
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 33
33
id : changesets
34
34
uses : changesets/action@v1
35
35
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
36
38
# This expects you to have a script called release which does a build for your packages and calls changeset publish
37
39
publish : yarn release
38
40
commit : " chore: release svelte-eslint-parser"
Original file line number Diff line number Diff line change 26
26
],
27
27
"scripts" : {
28
28
"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" ,
30
32
"clean" : " rimraf .nyc_output lib coverage" ,
31
33
"cover" : " nyc --reporter=lcov yarn test" ,
32
34
"debug" : " yarn mocha \" tests/src/**/*.ts\" --reporter dot --timeout 60000" ,
40
42
"release" : " changeset publish" ,
41
43
"test" : " yarn mocha \" tests/src/**/*.ts\" --reporter dot --timeout 60000" ,
42
44
"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"
44
47
},
45
48
"peerDependencies" : {
46
49
"svelte" : " ^3.37.0"
71
74
"@typescript-eslint/parser" : " ~5.59.0" ,
72
75
"benchmark" : " ^2.1.4" ,
73
76
"chai" : " ^4.3.4" ,
77
+ "env-cmd" : " ^10.1.0" ,
74
78
"esbuild" : " ^0.17.0" ,
75
79
"esbuild-register" : " ^3.3.3" ,
76
80
"eslint" : " ^8.2.0" ,
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ import * as AST from "./ast";
3
3
import { traverseNodes } from "./traverse" ;
4
4
import { KEYS } from "./visitor-keys" ;
5
5
import { ParseError } from "./errors" ;
6
+ export * as meta from "./meta" ;
7
+ export { name } from "./meta" ;
6
8
7
9
export { AST , ParseError } ;
8
10
9
- export const name = "svelte-eslint-parser" ;
10
-
11
11
// parser
12
12
export { parseForESLint } ;
13
13
// 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 11
11
"noUnusedLocals" : true ,
12
12
"noUnusedParameters" : true ,
13
13
"esModuleInterop" : true ,
14
+ "resolveJsonModule" : true ,
14
15
15
16
"skipLibCheck" : true
16
17
},
You can’t perform that action at this time.
0 commit comments