@tsslint/cli 1.5.8 → 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 CHANGED
@@ -20,6 +20,7 @@ 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;
24
25
  const vueVineColor = (s) => '\x1b[38;5;48m' + s + _reset;
25
26
  const mdxColor = (s) => '\x1b[33m' + s + _reset;
@@ -53,6 +54,9 @@ class Project {
53
54
  labels.push(tsColor('TS'));
54
55
  }
55
56
  else {
57
+ if (this.languages.includes('ts-macro')) {
58
+ labels.push(tsMacroColor('TS Macro'));
59
+ }
56
60
  if (this.languages.includes('vue')) {
57
61
  labels.push(vueColor('Vue'));
58
62
  }
@@ -113,11 +117,19 @@ class Project {
113
117
  '--mdx-projects',
114
118
  '--astro-project',
115
119
  '--astro-projects',
120
+ '--ts-macro-project',
121
+ '--ts-macro-projects',
116
122
  ].some(flag => process.argv.includes(flag))) {
117
- const languages = await clack.multiselect({
118
- required: false,
119
- message: 'Select frameworks (optional)',
123
+ const language = await clack.select({
124
+ message: 'Select framework',
125
+ initialValue: undefined,
120
126
  options: [{
127
+ label: 'Vanilla JS/TS',
128
+ value: undefined,
129
+ }, {
130
+ label: 'TS Macro',
131
+ value: 'ts-macro',
132
+ }, {
121
133
  label: 'Vue',
122
134
  value: 'vue',
123
135
  }, {
@@ -131,14 +143,14 @@ class Project {
131
143
  value: 'astro',
132
144
  }],
133
145
  });
134
- if (clack.isCancel(languages)) {
146
+ if (clack.isCancel(language)) {
135
147
  process.exit(1);
136
148
  }
137
- const tsconfigOptions = glob.sync('**/{tsconfig.json,jsconfig.json}');
149
+ const tsconfigOptions = glob.sync('**/{tsconfig.json,tsconfig.*.json,jsconfig.json}');
138
150
  let options = await Promise.all(tsconfigOptions.map(async (tsconfigOption) => {
139
151
  const tsconfig = require.resolve(tsconfigOption.startsWith('.') ? tsconfigOption : `./${tsconfigOption}`, { paths: [process.cwd()] });
140
152
  try {
141
- const commonLine = await parseCommonLine(tsconfig, languages);
153
+ const commonLine = await parseCommonLine(tsconfig, language ? [language] : []);
142
154
  return {
143
155
  label: path.relative(process.cwd(), tsconfig) + ` (${commonLine.fileNames.length})`,
144
156
  value: tsconfigOption,
@@ -149,12 +161,16 @@ class Project {
149
161
  }
150
162
  }));
151
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
+ }
152
167
  if (!options.length) {
153
168
  clack.log.error(lightRed('No projects found.'));
154
169
  process.exit(1);
155
170
  }
156
171
  const selectedTsconfigs = await clack.multiselect({
157
172
  message: 'Select one or multiple projects',
173
+ initialValues: [options[0].value],
158
174
  // @ts-expect-error
159
175
  options,
160
176
  });
@@ -162,18 +178,16 @@ class Project {
162
178
  process.exit(1);
163
179
  }
164
180
  let command = 'tsslint';
165
- if (!languages.length) {
181
+ if (!language) {
166
182
  command += ' --project ' + selectedTsconfigs.join(' ');
167
183
  }
168
184
  else {
169
- for (const language of languages) {
170
- command += ` --${language}-project ` + selectedTsconfigs.join(' ');
171
- }
185
+ command += ` --${language}-project ` + selectedTsconfigs.join(' ');
172
186
  }
173
187
  clack.log.info(`${darkGray('Command:')} ${purple(command)}`);
174
188
  for (let tsconfig of selectedTsconfigs) {
175
189
  tsconfig = resolvePath(tsconfig);
176
- tsconfigAndLanguages.set(tsconfig, languages);
190
+ tsconfigAndLanguages.set(tsconfig, language ? [language] : []);
177
191
  }
178
192
  }
179
193
  else {
@@ -199,6 +213,10 @@ class Project {
199
213
  projectFlags: ['--astro-project', '--astro-projects'],
200
214
  language: 'astro',
201
215
  },
216
+ {
217
+ projectFlags: ['--ts-macro-project', '--ts-macro-projects'],
218
+ language: 'ts-macro',
219
+ },
202
220
  ];
203
221
  for (const { projectFlags, language } of options) {
204
222
  const projectFlag = projectFlags.find(flag => process.argv.includes(flag));
@@ -103,6 +103,31 @@ async function load(tsconfig, languages) {
103
103
  const astroLanguagePlugin = astro.getLanguagePlugin();
104
104
  plugins.push(astroLanguagePlugin);
105
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
+ }
106
131
  cache.set(tsconfig, plugins);
107
132
  return plugins;
108
133
  function findPackageJson(pkgName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/cli",
3
- "version": "1.5.8",
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.8",
20
- "@tsslint/core": "1.5.8",
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",
@@ -30,5 +30,5 @@
30
30
  "@vue-vine/language-service": "latest",
31
31
  "@vue/language-core": "latest"
32
32
  },
33
- "gitHead": "a164ff719def41ce69256fd7260e9e0fb1017e48"
33
+ "gitHead": "0439ad76d74dd0de012d7d23a4bd2d7ef5331b76"
34
34
  }