Skip to content

Commit 30285dc

Browse files
committed
feat: add aliasLanguages
1 parent a8fad84 commit 30285dc

File tree

8 files changed

+25
-28
lines changed

8 files changed

+25
-28
lines changed

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"scripts": {
4-
"sg": "../dist/index.mjs sg",
4+
"sg": "../dist/index.mjs sg ./src",
55
"dev": "vite",
66
"build": "vite build"
77
},

src/index.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env node
2-
/* eslint-disable curly */
32
import { fileURLToPath } from 'node:url'
43
import process from 'node:process'
54
import { $, argv, chalk, fs, glob, path } from 'zx'
@@ -29,7 +28,7 @@ let macro = await select({
2928
},
3029
)
3130

32-
let render = 'export-render'
31+
let render
3332
if (macro === 'jsx-directive') {
3433
render = await select({
3534
message: chalk.green(
@@ -77,31 +76,23 @@ const files = await glob(`${targetDirectory}/**/*.vue`, {
7776
].filter(Boolean),
7877
})
7978

80-
// await Promise.all(files.map(async file => fs.move(file, `${file}.sg.html`)))
81-
8279
if (['jsx-directive', 'setup-sfc'].includes(macro)) {
83-
await $`${sg} scan -c ${config}.yml -U --filter '^v-(on|directive)' ${targetDirectory}`
80+
await $`${sg} scan -c ${config}.yml -U --filter '^v-' ${targetDirectory}`
8481

85-
await $`${sg} scan -c ${config}.yml -U --filter '^${macro === 'setup-sfc' ? render : 'export-render'}' ${targetDirectory}`
82+
await $`${sg} scan -c ${config}.yml -U --filter '^${macro === 'setup-sfc' ? 'export-render' : render}' ${targetDirectory}`
8683

8784
await $`${sg} scan -c ${config}.yml -U --filter '^setup-sfc' ${targetDirectory}`
8885

89-
// await Promise.all(files.map(async file => fs.move(`${file}.sg.html`, `${file}.sg.tsx`)))
90-
91-
await $`${sg} scan -c ${config}-tsx.yml -U --filter '^tsx v-' ${targetDirectory}`
86+
await $`${sg} scan -c ${config}-tsx.yml -U --filter '^v-' ${targetDirectory}`
9287

9388
if (defineSlots === 'define-short-slots')
94-
await $`${sg} scan -c ${config}.yml -U --filter 'tsx define-short-slots' ${targetDirectory}`
89+
await $`${sg} scan -c ${config}-tsx.yml -U --filter 'define-short-slots' ${targetDirectory}`
9590

96-
if (macro === 'setup-sfc') {
91+
if (macro === 'setup-sfc')
9792
await Promise.all(files.map(async file => fs.move(file, `${file.slice(0, -3)}setup.tsx`)))
98-
}
99-
else {
100-
await $`${sg} scan -c ${config}-tsx.yml -U --filter '^tsx sfc$' ${targetDirectory}`
101-
// await Promise.all(files.map(async file => fs.move(`${file}.sg.tsx`, file)))
102-
}
93+
else
94+
await $`${sg} scan -c ${config}-tsx.yml -U --filter '^sfc$' ${targetDirectory}`
10395
}
10496
else {
10597
await $`${sg} scan -c ${config}.yml -U --filter ^${macro} ${targetDirectory}`
106-
// await Promise.all(files.map(async file => fs.move(`${file}.sg.html`, file)))
10798
}

src/rules/define-slots.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ fix: |-
5050
5151
---
5252

53-
id: tsx v-define-slots
54-
language: vue
53+
id: v-define-slots
54+
language: vueTsx
5555
rule:
5656
kind: expression_statement
5757
pattern: $A
@@ -67,8 +67,8 @@ fix: |-
6767
6868
---
6969

70-
id: tsx define-short-slots
71-
language: vue
70+
id: define-short-slots
71+
language: vueTsx
7272
rule:
7373
kind: type_annotation
7474
has:

src/rules/jsx-directive/v-on.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fix:
4747
---
4848

4949
id: tsx v-on
50-
language: vue
50+
language: vueTsx
5151
rule:
5252
kind: jsx_expression
5353
not:

src/rules/jsx-directive/v-text.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
id: tsx v-text
2-
language: vue
1+
id: v-text
2+
language: vueTsx
33
rule:
44
kind: jsx_expression
55
has:

src/rules/sfc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
id: tsx sfc
2-
language: vue
1+
id: sfc
2+
language: vueTsx
33
rule:
44
kind: program
55
pattern: $A

src/sgconfig-tsx.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ ruleDirs:
33
utilDirs:
44
- utils
55
aliasLanguages:
6-
vue:
6+
vueTsx:
77
aliasOf: tsx
88
extensions: [vue]
9+
vue:
10+
aliasOf: html
11+
extensions: []

src/sgconfig.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ aliasLanguages:
66
vue:
77
aliasOf: html
88
extensions: [vue]
9+
vueTsx:
10+
aliasOf: tsx
11+
extensions: []

0 commit comments

Comments
 (0)