@tsslint/cli 1.5.7 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +44 -15
- package/lib/languagePlugins.js +63 -4
- package/package.json +5 -4
package/index.js
CHANGED
|
@@ -20,7 +20,9 @@ const lightGreen = (s) => '\x1b[92m' + s + _reset;
|
|
|
20
20
|
const lightYellow = (s) => '\x1b[93m' + s + _reset;
|
|
21
21
|
// https://talyian.github.io/ansicolors/
|
|
22
22
|
const tsColor = (s) => '\x1b[34m' + s + _reset;
|
|
23
|
+
const tsMacroColor = (s) => '\x1b[38;5;135m' + s + _reset;
|
|
23
24
|
const vueColor = (s) => '\x1b[32m' + s + _reset;
|
|
25
|
+
const vueVineColor = (s) => '\x1b[38;5;48m' + s + _reset;
|
|
24
26
|
const mdxColor = (s) => '\x1b[33m' + s + _reset;
|
|
25
27
|
const astroColor = (s) => '\x1b[38;5;209m' + s + _reset;
|
|
26
28
|
let threads = 1;
|
|
@@ -52,9 +54,15 @@ class Project {
|
|
|
52
54
|
labels.push(tsColor('TS'));
|
|
53
55
|
}
|
|
54
56
|
else {
|
|
57
|
+
if (this.languages.includes('ts-macro')) {
|
|
58
|
+
labels.push(tsMacroColor('TS Macro'));
|
|
59
|
+
}
|
|
55
60
|
if (this.languages.includes('vue')) {
|
|
56
61
|
labels.push(vueColor('Vue'));
|
|
57
62
|
}
|
|
63
|
+
if (this.languages.includes('vue-vine')) {
|
|
64
|
+
labels.push(vueVineColor('Vue Vine'));
|
|
65
|
+
}
|
|
58
66
|
if (this.languages.includes('mdx')) {
|
|
59
67
|
labels.push(mdxColor('MDX'));
|
|
60
68
|
}
|
|
@@ -103,17 +111,30 @@ class Project {
|
|
|
103
111
|
'--projects',
|
|
104
112
|
'--vue-project',
|
|
105
113
|
'--vue-projects',
|
|
114
|
+
'--vue-vine-project',
|
|
115
|
+
'--vue-vine-projects',
|
|
106
116
|
'--mdx-project',
|
|
107
117
|
'--mdx-projects',
|
|
108
118
|
'--astro-project',
|
|
109
119
|
'--astro-projects',
|
|
120
|
+
'--ts-macro-project',
|
|
121
|
+
'--ts-macro-projects',
|
|
110
122
|
].some(flag => process.argv.includes(flag))) {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
123
|
+
const language = await clack.select({
|
|
124
|
+
message: 'Select framework',
|
|
125
|
+
initialValue: undefined,
|
|
114
126
|
options: [{
|
|
127
|
+
label: 'Vanilla JS/TS',
|
|
128
|
+
value: undefined,
|
|
129
|
+
}, {
|
|
130
|
+
label: 'TS Macro',
|
|
131
|
+
value: 'ts-macro',
|
|
132
|
+
}, {
|
|
115
133
|
label: 'Vue',
|
|
116
134
|
value: 'vue',
|
|
135
|
+
}, {
|
|
136
|
+
label: 'Vue Vine',
|
|
137
|
+
value: 'vue-vine',
|
|
117
138
|
}, {
|
|
118
139
|
label: 'MDX',
|
|
119
140
|
value: 'mdx',
|
|
@@ -122,14 +143,14 @@ class Project {
|
|
|
122
143
|
value: 'astro',
|
|
123
144
|
}],
|
|
124
145
|
});
|
|
125
|
-
if (clack.isCancel(
|
|
146
|
+
if (clack.isCancel(language)) {
|
|
126
147
|
process.exit(1);
|
|
127
148
|
}
|
|
128
|
-
const tsconfigOptions = glob.sync('**/{tsconfig.json,jsconfig.json}');
|
|
149
|
+
const tsconfigOptions = glob.sync('**/{tsconfig.json,tsconfig.*.json,jsconfig.json}');
|
|
129
150
|
let options = await Promise.all(tsconfigOptions.map(async (tsconfigOption) => {
|
|
130
151
|
const tsconfig = require.resolve(tsconfigOption.startsWith('.') ? tsconfigOption : `./${tsconfigOption}`, { paths: [process.cwd()] });
|
|
131
152
|
try {
|
|
132
|
-
const commonLine = await parseCommonLine(tsconfig,
|
|
153
|
+
const commonLine = await parseCommonLine(tsconfig, language ? [language] : []);
|
|
133
154
|
return {
|
|
134
155
|
label: path.relative(process.cwd(), tsconfig) + ` (${commonLine.fileNames.length})`,
|
|
135
156
|
value: tsconfigOption,
|
|
@@ -140,12 +161,16 @@ class Project {
|
|
|
140
161
|
}
|
|
141
162
|
}));
|
|
142
163
|
options = options.filter(option => !!option);
|
|
164
|
+
if (options.some(option => !option.label.endsWith('(0)'))) {
|
|
165
|
+
options = options.filter(option => !option.label.endsWith('(0)'));
|
|
166
|
+
}
|
|
143
167
|
if (!options.length) {
|
|
144
168
|
clack.log.error(lightRed('No projects found.'));
|
|
145
169
|
process.exit(1);
|
|
146
170
|
}
|
|
147
171
|
const selectedTsconfigs = await clack.multiselect({
|
|
148
172
|
message: 'Select one or multiple projects',
|
|
173
|
+
initialValues: [options[0].value],
|
|
149
174
|
// @ts-expect-error
|
|
150
175
|
options,
|
|
151
176
|
});
|
|
@@ -153,20 +178,16 @@ class Project {
|
|
|
153
178
|
process.exit(1);
|
|
154
179
|
}
|
|
155
180
|
let command = 'tsslint';
|
|
156
|
-
if (!
|
|
181
|
+
if (!language) {
|
|
157
182
|
command += ' --project ' + selectedTsconfigs.join(' ');
|
|
158
183
|
}
|
|
159
184
|
else {
|
|
160
|
-
|
|
161
|
-
command += ` --${language}-project ` + selectedTsconfigs.join(' ');
|
|
162
|
-
}
|
|
185
|
+
command += ` --${language}-project ` + selectedTsconfigs.join(' ');
|
|
163
186
|
}
|
|
164
|
-
clack.log.info(
|
|
187
|
+
clack.log.info(`${darkGray('Command:')} ${purple(command)}`);
|
|
165
188
|
for (let tsconfig of selectedTsconfigs) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
tsconfigAndLanguages.set(tsconfig, languages);
|
|
189
|
+
tsconfig = resolvePath(tsconfig);
|
|
190
|
+
tsconfigAndLanguages.set(tsconfig, language ? [language] : []);
|
|
170
191
|
}
|
|
171
192
|
}
|
|
172
193
|
else {
|
|
@@ -179,6 +200,10 @@ class Project {
|
|
|
179
200
|
projectFlags: ['--vue-project', '--vue-projects'],
|
|
180
201
|
language: 'vue',
|
|
181
202
|
},
|
|
203
|
+
{
|
|
204
|
+
projectFlags: ['--vue-vine-project', '--vue-vine-projects'],
|
|
205
|
+
language: 'vue-vine',
|
|
206
|
+
},
|
|
182
207
|
{
|
|
183
208
|
projectFlags: ['--mdx-project', '--mdx-projects'],
|
|
184
209
|
projectsFlag: '--mdx-projects',
|
|
@@ -188,6 +213,10 @@ class Project {
|
|
|
188
213
|
projectFlags: ['--astro-project', '--astro-projects'],
|
|
189
214
|
language: 'astro',
|
|
190
215
|
},
|
|
216
|
+
{
|
|
217
|
+
projectFlags: ['--ts-macro-project', '--ts-macro-projects'],
|
|
218
|
+
language: 'ts-macro',
|
|
219
|
+
},
|
|
191
220
|
];
|
|
192
221
|
for (const { projectFlags, language } of options) {
|
|
193
222
|
const projectFlag = projectFlags.find(flag => process.argv.includes(flag));
|
package/lib/languagePlugins.js
CHANGED
|
@@ -32,6 +32,43 @@ async function load(tsconfig, languages) {
|
|
|
32
32
|
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, commonLine.options, commonLine.vueOptions, fileName => fileName);
|
|
33
33
|
plugins.push(vueLanguagePlugin);
|
|
34
34
|
}
|
|
35
|
+
if (languages.includes('vue-vine')) {
|
|
36
|
+
let vue;
|
|
37
|
+
let vueVine;
|
|
38
|
+
let pkgPath;
|
|
39
|
+
if (pkgPath = findPackageJson('@vue-vine/language-service')) {
|
|
40
|
+
const pkgDir = path.dirname(pkgPath);
|
|
41
|
+
vueVine = require('@vue-vine/language-service');
|
|
42
|
+
vue = require(require.resolve('@vue/language-core', { paths: [pkgDir] }));
|
|
43
|
+
}
|
|
44
|
+
else if (pkgPath = findPackageJson('vue-vine-tsc')) {
|
|
45
|
+
const pkgDir = path.dirname(pkgPath);
|
|
46
|
+
vue = require(require.resolve('@vue/language-core', { paths: [pkgDir] }));
|
|
47
|
+
vueVine = require(require.resolve('@vue/language-core', { paths: [pkgDir] }));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const pkg = ts.findConfigFile(path.dirname(tsconfig), ts.sys.fileExists, 'package.json');
|
|
51
|
+
if (pkg) {
|
|
52
|
+
throw new Error('Please install @vue-vine/language-service or vue-vine-tsc to ' + path.relative(process.cwd(), pkg));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error('Please install @vue-vine/language-service or vue-vine-tsc for ' + path.relative(process.cwd(), tsconfig));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const commonLine = vue.createParsedCommandLine(ts, ts.sys, tsconfig, true);
|
|
59
|
+
const globalTypesFilePath = vueVine.setupGlobalTypes(path.dirname(tsconfig), commonLine.vueOptions, ts.sys);
|
|
60
|
+
if (globalTypesFilePath) {
|
|
61
|
+
commonLine.vueOptions.__setupedGlobalTypes = {
|
|
62
|
+
absolutePath: globalTypesFilePath,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
plugins.push(vue.createVueLanguagePlugin(ts, commonLine.options, commonLine.vueOptions, id => id));
|
|
66
|
+
plugins.push(vueVine.createVueVineLanguagePlugin(ts, {
|
|
67
|
+
compilerOptions: commonLine.options,
|
|
68
|
+
vueCompilerOptions: commonLine.vueOptions,
|
|
69
|
+
target: 'tsc',
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
35
72
|
if (languages.includes('mdx')) {
|
|
36
73
|
let mdx;
|
|
37
74
|
try {
|
|
@@ -66,13 +103,35 @@ async function load(tsconfig, languages) {
|
|
|
66
103
|
const astroLanguagePlugin = astro.getLanguagePlugin();
|
|
67
104
|
plugins.push(astroLanguagePlugin);
|
|
68
105
|
}
|
|
106
|
+
if (languages.includes('ts-macro')) {
|
|
107
|
+
let tsMacro;
|
|
108
|
+
let tsMacroOptions;
|
|
109
|
+
let tsmcPkgPath;
|
|
110
|
+
if (tsmcPkgPath = findPackageJson('@ts-macro/language-plugin')) {
|
|
111
|
+
tsMacro = await import(require.resolve('@ts-macro/language-plugin', { paths: [path.dirname(tsconfig)] }));
|
|
112
|
+
tsMacroOptions = require(require.resolve('@ts-macro/language-plugin/options', { paths: [path.dirname(tsconfig)] }));
|
|
113
|
+
}
|
|
114
|
+
else if (tsmcPkgPath = findPackageJson('@ts-macro/tsc')) {
|
|
115
|
+
const tsmcPath = path.dirname(tsmcPkgPath);
|
|
116
|
+
tsMacro = require(require.resolve('@ts-macro/language-plugin', { paths: [tsmcPath] }));
|
|
117
|
+
tsMacroOptions = require(require.resolve('@ts-macro/language-plugin/options', { paths: [tsmcPath] }));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const pkg = ts.findConfigFile(path.dirname(tsconfig), ts.sys.fileExists, 'package.json');
|
|
121
|
+
if (pkg) {
|
|
122
|
+
throw new Error('Please install @ts-macro/language-plugin or @ts-macro/tsc to ' + path.relative(process.cwd(), pkg));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw new Error('Please install @ts-macro/language-plugin or @ts-macro/tsc for ' + path.relative(process.cwd(), tsconfig));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const compilerOptions = ts.readConfigFile(tsconfig, ts.sys.readFile).config.compilerOptions;
|
|
129
|
+
plugins.push(...tsMacro.getLanguagePlugins(ts, compilerOptions, tsMacroOptions.getOptions(ts)));
|
|
130
|
+
}
|
|
69
131
|
cache.set(tsconfig, plugins);
|
|
70
132
|
return plugins;
|
|
71
133
|
function findPackageJson(pkgName) {
|
|
72
|
-
|
|
73
|
-
return require.resolve(`${pkgName}/package.json`, { paths: [path.dirname(tsconfig)] });
|
|
74
|
-
}
|
|
75
|
-
catch { }
|
|
134
|
+
return ts.findConfigFile(path.dirname(tsconfig), ts.sys.fileExists, `node_modules/${pkgName}/package.json`);
|
|
76
135
|
}
|
|
77
136
|
}
|
|
78
137
|
//# sourceMappingURL=languagePlugins.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tsslint": "./bin/tsslint.js"
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@clack/prompts": "^0.8.2",
|
|
19
|
-
"@tsslint/config": "1.5.
|
|
20
|
-
"@tsslint/core": "1.5.
|
|
19
|
+
"@tsslint/config": "1.5.9",
|
|
20
|
+
"@tsslint/core": "1.5.9",
|
|
21
21
|
"@volar/language-core": "~2.4.0",
|
|
22
22
|
"@volar/typescript": "~2.4.0",
|
|
23
23
|
"glob": "^10.4.1",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"typescript": "*"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
+
"@vue-vine/language-service": "latest",
|
|
30
31
|
"@vue/language-core": "latest"
|
|
31
32
|
},
|
|
32
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "0439ad76d74dd0de012d7d23a4bd2d7ef5331b76"
|
|
33
34
|
}
|