@artel/artc 0.6.25289 → 0.6.25290

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/build/Cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CommandLineCompiler
4
- } from "./chunk-WQJII6CO.js";
5
- import "./chunk-X6VSO3OR.js";
4
+ } from "./chunk-HYJB7VUR.js";
5
+ import "./chunk-P7GXE2XS.js";
6
6
  import {
7
7
  __async
8
- } from "./chunk-F62D5WPV.js";
8
+ } from "./chunk-ZV4RVSWH.js";
9
9
 
10
10
  // source/Cli.ts
11
11
  function main() {
package/build/api/Api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Compiler
3
- } from "../chunk-X6VSO3OR.js";
3
+ } from "../chunk-P7GXE2XS.js";
4
4
  import {
5
5
  AccessKind,
6
6
  AccessedFunctionParameter,
@@ -347,7 +347,7 @@ import {
347
347
  withoutQuotes,
348
348
  withoutTemplateQuotes,
349
349
  yieldTask
350
- } from "../chunk-F62D5WPV.js";
350
+ } from "../chunk-ZV4RVSWH.js";
351
351
  export {
352
352
  AccessKind,
353
353
  AccessedFunctionParameter,
@@ -6,9 +6,9 @@ import {
6
6
  PhysicalFileSystem,
7
7
  PhysicalTypeScriptLibrariesProvider,
8
8
  PrintingDiagnosticAcceptor
9
- } from "../chunk-WQJII6CO.js";
10
- import "../chunk-X6VSO3OR.js";
11
- import "../chunk-F62D5WPV.js";
9
+ } from "../chunk-HYJB7VUR.js";
10
+ import "../chunk-P7GXE2XS.js";
11
+ import "../chunk-ZV4RVSWH.js";
12
12
  export {
13
13
  CommandLineCompiler,
14
14
  FileSystemUri,
@@ -183,7 +183,7 @@ import {
183
183
  unwrapParenthesizedExpressions,
184
184
  visitChildren,
185
185
  yieldTask
186
- } from "../chunk-F62D5WPV.js";
186
+ } from "../chunk-ZV4RVSWH.js";
187
187
 
188
188
  // source/services/CustomRequests.ts
189
189
  import * as ls from "vscode-languageserver";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Compiler
3
- } from "./chunk-X6VSO3OR.js";
3
+ } from "./chunk-P7GXE2XS.js";
4
4
  import {
5
5
  ArtelVersion,
6
6
  Cached,
@@ -15,7 +15,7 @@ import {
15
15
  __async,
16
16
  performanceMeasurementStageNames,
17
17
  performanceMeasurementStages
18
- } from "./chunk-F62D5WPV.js";
18
+ } from "./chunk-ZV4RVSWH.js";
19
19
 
20
20
  // source/executor/FileSystemUri.ts
21
21
  import { platform } from "os";
@@ -78,6 +78,13 @@ var PhysicalFileSystem = class {
78
78
  return text;
79
79
  });
80
80
  }
81
+ directoryExists(uri) {
82
+ return __async(this, null, function* () {
83
+ const path = FileSystemUri.toPath(uri);
84
+ const stats = yield this.tryLstat(path);
85
+ return stats?.isDirectory() === true;
86
+ });
87
+ }
81
88
  readEntry(uri) {
82
89
  return __async(this, null, function* () {
83
90
  const path = FileSystemUri.toPath(uri);
@@ -192,6 +199,15 @@ var NodeCompiler = class {
192
199
  static get fileSystem() {
193
200
  return this.fileSystem_ ??= new PhysicalFileSystem();
194
201
  }
202
+ static validateInputPaths(inputPaths, diagnostics) {
203
+ const inputUris = {
204
+ projectUri: FileSystemUri.pathToUri(inputPaths.projectPath),
205
+ workspaceUri: inputPaths.workspacePath !== void 0 ? FileSystemUri.pathToUri(inputPaths.workspacePath) : void 0,
206
+ builtInsStandardPackagesUri: inputPaths.builtInsStandardPackagesPath !== void 0 ? FileSystemUri.pathToUri(inputPaths.builtInsStandardPackagesPath) : void 0,
207
+ userStandardPackagesUri: inputPaths.userStandardPackagesPath !== void 0 ? FileSystemUri.pathToUri(inputPaths.userStandardPackagesPath) : void 0
208
+ };
209
+ return Compiler.validateInputUris(inputUris, this.fileSystem, diagnostics);
210
+ }
195
211
  static findStandardTypeScriptLibrary(nodeModulesSearchPaths, defaultTsLibraryPath) {
196
212
  return __async(this, null, function* () {
197
213
  const nodeModulesSearchUris = nodeModulesSearchPaths.map((p) => FileSystemUri.pathToUri(p));
@@ -275,6 +291,16 @@ var NodeCompiler = class {
275
291
  }
276
292
  static compile(task) {
277
293
  return __async(this, null, function* () {
294
+ const inputPaths = {
295
+ projectPath: task.projectPath,
296
+ workspacePath: task.loadCompilationOptions?.workspacePath,
297
+ builtInsStandardPackagesPath: task.loadCompilationOptions?.builtInsStandardPackagesPath,
298
+ userStandardPackagesPath: task.loadCompilationOptions?.userStandardPackagesPath
299
+ };
300
+ const areValidInputPaths = yield this.validateInputPaths(inputPaths, task.diagnostics);
301
+ if (!areValidInputPaths) {
302
+ return void 0;
303
+ }
278
304
  const typeScriptLibrariesProvider = yield this.createTypeScriptLibrariesProvider(
279
305
  task.nodeModulesWithTypeScriptSearchPaths,
280
306
  task.defaultTsLibraryPath,
@@ -356,22 +382,25 @@ var CommandLineCompiler = class {
356
382
  }
357
383
  static run(args) {
358
384
  return __async(this, null, function* () {
359
- const parsedArguments = ArgumentsParser.parseArguments(args);
385
+ const argumentsDiagnostics = new PrintingDiagnosticAcceptor(false);
386
+ const parsedArguments = ArgumentsParser.parseArguments(args, argumentsDiagnostics);
360
387
  if (parsedArguments.command === void 0) {
361
388
  this.displayUsageMessage(parsedArguments);
362
389
  return this.errorExitCode;
363
390
  }
391
+ if (parsedArguments.hasErrors) {
392
+ return this.errorExitCode;
393
+ }
364
394
  if (parsedArguments.command === 5 /* Help */) {
365
395
  this.displayUsageMessage(parsedArguments);
366
- return this.errorExitCode;
396
+ return this.successExitCode;
367
397
  }
368
398
  if (parsedArguments.command === 4 /* Version */) {
369
399
  console.log(ArtelVersion);
370
400
  return this.successExitCode;
371
401
  }
372
402
  if (parsedArguments.projectPath === void 0 || parsedArguments.outputPath === void 0) {
373
- this.displayUsageMessage(parsedArguments);
374
- return this.successExitCode;
403
+ return this.errorExitCode;
375
404
  }
376
405
  if (parsedArguments.measurePerformance) {
377
406
  PerformanceMeasurement.isEnabled = true;
@@ -452,15 +481,16 @@ ${e.stack}`);
452
481
  shell: true,
453
482
  env: process.env
454
483
  });
455
- program.once("exit", (code) => resolve2(code ?? 0));
484
+ program.once("exit", (code) => resolve2(code ?? this.successExitCode));
456
485
  program.once("error", reject);
457
486
  });
458
487
  });
459
488
  }
460
489
  };
461
490
  var ArgumentsParser = class {
462
- static parseArguments(args) {
491
+ static parseArguments(args, diagnostics) {
463
492
  const result = {
493
+ hasErrors: false,
464
494
  command: void 0,
465
495
  projectPath: void 0,
466
496
  outputPath: void 0,
@@ -473,12 +503,13 @@ var ArgumentsParser = class {
473
503
  builtInStandardPackagesPath: void 0,
474
504
  attachSyntaxNodeUrisInCompiledCode: false
475
505
  };
476
- const index = this.parseMainCommand(0, args, result);
477
- this.parseNamedArguments(index, args, result);
506
+ const index = this.parseMainCommand(0, args, result, diagnostics);
507
+ this.parseNamedArguments(index, args, result, diagnostics);
478
508
  return result;
479
509
  }
480
- static parseMainCommand(index, args, result) {
481
- if (index < args.length && !args[index].startsWith("-")) {
510
+ static parseMainCommand(index, args, result, diagnostics) {
511
+ if (index < args.length) {
512
+ const commandText = args[index];
482
513
  result.command = this.getCommandKind(args[index]);
483
514
  index++;
484
515
  if (result.command !== void 0) {
@@ -492,11 +523,25 @@ var ArgumentsParser = class {
492
523
  if (projectPath !== void 0) {
493
524
  result.projectPath = resolve(cwd, projectPath);
494
525
  index++;
495
- const outputPath = this.tryParseStringArgument(index, args);
496
- if (outputPath !== void 0) {
497
- result.outputPath = resolve(cwd, outputPath);
498
- index++;
526
+ if (result.command !== 0 /* Setup */) {
527
+ const outputPath = this.tryParseStringArgument(index, args);
528
+ if (outputPath !== void 0) {
529
+ result.outputPath = resolve(cwd, outputPath);
530
+ index++;
531
+ } else {
532
+ diagnostics.addDiagnostic(new Diagnostic(
533
+ DiagnosticData.withCode(3016 /* ExpectedOutputDirectoryPath */),
534
+ void 0
535
+ ));
536
+ result.hasErrors = true;
537
+ }
499
538
  }
539
+ } else {
540
+ diagnostics.addDiagnostic(new Diagnostic(
541
+ DiagnosticData.withCode(3015 /* ExpectedProjectDirectoryPath */),
542
+ void 0
543
+ ));
544
+ result.hasErrors = true;
500
545
  }
501
546
  break;
502
547
  }
@@ -506,7 +551,19 @@ var ArgumentsParser = class {
506
551
  default:
507
552
  Debug.never(result.command);
508
553
  }
554
+ } else {
555
+ diagnostics.addDiagnostic(new Diagnostic(DiagnosticData.withCode(
556
+ 3013 /* UnknownCompilerCommand0 */,
557
+ [commandText]
558
+ ), void 0));
559
+ result.hasErrors = true;
509
560
  }
561
+ } else {
562
+ diagnostics.addDiagnostic(new Diagnostic(
563
+ DiagnosticData.withCode(3012 /* ExpectedCompilerCommand */),
564
+ void 0
565
+ ));
566
+ result.hasErrors = true;
510
567
  }
511
568
  return index;
512
569
  }
@@ -534,7 +591,7 @@ var ArgumentsParser = class {
534
591
  return void 0;
535
592
  }
536
593
  }
537
- static parseNamedArguments(index, args, result) {
594
+ static parseNamedArguments(index, args, result, diagnostics) {
538
595
  const cwd = process.cwd();
539
596
  for (; index < args.length; index++) {
540
597
  const argumentName = args[index];
@@ -544,7 +601,7 @@ var ArgumentsParser = class {
544
601
  switch (argumentName) {
545
602
  case "--\u0441\u0442\u0430\u043D\u0434\u0430\u0440\u0442\u043D\u0430\u044F-\u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430-type-script":
546
603
  case "--standard-type-script-library": {
547
- const path = this.tryParseStringArgument(index + 1, args);
604
+ const path = this.parseStringArgument(index + 1, args, argumentName, diagnostics, result);
548
605
  if (path !== void 0) {
549
606
  result.defaultTsLibraryPath = resolve(cwd, path);
550
607
  index++;
@@ -553,7 +610,7 @@ var ArgumentsParser = class {
553
610
  }
554
611
  case "--workspace":
555
612
  case "--\u0440\u0430\u0431\u043E\u0447\u0430\u044F-\u043E\u0431\u043B\u0430\u0441\u0442\u044C": {
556
- const path = this.tryParseStringArgument(index + 1, args);
613
+ const path = this.parseStringArgument(index + 1, args, argumentName, diagnostics, result);
557
614
  if (path !== void 0) {
558
615
  result.workspacePath = resolve(cwd, path);
559
616
  index++;
@@ -562,7 +619,7 @@ var ArgumentsParser = class {
562
619
  }
563
620
  case "--standard-packages":
564
621
  case "--\u0441\u0442\u0430\u043D\u0434\u0430\u0440\u0442\u043D\u044B\u0435-\u043F\u0430\u043A\u0435\u0442\u044B": {
565
- const path = this.tryParseStringArgument(index + 1, args);
622
+ const path = this.parseStringArgument(index + 1, args, argumentName, diagnostics, result);
566
623
  if (path !== void 0) {
567
624
  result.standardPackagesPath = resolve(cwd, path);
568
625
  index++;
@@ -571,7 +628,7 @@ var ArgumentsParser = class {
571
628
  }
572
629
  case "--built-in-standard-packages":
573
630
  case "--\u0432\u0441\u0442\u0440\u043E\u0435\u043D\u043D\u044B\u0435-\u0441\u0442\u0430\u043D\u0434\u0430\u0440\u0442\u043D\u044B\u0435-\u043F\u0430\u043A\u0435\u0442\u044B": {
574
- const path = this.tryParseStringArgument(index + 1, args);
631
+ const path = this.parseStringArgument(index + 1, args, argumentName, diagnostics, result);
575
632
  if (path !== void 0) {
576
633
  result.builtInStandardPackagesPath = resolve(cwd, path);
577
634
  index++;
@@ -598,9 +655,28 @@ var ArgumentsParser = class {
598
655
  result.attachSyntaxNodeUrisInCompiledCode = true;
599
656
  break;
600
657
  }
658
+ default: {
659
+ diagnostics.addDiagnostic(new Diagnostic(
660
+ DiagnosticData.withCode(3014 /* UnknownCommandLineArgument0 */, [argumentName]),
661
+ void 0
662
+ ));
663
+ result.hasErrors = true;
664
+ break;
665
+ }
601
666
  }
602
667
  }
603
668
  }
669
+ static parseStringArgument(index, args, name, diagnostics, parsedArguments) {
670
+ const result = this.tryParseStringArgument(index, args);
671
+ if (result === void 0) {
672
+ diagnostics.addDiagnostic(new Diagnostic(
673
+ DiagnosticData.withCode(3017 /* ExpectedTextValueForArgument0 */, [name]),
674
+ void 0
675
+ ));
676
+ parsedArguments.hasErrors = true;
677
+ }
678
+ return result;
679
+ }
604
680
  static tryParseStringArgument(index, args) {
605
681
  if (index < args.length && !args[index].startsWith("-")) {
606
682
  return args[index];
@@ -2,16 +2,103 @@ import {
2
2
  Analyzer,
3
3
  CompilationLoader,
4
4
  DefaultNamesOfDirectoriesToIgnore,
5
+ Diagnostic,
6
+ DiagnosticData,
5
7
  Emitter,
6
8
  SourceFileAnalyzer,
7
9
  SourcePackageDependencyGraph,
8
10
  WellKnownDeclarationsLoadError,
9
11
  __async,
10
12
  createTsInteropInputsForCompilation
11
- } from "./chunk-F62D5WPV.js";
13
+ } from "./chunk-ZV4RVSWH.js";
12
14
 
13
15
  // source/executor/Compiler.ts
14
16
  var Compiler = class {
17
+ static validateInputUris(inputUris, sourcesProvider, diagnostics) {
18
+ return __async(this, null, function* () {
19
+ if (!(yield sourcesProvider.directoryExists(inputUris.projectUri))) {
20
+ diagnostics?.addDiagnostic(new Diagnostic(DiagnosticData.withCode(
21
+ 3006 /* ProjectDirectoryDoesNotExist0 */,
22
+ [inputUris.projectUri.getFSPathWithFallback()]
23
+ ), void 0));
24
+ return false;
25
+ }
26
+ if (inputUris.workspaceUri !== void 0) {
27
+ if (!(yield sourcesProvider.directoryExists(inputUris.workspaceUri))) {
28
+ diagnostics?.addDiagnostic(new Diagnostic(
29
+ DiagnosticData.withCode(
30
+ 3008 /* WorkspaceDirectoryDoesNotExist0 */,
31
+ [inputUris.workspaceUri.getFSPathWithFallback()]
32
+ ),
33
+ void 0
34
+ ));
35
+ return false;
36
+ }
37
+ if (inputUris.projectUri.checkIfRelativeTo(inputUris.workspaceUri) === 2 /* NotRelativeOrEqual */) {
38
+ diagnostics?.addDiagnostic(new Diagnostic(
39
+ DiagnosticData.withCode(
40
+ 3009 /* ProjectDirectory0MustBeNestedInWorkspaceDirectory1 */,
41
+ [inputUris.projectUri.getFSPathWithFallback(), inputUris.workspaceUri.getFSPathWithFallback()]
42
+ ),
43
+ void 0
44
+ ));
45
+ return false;
46
+ }
47
+ }
48
+ if (inputUris.userStandardPackagesUri !== void 0) {
49
+ if (!(yield sourcesProvider.directoryExists(inputUris.userStandardPackagesUri))) {
50
+ diagnostics?.addDiagnostic(new Diagnostic(
51
+ DiagnosticData.withCode(
52
+ 3007 /* StandardPackagesDirectoryDoesNotExist0 */,
53
+ [inputUris.userStandardPackagesUri.getFSPathWithFallback()]
54
+ ),
55
+ void 0
56
+ ));
57
+ return false;
58
+ }
59
+ if (inputUris.workspaceUri !== void 0) {
60
+ if (inputUris.userStandardPackagesUri.checkIfRelativeTo(inputUris.workspaceUri) === 2 /* NotRelativeOrEqual */) {
61
+ diagnostics?.addDiagnostic(new Diagnostic(
62
+ DiagnosticData.withCode(
63
+ 3011 /* StandardPackagesDirectory0MustBeNestedInWorkspaceDirectory1 */,
64
+ [
65
+ inputUris.userStandardPackagesUri.getFSPathWithFallback(),
66
+ inputUris.workspaceUri.getFSPathWithFallback()
67
+ ]
68
+ ),
69
+ void 0
70
+ ));
71
+ return false;
72
+ }
73
+ } else {
74
+ if (inputUris.userStandardPackagesUri.checkIfRelativeTo(inputUris.projectUri) === 2 /* NotRelativeOrEqual */) {
75
+ diagnostics?.addDiagnostic(new Diagnostic(
76
+ DiagnosticData.withCode(
77
+ 3010 /* StandardPackagesDirectory0MustBeNestedInProjectDirectory1 */,
78
+ [
79
+ inputUris.userStandardPackagesUri.getFSPathWithFallback(),
80
+ inputUris.projectUri.getFSPathWithFallback()
81
+ ]
82
+ ),
83
+ void 0
84
+ ));
85
+ return false;
86
+ }
87
+ }
88
+ }
89
+ if (inputUris.builtInsStandardPackagesUri !== void 0 && !(yield sourcesProvider.directoryExists(inputUris.builtInsStandardPackagesUri))) {
90
+ diagnostics?.addDiagnostic(new Diagnostic(
91
+ DiagnosticData.withCode(
92
+ 3007 /* StandardPackagesDirectoryDoesNotExist0 */,
93
+ [inputUris.builtInsStandardPackagesUri.getFSPathWithFallback()]
94
+ ),
95
+ void 0
96
+ ));
97
+ return false;
98
+ }
99
+ return true;
100
+ });
101
+ }
15
102
  static loadCompilation(projectUri, sourcesProvider, tsLibrariesProvider, diagnostics, taskController, options) {
16
103
  return __async(this, null, function* () {
17
104
  const loaderOptions = {