@powerlines/nx 0.5.0 → 0.5.2
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/CHANGELOG.md +14 -0
- package/dist/{chunk-GPR4LRJV.js → chunk-6COOH7PT.js} +2 -2
- package/dist/{chunk-E5KDMPYX.mjs → chunk-6EYSDBXF.mjs} +1 -1
- package/dist/{chunk-5DSETHHW.js → chunk-BJ4E5KUK.js} +2 -2
- package/dist/{chunk-CNNNEVWJ.mjs → chunk-FQGP7LHQ.mjs} +1 -1
- package/dist/{chunk-LRONVULK.js → chunk-FW5WOOGV.js} +141 -613
- package/dist/{chunk-RK2TJCMI.js → chunk-ID7Q55KI.js} +2 -2
- package/dist/{chunk-THDQE26D.mjs → chunk-K2URIO44.mjs} +1 -1
- package/dist/{chunk-2KAWJURA.js → chunk-QARFJCME.js} +2 -2
- package/dist/{chunk-UQ4OVGQQ.mjs → chunk-RVNLAQU5.mjs} +133 -604
- package/dist/{chunk-J2XU6B3K.js → chunk-USVD3RLO.js} +2 -2
- package/dist/{chunk-KO42I6KA.mjs → chunk-V73NN5FH.mjs} +1 -1
- package/dist/{chunk-QAEGJGQS.mjs → chunk-YZ7FHAGJ.mjs} +1 -1
- package/dist/executors.js +11 -11
- package/dist/executors.mjs +6 -6
- package/dist/index.js +11 -11
- package/dist/index.mjs +6 -6
- package/dist/src/base/base-executor.js +2 -2
- package/dist/src/base/base-executor.mjs +1 -1
- package/dist/src/executors/build/executor.js +4 -4
- package/dist/src/executors/build/executor.mjs +2 -2
- package/dist/src/executors/clean/executor.js +4 -4
- package/dist/src/executors/clean/executor.mjs +2 -2
- package/dist/src/executors/docs/executor.js +4 -4
- package/dist/src/executors/docs/executor.mjs +2 -2
- package/dist/src/executors/lint/executor.js +4 -4
- package/dist/src/executors/lint/executor.mjs +2 -2
- package/dist/src/executors/prepare/executor.js +4 -4
- package/dist/src/executors/prepare/executor.mjs +2 -2
- package/package.json +12 -12
|
@@ -6,7 +6,7 @@ var logger = require('@storm-software/config-tools/logger');
|
|
|
6
6
|
var baseExecutor = require('@storm-software/workspace-tools/base/base-executor');
|
|
7
7
|
var isError = require('@stryke/type-checks/is-error');
|
|
8
8
|
var defu4 = require('defu');
|
|
9
|
-
var console
|
|
9
|
+
var console = require('@storm-software/config-tools/logger/console');
|
|
10
10
|
var types = require('@storm-software/config-tools/types');
|
|
11
11
|
var toArray = require('@stryke/convert/to-array');
|
|
12
12
|
var copyFile = require('@stryke/fs/copy-file');
|
|
@@ -28,7 +28,7 @@ var chalk5 = require('chalk');
|
|
|
28
28
|
var Handlebars = require('handlebars');
|
|
29
29
|
var json = require('@stryke/fs/json');
|
|
30
30
|
var append = require('@stryke/path/append');
|
|
31
|
-
var
|
|
31
|
+
var ts2 = require('typescript');
|
|
32
32
|
var titleCase = require('@stryke/string-format/title-case');
|
|
33
33
|
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
34
34
|
var writeFile$1 = require('@stryke/fs/write-file');
|
|
@@ -56,20 +56,15 @@ var buffer = require('buffer');
|
|
|
56
56
|
var fs = require('fs');
|
|
57
57
|
var unionfs = require('unionfs');
|
|
58
58
|
var isObject = require('@stryke/type-checks/is-object');
|
|
59
|
-
var isFile = require('@stryke/fs/is-file');
|
|
60
|
-
var readFile = require('@stryke/fs/read-file');
|
|
61
|
-
var semverFns = require('@stryke/fs/semver-fns');
|
|
62
|
-
var getParentPath = require('@stryke/path/get-parent-path');
|
|
63
|
-
var path = require('path');
|
|
64
|
-
var _package = require('@stryke/string-format/package');
|
|
65
59
|
var core = require('@babel/core');
|
|
60
|
+
var readFile = require('@stryke/fs/read-file');
|
|
66
61
|
var MagicString = require('magic-string');
|
|
67
62
|
var helperPluginUtils = require('@babel/helper-plugin-utils');
|
|
68
63
|
var t = require('@babel/types');
|
|
64
|
+
var _package = require('@stryke/string-format/package');
|
|
69
65
|
var superdiff = require('@donedeal0/superdiff');
|
|
70
66
|
var tsconfig = require('@stryke/fs/tsconfig');
|
|
71
67
|
var stormJson = require('@stryke/json/storm-json');
|
|
72
|
-
var minimatch = require('minimatch');
|
|
73
68
|
var environmentChecks = require('@stryke/env/environment-checks');
|
|
74
69
|
var unplugin = require('unplugin');
|
|
75
70
|
var bundleRequire = require('bundle-require');
|
|
@@ -99,9 +94,8 @@ function _interopNamespace(e) {
|
|
|
99
94
|
var defu4__default = /*#__PURE__*/_interopDefault(defu4);
|
|
100
95
|
var chalk5__default = /*#__PURE__*/_interopDefault(chalk5);
|
|
101
96
|
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
102
|
-
var
|
|
97
|
+
var ts2__default = /*#__PURE__*/_interopDefault(ts2);
|
|
103
98
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
104
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
105
99
|
var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
|
|
106
100
|
var t__namespace = /*#__PURE__*/_interopNamespace(t);
|
|
107
101
|
|
|
@@ -166,13 +160,13 @@ function isIncludeMatchFound(tsconfigType, types) {
|
|
|
166
160
|
return findIncludeMatch(tsconfigType, types) !== void 0;
|
|
167
161
|
}
|
|
168
162
|
chunkSHUYVCID_js.__name(isIncludeMatchFound, "isIncludeMatchFound");
|
|
169
|
-
function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host =
|
|
163
|
+
function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = ts2__default.default.sys) {
|
|
170
164
|
const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
|
|
171
165
|
const tsconfigJson = json.readJsonFileSync(tsconfigFilePath);
|
|
172
166
|
if (!tsconfigJson) {
|
|
173
167
|
throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths.joinPaths(projectRoot, tsconfig ?? "tsconfig.json")}`);
|
|
174
168
|
}
|
|
175
|
-
const parsedCommandLine =
|
|
169
|
+
const parsedCommandLine = ts2__default.default.parseJsonConfigFileContent(defu4__default.default(tsconfigRaw ?? {}, tsconfigJson), host, append.appendPath(projectRoot, workspaceRoot));
|
|
176
170
|
if (parsedCommandLine.errors.length > 0) {
|
|
177
171
|
const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
|
|
178
172
|
${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
|
|
@@ -621,7 +615,7 @@ var VirtualFileSystem = class {
|
|
|
621
615
|
* @returns `true` if the path or ID corresponds to a runtime file, otherwise `false`.
|
|
622
616
|
*/
|
|
623
617
|
isBuiltinFile(pathOrId, options) {
|
|
624
|
-
return !!this.builtinIdMap.values().find((
|
|
618
|
+
return !!this.builtinIdMap.values().find((path) => path === this.resolvePath(pathOrId, {
|
|
625
619
|
...options,
|
|
626
620
|
type: "file"
|
|
627
621
|
}));
|
|
@@ -653,7 +647,7 @@ var VirtualFileSystem = class {
|
|
|
653
647
|
if (!resolvedPath) {
|
|
654
648
|
return false;
|
|
655
649
|
}
|
|
656
|
-
if (this.builtinIdMap.values().find((
|
|
650
|
+
if (this.builtinIdMap.values().find((path) => path === resolvedPath)) {
|
|
657
651
|
return true;
|
|
658
652
|
}
|
|
659
653
|
return this.#virtualFS.existsSync(resolvedPath);
|
|
@@ -667,7 +661,7 @@ var VirtualFileSystem = class {
|
|
|
667
661
|
* @returns Whether the path or ID corresponds to a virtual file.
|
|
668
662
|
*/
|
|
669
663
|
isTsconfigPath(pathOrId) {
|
|
670
|
-
return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((
|
|
664
|
+
return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((path) => pathOrId.startsWith(path.replaceAll("*", "")));
|
|
671
665
|
}
|
|
672
666
|
/**
|
|
673
667
|
* Checks if a given ID corresponds to a runtime file path.
|
|
@@ -688,12 +682,12 @@ var VirtualFileSystem = class {
|
|
|
688
682
|
*/
|
|
689
683
|
async listBuiltinFiles() {
|
|
690
684
|
const runtimeFiles = [];
|
|
691
|
-
for (const [id,
|
|
692
|
-
const contents = await this.readFile(
|
|
685
|
+
for (const [id, path] of this.builtinIdMap.entries()) {
|
|
686
|
+
const contents = await this.readFile(path);
|
|
693
687
|
if (contents) {
|
|
694
688
|
runtimeFiles.push({
|
|
695
689
|
id: this.formatRuntimeId(id),
|
|
696
|
-
path
|
|
690
|
+
path,
|
|
697
691
|
contents
|
|
698
692
|
});
|
|
699
693
|
}
|
|
@@ -707,21 +701,21 @@ var VirtualFileSystem = class {
|
|
|
707
701
|
* @param options - Options for listing files, such as encoding and recursion.
|
|
708
702
|
* @returns An array of file names in the specified path.
|
|
709
703
|
*/
|
|
710
|
-
readdirSync(
|
|
711
|
-
return this.resolveFS(
|
|
704
|
+
readdirSync(path, options = "utf8") {
|
|
705
|
+
return this.resolveFS(path).readdirSync(toFilePath(path), options);
|
|
712
706
|
}
|
|
713
707
|
/**
|
|
714
708
|
* Removes a file in the virtual file system (VFS).
|
|
715
709
|
*
|
|
716
710
|
* @param path - The path to create the directory at.
|
|
717
711
|
*/
|
|
718
|
-
unlinkSync(
|
|
719
|
-
const formattedPath = toFilePath(
|
|
720
|
-
if (!this.fileExistsSync(
|
|
712
|
+
unlinkSync(path, options) {
|
|
713
|
+
const formattedPath = toFilePath(path);
|
|
714
|
+
if (!this.fileExistsSync(path)) {
|
|
721
715
|
return;
|
|
722
716
|
}
|
|
723
717
|
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
|
|
724
|
-
this.resolveFS(
|
|
718
|
+
this.resolveFS(path, options).unlinkSync(formattedPath);
|
|
725
719
|
this.#cachedFS.delete(formattedPath);
|
|
726
720
|
this.clearResolverCache(formattedPath);
|
|
727
721
|
}
|
|
@@ -730,14 +724,14 @@ var VirtualFileSystem = class {
|
|
|
730
724
|
*
|
|
731
725
|
* @param path - The path to create the directory at.
|
|
732
726
|
*/
|
|
733
|
-
async unlink(
|
|
734
|
-
const formattedPath = toFilePath(
|
|
735
|
-
if (!this.fileExistsSync(
|
|
727
|
+
async unlink(path, options) {
|
|
728
|
+
const formattedPath = toFilePath(path);
|
|
729
|
+
if (!this.fileExistsSync(path)) {
|
|
736
730
|
return;
|
|
737
731
|
}
|
|
738
732
|
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
|
|
739
|
-
if (isFunction.isFunction(this.resolveFS(
|
|
740
|
-
await this.resolveFS(
|
|
733
|
+
if (isFunction.isFunction(this.resolveFS(path, options).promises.unlink)) {
|
|
734
|
+
await this.resolveFS(path, options).promises.unlink(formattedPath);
|
|
741
735
|
this.#cachedFS.delete(formattedPath);
|
|
742
736
|
this.clearResolverCache(formattedPath);
|
|
743
737
|
} else {
|
|
@@ -750,13 +744,13 @@ var VirtualFileSystem = class {
|
|
|
750
744
|
* @param path - The path to create the directory at.
|
|
751
745
|
* @param options - Options for creating the directory.
|
|
752
746
|
*/
|
|
753
|
-
rmdirSync(
|
|
754
|
-
const formattedPath = toFilePath(
|
|
755
|
-
if (!this.directoryExistsSync(
|
|
747
|
+
rmdirSync(path, options = {}) {
|
|
748
|
+
const formattedPath = toFilePath(path);
|
|
749
|
+
if (!this.directoryExistsSync(path)) {
|
|
756
750
|
return;
|
|
757
751
|
}
|
|
758
752
|
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
|
|
759
|
-
this.resolveFS(
|
|
753
|
+
this.resolveFS(path, options).rmdirSync(formattedPath, defu4__default.default(options, {
|
|
760
754
|
recursive: true
|
|
761
755
|
}));
|
|
762
756
|
this.#cachedFS.delete(formattedPath);
|
|
@@ -769,14 +763,14 @@ var VirtualFileSystem = class {
|
|
|
769
763
|
* @param options - Options for creating the directory.
|
|
770
764
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
771
765
|
*/
|
|
772
|
-
async rmdir(
|
|
773
|
-
const formattedPath = toFilePath(
|
|
774
|
-
if (!this.directoryExistsSync(
|
|
766
|
+
async rmdir(path, options = {}) {
|
|
767
|
+
const formattedPath = toFilePath(path);
|
|
768
|
+
if (!this.directoryExistsSync(path)) {
|
|
775
769
|
return;
|
|
776
770
|
}
|
|
777
771
|
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
|
|
778
|
-
if (isFunction.isFunction(this.resolveFS(
|
|
779
|
-
await this.resolveFS(
|
|
772
|
+
if (isFunction.isFunction(this.resolveFS(path, options).promises.rm)) {
|
|
773
|
+
await this.resolveFS(path, options).promises.rm(formattedPath, defu4__default.default(options, {
|
|
780
774
|
force: true,
|
|
781
775
|
recursive: true
|
|
782
776
|
}));
|
|
@@ -796,12 +790,12 @@ var VirtualFileSystem = class {
|
|
|
796
790
|
* @param options - Options for removing the file.
|
|
797
791
|
* @returns A promise that resolves when the file is removed.
|
|
798
792
|
*/
|
|
799
|
-
async rm(
|
|
800
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${toFilePath(
|
|
801
|
-
if (this.directoryExistsSync(
|
|
802
|
-
return this.rmdir(
|
|
793
|
+
async rm(path, options = {}) {
|
|
794
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
|
|
795
|
+
if (this.directoryExistsSync(path)) {
|
|
796
|
+
return this.rmdir(path, options);
|
|
803
797
|
}
|
|
804
|
-
return this.unlink(
|
|
798
|
+
return this.unlink(path, options);
|
|
805
799
|
}
|
|
806
800
|
/**
|
|
807
801
|
* Creates a directory in the virtual file system (VFS).
|
|
@@ -810,8 +804,8 @@ var VirtualFileSystem = class {
|
|
|
810
804
|
* @param options - Options for creating the directory.
|
|
811
805
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
812
806
|
*/
|
|
813
|
-
mkdirSync(
|
|
814
|
-
const filePath = toFilePath(
|
|
807
|
+
mkdirSync(path, options = {}) {
|
|
808
|
+
const filePath = toFilePath(path);
|
|
815
809
|
this.clearResolverCache(filePath);
|
|
816
810
|
return this.resolveFS(filePath, options).mkdirSync(filePath, defu4__default.default(options ?? {}, {
|
|
817
811
|
recursive: true
|
|
@@ -824,9 +818,9 @@ var VirtualFileSystem = class {
|
|
|
824
818
|
* @param options - Options for creating the directory.
|
|
825
819
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
826
820
|
*/
|
|
827
|
-
async mkdir(
|
|
821
|
+
async mkdir(path, options = {}) {
|
|
828
822
|
let result;
|
|
829
|
-
const filePath = toFilePath(
|
|
823
|
+
const filePath = toFilePath(path);
|
|
830
824
|
if (isFunction.isFunction(this.resolveFS(filePath, options).promises.mkdir)) {
|
|
831
825
|
result = await this.resolveFS(filePath, options).promises.mkdir(filePath, defu4__default.default(options ?? {}, {
|
|
832
826
|
recursive: true
|
|
@@ -846,8 +840,8 @@ var VirtualFileSystem = class {
|
|
|
846
840
|
* @param options - Options for listing files, such as encoding and recursion.
|
|
847
841
|
* @returns An array of file names in the specified path.
|
|
848
842
|
*/
|
|
849
|
-
async readdir(
|
|
850
|
-
return this.resolveFS(
|
|
843
|
+
async readdir(path, options = "utf8") {
|
|
844
|
+
return this.resolveFS(path).promises.readdir(toFilePath(path), options);
|
|
851
845
|
}
|
|
852
846
|
/**
|
|
853
847
|
* Asynchronously reads a file from the virtual file system (VFS).
|
|
@@ -961,9 +955,9 @@ var VirtualFileSystem = class {
|
|
|
961
955
|
* @param options - Optional parameters for writing the runtime file.
|
|
962
956
|
* @returns A promise that resolves when the file is written.
|
|
963
957
|
*/
|
|
964
|
-
async writeBuiltinFile(id,
|
|
958
|
+
async writeBuiltinFile(id, path, contents, options = {}) {
|
|
965
959
|
const formattedId = this.formatRuntimeId(id);
|
|
966
|
-
const absolutePath = this.formatAbsoluteFilePath(toFilePath(
|
|
960
|
+
const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
967
961
|
this.builtinIdMap.set(formattedId, absolutePath);
|
|
968
962
|
let data = contents;
|
|
969
963
|
if (!options.skipFormat) {
|
|
@@ -1010,8 +1004,8 @@ var VirtualFileSystem = class {
|
|
|
1010
1004
|
* @param options - Optional parameters for writing the file.
|
|
1011
1005
|
* @returns A promise that resolves when the file is written.
|
|
1012
1006
|
*/
|
|
1013
|
-
async writeFileToDisk(
|
|
1014
|
-
const absolutePath = this.formatAbsoluteFilePath(toFilePath(
|
|
1007
|
+
async writeFileToDisk(path, contents, options = {}) {
|
|
1008
|
+
const absolutePath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
1015
1009
|
let data = contents;
|
|
1016
1010
|
if (!options.skipFormat) {
|
|
1017
1011
|
const resolvedConfig = await prettier.resolveConfig(absolutePath);
|
|
@@ -1046,9 +1040,9 @@ var VirtualFileSystem = class {
|
|
|
1046
1040
|
* @param path - The path of the file to check.
|
|
1047
1041
|
* @returns `true` if the file exists, otherwise `false`.
|
|
1048
1042
|
*/
|
|
1049
|
-
fileExistsSync(
|
|
1050
|
-
const formattedPath = this.formatAbsoluteFilePath(toFilePath(
|
|
1051
|
-
return this.isValidBuiltinId(formattedPath) || this.#virtualFS.existsSync(formattedPath) && this.#virtualFS.lstatSync(formattedPath).isFile() || this.#fs.existsSync(formattedPath) && this.#fs.lstatSync(formattedPath).isFile() || this.resolveFS(
|
|
1043
|
+
fileExistsSync(path) {
|
|
1044
|
+
const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
1045
|
+
return this.isValidBuiltinId(formattedPath) || this.#virtualFS.existsSync(formattedPath) && this.#virtualFS.lstatSync(formattedPath).isFile() || this.#fs.existsSync(formattedPath) && this.#fs.lstatSync(formattedPath).isFile() || this.resolveFS(path).existsSync(formattedPath) && this.resolveFS(path).lstatSync(formattedPath).isFile();
|
|
1052
1046
|
}
|
|
1053
1047
|
/**
|
|
1054
1048
|
* Checks if a directory exists in the virtual file system (VFS).
|
|
@@ -1056,9 +1050,9 @@ var VirtualFileSystem = class {
|
|
|
1056
1050
|
* @param path - The path of the directory to check.
|
|
1057
1051
|
* @returns `true` if the directory exists, otherwise `false`.
|
|
1058
1052
|
*/
|
|
1059
|
-
directoryExistsSync(
|
|
1060
|
-
const formattedPath = this.formatAbsoluteFilePath(toFilePath(
|
|
1061
|
-
return this.#virtualFS.existsSync(formattedPath) && this.#virtualFS.lstatSync(formattedPath).isDirectory() || this.#fs.existsSync(formattedPath) && this.#fs.lstatSync(formattedPath).isDirectory() || this.resolveFS(
|
|
1053
|
+
directoryExistsSync(path) {
|
|
1054
|
+
const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
1055
|
+
return this.#virtualFS.existsSync(formattedPath) && this.#virtualFS.lstatSync(formattedPath).isDirectory() || this.#fs.existsSync(formattedPath) && this.#fs.lstatSync(formattedPath).isDirectory() || this.resolveFS(path).existsSync(formattedPath) && this.resolveFS(path).lstatSync(formattedPath).isDirectory();
|
|
1062
1056
|
}
|
|
1063
1057
|
/**
|
|
1064
1058
|
* Checks if a path exists in the virtual file system (VFS).
|
|
@@ -1066,9 +1060,9 @@ var VirtualFileSystem = class {
|
|
|
1066
1060
|
* @param path - The path to check.
|
|
1067
1061
|
* @returns `true` if the path exists, otherwise `false`.
|
|
1068
1062
|
*/
|
|
1069
|
-
pathExistsSync(
|
|
1070
|
-
const formattedPath = this.formatAbsoluteFilePath(toFilePath(
|
|
1071
|
-
return this.isValidBuiltinId(formattedPath) || this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(
|
|
1063
|
+
pathExistsSync(path) {
|
|
1064
|
+
const formattedPath = this.formatAbsoluteFilePath(toFilePath(path));
|
|
1065
|
+
return this.isValidBuiltinId(formattedPath) || this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
|
|
1072
1066
|
}
|
|
1073
1067
|
/**
|
|
1074
1068
|
* Retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -1130,12 +1124,12 @@ var VirtualFileSystem = class {
|
|
|
1130
1124
|
* @param path - The path to check.
|
|
1131
1125
|
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1132
1126
|
*/
|
|
1133
|
-
resolveTsconfigPath(
|
|
1127
|
+
resolveTsconfigPath(path) {
|
|
1134
1128
|
if (this.#context.tsconfig.options.paths) {
|
|
1135
|
-
for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) =>
|
|
1136
|
-
const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePathName(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""),
|
|
1129
|
+
for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")))) {
|
|
1130
|
+
const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePathName(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatAbsoluteFilePath(tsconfigPath) === this.formatAbsoluteFilePath(path));
|
|
1137
1131
|
if (resolvedPath) {
|
|
1138
|
-
return this.formatAbsoluteFilePath(resolvedPath) === this.formatAbsoluteFilePath(
|
|
1132
|
+
return this.formatAbsoluteFilePath(resolvedPath) === this.formatAbsoluteFilePath(path) ? this.formatAbsoluteFilePath(resolvedPath) : this.resolvePathName(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
|
|
1139
1133
|
}
|
|
1140
1134
|
}
|
|
1141
1135
|
}
|
|
@@ -1149,9 +1143,9 @@ var VirtualFileSystem = class {
|
|
|
1149
1143
|
* @param path - The path to check.
|
|
1150
1144
|
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1151
1145
|
*/
|
|
1152
|
-
resolveTsconfigPathPackage(
|
|
1146
|
+
resolveTsconfigPathPackage(path) {
|
|
1153
1147
|
if (this.#context.tsconfig.options.paths) {
|
|
1154
|
-
const tsconfigPathKeys = Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) =>
|
|
1148
|
+
const tsconfigPathKeys = Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")));
|
|
1155
1149
|
if (tsconfigPathKeys.length > 0 && tsconfigPathKeys[0]) {
|
|
1156
1150
|
return tsconfigPathKeys[0].replace(/\/\*$/, "");
|
|
1157
1151
|
}
|
|
@@ -1209,11 +1203,11 @@ var VirtualFileSystem = class {
|
|
|
1209
1203
|
* @param path - The file path to format.
|
|
1210
1204
|
* @returns The formatted file path.
|
|
1211
1205
|
*/
|
|
1212
|
-
formatFilePath(
|
|
1213
|
-
if (!isSetString.isSetString(
|
|
1206
|
+
formatFilePath(path) {
|
|
1207
|
+
if (!isSetString.isSetString(path)) {
|
|
1214
1208
|
throw new Error(`Invalid path provided. Expected a string or a valid file path.`);
|
|
1215
1209
|
}
|
|
1216
|
-
return
|
|
1210
|
+
return path.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "");
|
|
1217
1211
|
}
|
|
1218
1212
|
/**
|
|
1219
1213
|
* Converts a relative path to an absolute path based on the workspace and project root.
|
|
@@ -1221,8 +1215,8 @@ var VirtualFileSystem = class {
|
|
|
1221
1215
|
* @param path - The relative path to convert.
|
|
1222
1216
|
* @returns The absolute path.
|
|
1223
1217
|
*/
|
|
1224
|
-
formatAbsoluteFilePath = /* @__PURE__ */ chunkSHUYVCID_js.__name((
|
|
1225
|
-
const formattedPath = this.formatFilePath(
|
|
1218
|
+
formatAbsoluteFilePath = /* @__PURE__ */ chunkSHUYVCID_js.__name((path) => {
|
|
1219
|
+
const formattedPath = this.formatFilePath(path);
|
|
1226
1220
|
if (isType.isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
|
|
1227
1221
|
return formattedPath;
|
|
1228
1222
|
} else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
|
|
@@ -1258,8 +1252,8 @@ var VirtualFileSystem = class {
|
|
|
1258
1252
|
return result;
|
|
1259
1253
|
}
|
|
1260
1254
|
}
|
|
1261
|
-
for (const
|
|
1262
|
-
const request = joinPaths.joinPaths(
|
|
1255
|
+
for (const path of this.resolveParentPaths(pathOrId, options.paths)) {
|
|
1256
|
+
const request = joinPaths.joinPaths(path, pathOrId);
|
|
1263
1257
|
if (options.type === "file" ? this.fileExistsSync(pathOrId) : this.pathExistsSync(pathOrId)) {
|
|
1264
1258
|
return request;
|
|
1265
1259
|
}
|
|
@@ -1276,16 +1270,16 @@ var VirtualFileSystem = class {
|
|
|
1276
1270
|
joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
|
|
1277
1271
|
];
|
|
1278
1272
|
if (this.#context.tsconfig.options.paths) {
|
|
1279
|
-
paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret,
|
|
1280
|
-
if (
|
|
1281
|
-
ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot,
|
|
1273
|
+
paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
|
|
1274
|
+
if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
|
|
1275
|
+
ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
|
|
1282
1276
|
}
|
|
1283
1277
|
return ret;
|
|
1284
1278
|
}, paths) : paths;
|
|
1285
1279
|
}
|
|
1286
|
-
return paths.reduce((ret,
|
|
1287
|
-
if (!ret.includes(
|
|
1288
|
-
ret.push(
|
|
1280
|
+
return paths.reduce((ret, path) => {
|
|
1281
|
+
if (!ret.includes(path)) {
|
|
1282
|
+
ret.push(path);
|
|
1289
1283
|
}
|
|
1290
1284
|
return ret;
|
|
1291
1285
|
}, current.filter(Boolean).map((p) => this.formatAbsoluteFilePath(toFilePath(p))));
|
|
@@ -1326,8 +1320,8 @@ var VirtualFileSystem = class {
|
|
|
1326
1320
|
*
|
|
1327
1321
|
* @param path - The path to clear the resolver cache for.
|
|
1328
1322
|
*/
|
|
1329
|
-
clearResolverCache(
|
|
1330
|
-
this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(
|
|
1323
|
+
clearResolverCache(path) {
|
|
1324
|
+
this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
|
|
1331
1325
|
}
|
|
1332
1326
|
};
|
|
1333
1327
|
var FILE_PREFIX = "file://";
|
|
@@ -1463,12 +1457,12 @@ function patchFS(originalFS, vfs) {
|
|
|
1463
1457
|
}
|
|
1464
1458
|
chunkSHUYVCID_js.__name(patchFS, "patchFS");
|
|
1465
1459
|
function checkVariants(request, vfs, parentPath) {
|
|
1466
|
-
const
|
|
1467
|
-
let file = checkExtensions(
|
|
1460
|
+
const path = parentPath ? joinPaths.joinPaths(parentPath, request) : request;
|
|
1461
|
+
let file = checkExtensions(path, vfs);
|
|
1468
1462
|
if (file) {
|
|
1469
1463
|
return file;
|
|
1470
1464
|
}
|
|
1471
|
-
file = checkIndex(
|
|
1465
|
+
file = checkIndex(path, vfs);
|
|
1472
1466
|
if (file) {
|
|
1473
1467
|
return file;
|
|
1474
1468
|
}
|
|
@@ -2305,381 +2299,6 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
|
|
|
2305
2299
|
}
|
|
2306
2300
|
}
|
|
2307
2301
|
};
|
|
2308
|
-
async function installPackage(context, packageName, dev = false) {
|
|
2309
|
-
const isListed = await packageFns.isPackageListed(packageName, {
|
|
2310
|
-
cwd: context.config.projectRoot
|
|
2311
|
-
});
|
|
2312
|
-
if (!isListed) {
|
|
2313
|
-
if (context.config.skipInstalls !== true && !process.env.POWERLINES_LOCAL) {
|
|
2314
|
-
context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`);
|
|
2315
|
-
const result = await install.install(packageName, {
|
|
2316
|
-
cwd: context.config.projectRoot,
|
|
2317
|
-
dev
|
|
2318
|
-
});
|
|
2319
|
-
if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
|
|
2320
|
-
context.log(types.LogLevelLabel.ERROR, result.stderr);
|
|
2321
|
-
throw new Error(`An error occurred while installing the package "${packageName}"`);
|
|
2322
|
-
}
|
|
2323
|
-
} else {
|
|
2324
|
-
context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`);
|
|
2325
|
-
}
|
|
2326
|
-
} else if (_package.hasPackageVersion(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
|
|
2327
|
-
const isMatching = await packageFns.doesPackageMatch(_package.getPackageName(packageName), _package.getPackageVersion(packageName), context.config.projectRoot);
|
|
2328
|
-
if (!isMatching) {
|
|
2329
|
-
const packageListing = await packageFns.getPackageListing(_package.getPackageName(packageName), {
|
|
2330
|
-
cwd: context.config.projectRoot
|
|
2331
|
-
});
|
|
2332
|
-
if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) {
|
|
2333
|
-
context.log(types.LogLevelLabel.WARN, `The package "${_package.getPackageName(packageName)}" is installed but does not match the expected version ${_package.getPackageVersion(packageName)} (installed version: ${packageListing?.version || "<Unknown>"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`);
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
chunkSHUYVCID_js.__name(installPackage, "installPackage");
|
|
2339
|
-
async function installPackages(context, packages) {
|
|
2340
|
-
return Promise.all(packages.map(async (pkg) => installPackage(context, pkg.name, pkg.dev)));
|
|
2341
|
-
}
|
|
2342
|
-
chunkSHUYVCID_js.__name(installPackages, "installPackages");
|
|
2343
|
-
|
|
2344
|
-
// ../powerlines/src/internal/helpers/eslint.ts
|
|
2345
|
-
var MessageSeverity;
|
|
2346
|
-
(function(MessageSeverity2) {
|
|
2347
|
-
MessageSeverity2[MessageSeverity2["Warning"] = 1] = "Warning";
|
|
2348
|
-
MessageSeverity2[MessageSeverity2["Error"] = 2] = "Error";
|
|
2349
|
-
})(MessageSeverity || (MessageSeverity = {}));
|
|
2350
|
-
function pluginCount(messages) {
|
|
2351
|
-
let nextPluginWarningCount = 0;
|
|
2352
|
-
let nextPluginErrorCount = 0;
|
|
2353
|
-
for (let i = 0; i < messages.length; i++) {
|
|
2354
|
-
const { severity, ruleId } = messages[i];
|
|
2355
|
-
if (ruleId?.includes("powerlines")) {
|
|
2356
|
-
if (severity === 1) {
|
|
2357
|
-
nextPluginWarningCount += 1;
|
|
2358
|
-
} else {
|
|
2359
|
-
nextPluginErrorCount += 1;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
return {
|
|
2364
|
-
nextPluginErrorCount,
|
|
2365
|
-
nextPluginWarningCount
|
|
2366
|
-
};
|
|
2367
|
-
}
|
|
2368
|
-
chunkSHUYVCID_js.__name(pluginCount, "pluginCount");
|
|
2369
|
-
function formatMessage(dir, messages, filePath) {
|
|
2370
|
-
let fileName = path__default.default.posix.normalize(path__default.default.relative(dir, filePath).replace(/\\/g, "/"));
|
|
2371
|
-
if (!fileName.startsWith(".")) {
|
|
2372
|
-
fileName = `./${fileName}`;
|
|
2373
|
-
}
|
|
2374
|
-
let output = `
|
|
2375
|
-
${fileName}`;
|
|
2376
|
-
for (let i = 0; i < messages.length; i++) {
|
|
2377
|
-
const { message, severity, line, column, ruleId } = messages[i];
|
|
2378
|
-
output += "\n";
|
|
2379
|
-
if (line && column) {
|
|
2380
|
-
output = `${output + line.toString()}:${column.toString()} `;
|
|
2381
|
-
}
|
|
2382
|
-
if (severity === 1) {
|
|
2383
|
-
output += `Warning: `;
|
|
2384
|
-
} else {
|
|
2385
|
-
output += `Error: `;
|
|
2386
|
-
}
|
|
2387
|
-
output += message;
|
|
2388
|
-
if (ruleId) {
|
|
2389
|
-
output += ` ${ruleId}`;
|
|
2390
|
-
}
|
|
2391
|
-
}
|
|
2392
|
-
return output;
|
|
2393
|
-
}
|
|
2394
|
-
chunkSHUYVCID_js.__name(formatMessage, "formatMessage");
|
|
2395
|
-
async function formatResults(baseDir, results, format3) {
|
|
2396
|
-
let totalPluginErrorCount = 0;
|
|
2397
|
-
let totalPluginWarningCount = 0;
|
|
2398
|
-
const resultsWithMessages = results.filter(({ messages }) => messages?.length);
|
|
2399
|
-
resultsWithMessages.forEach(({ messages }) => {
|
|
2400
|
-
const res = pluginCount(messages);
|
|
2401
|
-
totalPluginErrorCount += res.nextPluginErrorCount;
|
|
2402
|
-
totalPluginWarningCount += res.nextPluginWarningCount;
|
|
2403
|
-
});
|
|
2404
|
-
const output = format3 ? await format3(resultsWithMessages) : resultsWithMessages.map(({ messages, filePath }) => formatMessage(baseDir, messages, filePath)).join("\n");
|
|
2405
|
-
return {
|
|
2406
|
-
output,
|
|
2407
|
-
outputWithMessages: resultsWithMessages.length > 0 ? `${output}
|
|
2408
|
-
|
|
2409
|
-
Info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules` : "",
|
|
2410
|
-
totalPluginErrorCount,
|
|
2411
|
-
totalPluginWarningCount
|
|
2412
|
-
};
|
|
2413
|
-
}
|
|
2414
|
-
chunkSHUYVCID_js.__name(formatResults, "formatResults");
|
|
2415
|
-
async function writeDefaultEslintConfig(log, context, type = "recommended") {
|
|
2416
|
-
const eslintConfigFile = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, "eslint.config.js");
|
|
2417
|
-
const eslintConfig = `
|
|
2418
|
-
import { getConfig } from "eslint-config-powerlines";
|
|
2419
|
-
|
|
2420
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
2421
|
-
|
|
2422
|
-
export default getConfig({
|
|
2423
|
-
repositoryName: "${context.workspaceConfig.name || context.config.name || "powerlines"}",
|
|
2424
|
-
"powerlines": "${type}",
|
|
2425
|
-
});
|
|
2426
|
-
`;
|
|
2427
|
-
log(types.LogLevelLabel.INFO, `Writing a default ESLint config file to ${eslintConfigFile}`);
|
|
2428
|
-
return writeFile(log, eslintConfigFile, eslintConfig);
|
|
2429
|
-
}
|
|
2430
|
-
chunkSHUYVCID_js.__name(writeDefaultEslintConfig, "writeDefaultEslintConfig");
|
|
2431
|
-
var VALID_SEVERITY = [
|
|
2432
|
-
"off",
|
|
2433
|
-
"warn",
|
|
2434
|
-
"error"
|
|
2435
|
-
];
|
|
2436
|
-
function isValidSeverity(severity) {
|
|
2437
|
-
return VALID_SEVERITY.includes(severity);
|
|
2438
|
-
}
|
|
2439
|
-
chunkSHUYVCID_js.__name(isValidSeverity, "isValidSeverity");
|
|
2440
|
-
async function writeOutputFile(log, outputFile, outputData) {
|
|
2441
|
-
const filePath = path__default.default.resolve(process.cwd(), outputFile);
|
|
2442
|
-
if (isFile.isDirectory(filePath)) {
|
|
2443
|
-
log(types.LogLevelLabel.ERROR, `Cannot write to output file path, it is a directory: ${filePath}`);
|
|
2444
|
-
} else {
|
|
2445
|
-
try {
|
|
2446
|
-
await writeFile(log, filePath, outputData);
|
|
2447
|
-
log(types.LogLevelLabel.INFO, `The output file has been created: ${filePath}`);
|
|
2448
|
-
} catch (err) {
|
|
2449
|
-
log(types.LogLevelLabel.ERROR, `There was a problem writing the output file: ${filePath}`);
|
|
2450
|
-
console.error(err);
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
chunkSHUYVCID_js.__name(writeOutputFile, "writeOutputFile");
|
|
2455
|
-
async function hasEslintConfiguration(eslintFile, packageJsonConfig) {
|
|
2456
|
-
const configObject = {
|
|
2457
|
-
exists: false,
|
|
2458
|
-
emptyEslint: false,
|
|
2459
|
-
emptyPkgJsonConfig: false
|
|
2460
|
-
};
|
|
2461
|
-
if (eslintFile) {
|
|
2462
|
-
const content = await readFile.readFile(eslintFile).then((txt) => txt.trim().replace(/\n/g, ""), () => null);
|
|
2463
|
-
if (content === "" || content === "{}" || content === "---" || content === "module.exports = {}") {
|
|
2464
|
-
configObject.emptyEslint = true;
|
|
2465
|
-
} else {
|
|
2466
|
-
configObject.exists = true;
|
|
2467
|
-
}
|
|
2468
|
-
} else if (packageJsonConfig?.eslintConfig) {
|
|
2469
|
-
if (Object.keys(packageJsonConfig.eslintConfig).length) {
|
|
2470
|
-
configObject.exists = true;
|
|
2471
|
-
} else {
|
|
2472
|
-
configObject.emptyPkgJsonConfig = true;
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
return configObject;
|
|
2476
|
-
}
|
|
2477
|
-
chunkSHUYVCID_js.__name(hasEslintConfiguration, "hasEslintConfiguration");
|
|
2478
|
-
var lint = /* @__PURE__ */ chunkSHUYVCID_js.__name(async (log, context, eslintConfigPath, { lintDuringBuild = false, eslintOptions = null, reportErrorsOnly = false, maxWarnings = -1, formatter = null, outputFile = null }) => {
|
|
2479
|
-
try {
|
|
2480
|
-
await installPackages(context, [
|
|
2481
|
-
{
|
|
2482
|
-
name: "eslint",
|
|
2483
|
-
dev: true
|
|
2484
|
-
},
|
|
2485
|
-
{
|
|
2486
|
-
name: "eslint-config-powerlines",
|
|
2487
|
-
dev: true
|
|
2488
|
-
}
|
|
2489
|
-
]);
|
|
2490
|
-
const isInstalled = packageFns.isPackageExists("eslint", {
|
|
2491
|
-
paths: [
|
|
2492
|
-
context.workspaceConfig.workspaceRoot,
|
|
2493
|
-
context.config.projectRoot
|
|
2494
|
-
]
|
|
2495
|
-
});
|
|
2496
|
-
if (!isInstalled) {
|
|
2497
|
-
log(types.LogLevelLabel.ERROR, `ESLint must be installed${lintDuringBuild ? " in order to run during builds:" : ":"} npm install --save-dev eslint`);
|
|
2498
|
-
return null;
|
|
2499
|
-
}
|
|
2500
|
-
const module = await context.resolver.import(context.resolver.esmResolve("eslint"));
|
|
2501
|
-
const useFlatConfig = eslintConfigPath ? filePathFns.findFileName(eslintConfigPath).startsWith("eslint.config.") : false;
|
|
2502
|
-
let ESLint;
|
|
2503
|
-
if ("loadESLint" in module) {
|
|
2504
|
-
ESLint = await module.loadESLint({
|
|
2505
|
-
useFlatConfig
|
|
2506
|
-
});
|
|
2507
|
-
}
|
|
2508
|
-
const eslintVersion = semverFns.parseVersion(ESLint?.version);
|
|
2509
|
-
if (!eslintVersion || eslintVersion.compare("8.57.0") < 0) {
|
|
2510
|
-
return `Error - Your project has an older version of ESLint installed${eslintVersion ? ` (${eslintVersion.major}.${eslintVersion.minor}.${eslintVersion.patch})` : ""}. Please upgrade to ESLint version 8.57.0 or above`;
|
|
2511
|
-
}
|
|
2512
|
-
const options = {
|
|
2513
|
-
useEslintrc: true,
|
|
2514
|
-
baseConfig: {},
|
|
2515
|
-
errorOnUnmatchedPattern: false,
|
|
2516
|
-
extensions: [
|
|
2517
|
-
".js",
|
|
2518
|
-
".jsx",
|
|
2519
|
-
".ts",
|
|
2520
|
-
".tsx"
|
|
2521
|
-
],
|
|
2522
|
-
cache: true,
|
|
2523
|
-
...eslintOptions
|
|
2524
|
-
};
|
|
2525
|
-
if (eslintVersion?.compare("9.0.0") && useFlatConfig) {
|
|
2526
|
-
for (const option of [
|
|
2527
|
-
"useEslintrc",
|
|
2528
|
-
"extensions",
|
|
2529
|
-
"ignorePath",
|
|
2530
|
-
"reportUnusedDisableDirectives",
|
|
2531
|
-
"resolvePluginsRelativeTo",
|
|
2532
|
-
"rulePaths",
|
|
2533
|
-
"inlineConfig",
|
|
2534
|
-
"maxWarnings"
|
|
2535
|
-
]) {
|
|
2536
|
-
if (option in options) {
|
|
2537
|
-
delete options[option];
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
}
|
|
2541
|
-
let eslint2 = new ESLint(options);
|
|
2542
|
-
let stormStackEslintPluginIsEnabled = false;
|
|
2543
|
-
const stormStackRulesEnabled = /* @__PURE__ */ new Map();
|
|
2544
|
-
for (const configFile of [
|
|
2545
|
-
eslintConfigPath,
|
|
2546
|
-
joinPaths.joinPaths(context.config.projectRoot, "package.json")
|
|
2547
|
-
]) {
|
|
2548
|
-
if (!configFile) continue;
|
|
2549
|
-
const completeConfig = await eslint2.calculateConfigForFile(configFile);
|
|
2550
|
-
if (!completeConfig) continue;
|
|
2551
|
-
const plugins2 = completeConfig.plugins;
|
|
2552
|
-
const hasStormStackPlugin = (
|
|
2553
|
-
// in ESLint < 9, `plugins` value is string[]
|
|
2554
|
-
Array.isArray(plugins2) ? plugins2.includes("powerlines") : "powerlines" in plugins2
|
|
2555
|
-
);
|
|
2556
|
-
if (hasStormStackPlugin) {
|
|
2557
|
-
stormStackEslintPluginIsEnabled = true;
|
|
2558
|
-
for (const [name, [severity]] of Object.entries(completeConfig.rules)) {
|
|
2559
|
-
if (!name.startsWith("powerlines/")) {
|
|
2560
|
-
continue;
|
|
2561
|
-
}
|
|
2562
|
-
if (typeof severity === "number" && severity >= 0 && severity < VALID_SEVERITY.length) {
|
|
2563
|
-
stormStackRulesEnabled.set(name, VALID_SEVERITY[severity]);
|
|
2564
|
-
} else if (typeof severity === "string" && isValidSeverity(severity)) {
|
|
2565
|
-
stormStackRulesEnabled.set(name, severity);
|
|
2566
|
-
}
|
|
2567
|
-
}
|
|
2568
|
-
break;
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
if (stormStackEslintPluginIsEnabled) {
|
|
2572
|
-
eslint2 = new ESLint(options);
|
|
2573
|
-
} else {
|
|
2574
|
-
log(types.LogLevelLabel.WARN, "The Powerlines plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config");
|
|
2575
|
-
}
|
|
2576
|
-
const lintStart = process.hrtime();
|
|
2577
|
-
let results = await eslint2.lintFiles(context.tsconfig.fileNames.filter((fileName) => !fileName.includes(context.artifactsPath) && !fileName.includes("node_modules")));
|
|
2578
|
-
let selectedFormatter = null;
|
|
2579
|
-
if (options.fix) {
|
|
2580
|
-
await ESLint.outputFixes(results);
|
|
2581
|
-
}
|
|
2582
|
-
if (reportErrorsOnly) {
|
|
2583
|
-
results = ESLint.getErrorResults(results);
|
|
2584
|
-
}
|
|
2585
|
-
if (formatter) {
|
|
2586
|
-
selectedFormatter = await eslint2.loadFormatter(formatter);
|
|
2587
|
-
}
|
|
2588
|
-
const formattedResult = await formatResults(context.config.projectRoot, results, selectedFormatter?.format?.bind(selectedFormatter));
|
|
2589
|
-
const lintEnd = process.hrtime(lintStart);
|
|
2590
|
-
const totalWarnings = results.reduce((sum, file) => sum + file.warningCount, 0);
|
|
2591
|
-
if (outputFile) {
|
|
2592
|
-
await writeOutputFile(log, outputFile, formattedResult.output);
|
|
2593
|
-
}
|
|
2594
|
-
return {
|
|
2595
|
-
output: formattedResult.outputWithMessages,
|
|
2596
|
-
isError: ESLint.getErrorResults(results)?.length > 0 || maxWarnings >= 0 && totalWarnings > maxWarnings,
|
|
2597
|
-
eventInfo: {
|
|
2598
|
-
durationInSeconds: lintEnd[0],
|
|
2599
|
-
eslintVersion: eslintVersion.version,
|
|
2600
|
-
lintedFilesCount: results.length,
|
|
2601
|
-
lintFix: !!options.fix,
|
|
2602
|
-
eslintPluginErrorsCount: formattedResult.totalPluginErrorCount,
|
|
2603
|
-
eslintPluginWarningsCount: formattedResult.totalPluginWarningCount,
|
|
2604
|
-
stormStackRulesEnabled: Object.fromEntries(stormStackRulesEnabled)
|
|
2605
|
-
}
|
|
2606
|
-
};
|
|
2607
|
-
} catch (err) {
|
|
2608
|
-
if (lintDuringBuild) {
|
|
2609
|
-
log(types.LogLevelLabel.ERROR, `ESLint: ${isError.isError(err) && err.message ? err.message.replace(/\n/g, " ") : String(err)}`);
|
|
2610
|
-
return null;
|
|
2611
|
-
} else {
|
|
2612
|
-
throw err;
|
|
2613
|
-
}
|
|
2614
|
-
}
|
|
2615
|
-
}, "lint");
|
|
2616
|
-
async function eslint(context, lintDuringBuild = false, opts = {}) {
|
|
2617
|
-
const { eslintOptions = null, reportErrorsOnly = false, maxWarnings = -1, formatter = null, outputFile = null, type = "recommended" } = opts;
|
|
2618
|
-
const eslintFile = getParentPath.getParentPath([
|
|
2619
|
-
// eslint v9
|
|
2620
|
-
"eslint.config.js",
|
|
2621
|
-
"eslint.config.mjs",
|
|
2622
|
-
"eslint.config.cjs",
|
|
2623
|
-
// TS extensions require to install a separate package `jiti`.
|
|
2624
|
-
// https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files
|
|
2625
|
-
"eslint.config.ts",
|
|
2626
|
-
"eslint.config.mts",
|
|
2627
|
-
"eslint.config.cts",
|
|
2628
|
-
// eslint <= v8
|
|
2629
|
-
".eslintrc.js",
|
|
2630
|
-
".eslintrc.cjs",
|
|
2631
|
-
".eslintrc.yaml",
|
|
2632
|
-
".eslintrc.yml",
|
|
2633
|
-
".eslintrc.json",
|
|
2634
|
-
".eslintrc"
|
|
2635
|
-
], context.config.projectRoot) ?? null;
|
|
2636
|
-
const config = await hasEslintConfiguration(eslintFile, context.packageJson);
|
|
2637
|
-
if (config.exists) {
|
|
2638
|
-
return lint(context.log, context, eslintFile, {
|
|
2639
|
-
lintDuringBuild,
|
|
2640
|
-
eslintOptions,
|
|
2641
|
-
reportErrorsOnly,
|
|
2642
|
-
maxWarnings,
|
|
2643
|
-
formatter,
|
|
2644
|
-
outputFile
|
|
2645
|
-
});
|
|
2646
|
-
}
|
|
2647
|
-
if (lintDuringBuild) {
|
|
2648
|
-
if (config.emptyPkgJsonConfig || config.emptyEslint) {
|
|
2649
|
-
context.log(types.LogLevelLabel.WARN, `No ESLint configuration detected. Run "storm lint" to begin setup`);
|
|
2650
|
-
}
|
|
2651
|
-
return null;
|
|
2652
|
-
} else {
|
|
2653
|
-
const isEslintInstalled = packageFns.isPackageExists("eslint", {
|
|
2654
|
-
paths: [
|
|
2655
|
-
context.workspaceConfig.workspaceRoot,
|
|
2656
|
-
context.config.projectRoot
|
|
2657
|
-
]
|
|
2658
|
-
});
|
|
2659
|
-
const isEslintPluginInstalled = packageFns.isPackageExists("eslint-config-powerlines", {
|
|
2660
|
-
paths: [
|
|
2661
|
-
context.workspaceConfig.workspaceRoot,
|
|
2662
|
-
context.config.projectRoot
|
|
2663
|
-
]
|
|
2664
|
-
});
|
|
2665
|
-
if (!isEslintInstalled || !isEslintPluginInstalled) {
|
|
2666
|
-
await installPackages(context, [
|
|
2667
|
-
{
|
|
2668
|
-
name: "eslint",
|
|
2669
|
-
dev: true
|
|
2670
|
-
},
|
|
2671
|
-
{
|
|
2672
|
-
name: "eslint-config-powerlines",
|
|
2673
|
-
dev: true
|
|
2674
|
-
}
|
|
2675
|
-
]);
|
|
2676
|
-
}
|
|
2677
|
-
await writeDefaultEslintConfig(context.log, context, type);
|
|
2678
|
-
}
|
|
2679
|
-
context.log(types.LogLevelLabel.SUCCESS, `ESLint has successfully been configured. Run "storm lint" again to view warnings and errors.`);
|
|
2680
|
-
return null;
|
|
2681
|
-
}
|
|
2682
|
-
chunkSHUYVCID_js.__name(eslint, "eslint");
|
|
2683
2302
|
function getString(code) {
|
|
2684
2303
|
if (!code) {
|
|
2685
2304
|
return "";
|
|
@@ -2880,7 +2499,7 @@ async function generateTypes(context) {
|
|
|
2880
2499
|
resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
|
|
2881
2500
|
resolvedTsconfig.options.suppressOutputPathCheck = true;
|
|
2882
2501
|
context.log(types.LogLevelLabel.TRACE, "Creating the TypeScript compiler host");
|
|
2883
|
-
const program =
|
|
2502
|
+
const program = ts2.createProgram(files, resolvedTsconfig.options, ts2.createCompilerHost(resolvedTsconfig.options));
|
|
2884
2503
|
context.log(types.LogLevelLabel.TRACE, `Running TypeScript compiler on ${builtinFiles.length} built-in runtime files.`);
|
|
2885
2504
|
let builtinModules = "";
|
|
2886
2505
|
const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
|
|
@@ -2895,15 +2514,15 @@ declare module "${context.fs.resolveId(sourceFile2.fileName)}" {
|
|
|
2895
2514
|
}
|
|
2896
2515
|
}
|
|
2897
2516
|
}, void 0, true);
|
|
2898
|
-
const diagnostics =
|
|
2517
|
+
const diagnostics = ts2.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
2899
2518
|
const diagnosticMessages = [];
|
|
2900
2519
|
diagnostics.forEach((diagnostic) => {
|
|
2901
2520
|
if (diagnostic.file) {
|
|
2902
|
-
const { line, character } =
|
|
2903
|
-
const message =
|
|
2521
|
+
const { line, character } = ts2.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
2522
|
+
const message = ts2.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
2904
2523
|
diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
2905
2524
|
} else {
|
|
2906
|
-
const message =
|
|
2525
|
+
const message = ts2.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
2907
2526
|
diagnosticMessages.push(message);
|
|
2908
2527
|
}
|
|
2909
2528
|
});
|
|
@@ -2930,13 +2549,47 @@ ${builtinModules}`.replace(
|
|
|
2930
2549
|
await context.fs.writeFileToDisk(sourceFile.id, getString(sourceFile.code));
|
|
2931
2550
|
}
|
|
2932
2551
|
chunkSHUYVCID_js.__name(generateTypes, "generateTypes");
|
|
2552
|
+
async function installPackage(context, packageName, dev = false) {
|
|
2553
|
+
if (!await packageFns.isPackageListed(_package.getPackageName(packageName), {
|
|
2554
|
+
cwd: context.config.projectRoot
|
|
2555
|
+
})) {
|
|
2556
|
+
if (context.config.skipInstalls !== true && !process.env.POWERLINES_LOCAL) {
|
|
2557
|
+
context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`);
|
|
2558
|
+
const result = await install.install(packageName, {
|
|
2559
|
+
cwd: context.config.projectRoot,
|
|
2560
|
+
dev
|
|
2561
|
+
});
|
|
2562
|
+
if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
|
|
2563
|
+
context.log(types.LogLevelLabel.ERROR, result.stderr);
|
|
2564
|
+
throw new Error(`An error occurred while installing the package "${packageName}"`);
|
|
2565
|
+
}
|
|
2566
|
+
} else {
|
|
2567
|
+
context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`);
|
|
2568
|
+
}
|
|
2569
|
+
} else if (_package.hasPackageVersion(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
|
|
2570
|
+
const isMatching = await packageFns.doesPackageMatch(_package.getPackageName(packageName), _package.getPackageVersion(packageName), context.config.projectRoot);
|
|
2571
|
+
if (!isMatching) {
|
|
2572
|
+
const packageListing = await packageFns.getPackageListing(_package.getPackageName(packageName), {
|
|
2573
|
+
cwd: context.config.projectRoot
|
|
2574
|
+
});
|
|
2575
|
+
if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) {
|
|
2576
|
+
context.log(types.LogLevelLabel.WARN, `The package "${_package.getPackageName(packageName)}" is installed but does not match the expected version ${_package.getPackageVersion(packageName)} (installed version: ${packageListing?.version || "<Unknown>"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`);
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
chunkSHUYVCID_js.__name(installPackage, "installPackage");
|
|
2582
|
+
|
|
2583
|
+
// ../powerlines/src/internal/helpers/install-dependencies.ts
|
|
2933
2584
|
async function installDependencies(context) {
|
|
2934
2585
|
context.log(types.LogLevelLabel.TRACE, `Checking and installing missing project dependencies.`);
|
|
2935
2586
|
context.dependencies ??= {};
|
|
2936
|
-
context.
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2587
|
+
context.log(types.LogLevelLabel.TRACE, `The following packages are required:
|
|
2588
|
+
Dependencies:
|
|
2589
|
+
${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}
|
|
2590
|
+
|
|
2591
|
+
DevDependencies:
|
|
2592
|
+
${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}`);
|
|
2940
2593
|
await Promise.all([
|
|
2941
2594
|
Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, false))),
|
|
2942
2595
|
Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, true)))
|
|
@@ -2980,22 +2633,22 @@ async function resolveTsconfigChanges(context) {
|
|
|
2980
2633
|
tsconfigJson.compilerOptions.lib ??= [];
|
|
2981
2634
|
tsconfigJson.compilerOptions.lib.push("esnext");
|
|
2982
2635
|
}
|
|
2983
|
-
if (tsconfig$1.options.module !==
|
|
2636
|
+
if (tsconfig$1.options.module !== ts2__default.default.ModuleKind.ESNext) {
|
|
2984
2637
|
tsconfigJson.compilerOptions.module = "ESNext";
|
|
2985
2638
|
}
|
|
2986
2639
|
if (!tsconfig$1.options.target || ![
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2640
|
+
ts2__default.default.ScriptTarget.ESNext,
|
|
2641
|
+
ts2__default.default.ScriptTarget.ES2024,
|
|
2642
|
+
ts2__default.default.ScriptTarget.ES2023,
|
|
2643
|
+
ts2__default.default.ScriptTarget.ES2022,
|
|
2644
|
+
ts2__default.default.ScriptTarget.ES2021
|
|
2992
2645
|
].includes(tsconfig$1.options.target)) {
|
|
2993
2646
|
tsconfigJson.compilerOptions.target = "ESNext";
|
|
2994
2647
|
}
|
|
2995
|
-
if (tsconfig$1.options.moduleResolution !==
|
|
2648
|
+
if (tsconfig$1.options.moduleResolution !== ts2__default.default.ModuleResolutionKind.Bundler) {
|
|
2996
2649
|
tsconfigJson.compilerOptions.moduleResolution = "Bundler";
|
|
2997
2650
|
}
|
|
2998
|
-
if (tsconfig$1.options.moduleDetection !==
|
|
2651
|
+
if (tsconfig$1.options.moduleDetection !== ts2__default.default.ModuleDetectionKind.Force) {
|
|
2999
2652
|
tsconfigJson.compilerOptions.moduleDetection = "force";
|
|
3000
2653
|
}
|
|
3001
2654
|
if (tsconfig$1.options.allowSyntheticDefaultImports !== true) {
|
|
@@ -3029,7 +2682,7 @@ async function resolveTsconfigChanges(context) {
|
|
|
3029
2682
|
tsconfigJson.compilerOptions.declaration = true;
|
|
3030
2683
|
}
|
|
3031
2684
|
if (context.environment.consumer === "client") {
|
|
3032
|
-
if (tsconfig$1.options.jsx !==
|
|
2685
|
+
if (tsconfig$1.options.jsx !== ts2__default.default.JsxEmit.ReactJSX) {
|
|
3033
2686
|
tsconfigJson.compilerOptions.jsx = "react-jsx";
|
|
3034
2687
|
}
|
|
3035
2688
|
if (!tsconfig$1.options.lib?.some((lib) => lib.toLowerCase() !== "dom")) {
|
|
@@ -3115,127 +2768,6 @@ async function resolveTsconfig(context) {
|
|
|
3115
2768
|
context.tsconfig.tsconfigJson.compilerOptions.strict = false;
|
|
3116
2769
|
}
|
|
3117
2770
|
chunkSHUYVCID_js.__name(resolveTsconfig, "resolveTsconfig");
|
|
3118
|
-
function getDefaultCompilerOptions() {
|
|
3119
|
-
return {
|
|
3120
|
-
...ts3__default.default.getDefaultCompilerOptions(),
|
|
3121
|
-
jsx: ts3__default.default.JsxEmit.React,
|
|
3122
|
-
strict: true,
|
|
3123
|
-
esModuleInterop: true,
|
|
3124
|
-
module: ts3__default.default.ModuleKind.ESNext,
|
|
3125
|
-
suppressOutputPathCheck: true,
|
|
3126
|
-
skipLibCheck: true,
|
|
3127
|
-
skipDefaultLibCheck: true,
|
|
3128
|
-
moduleResolution: ts3__default.default.ModuleResolutionKind.Node10
|
|
3129
|
-
};
|
|
3130
|
-
}
|
|
3131
|
-
chunkSHUYVCID_js.__name(getDefaultCompilerOptions, "getDefaultCompilerOptions");
|
|
3132
|
-
async function createVirtualProgram(rootNames, context, compilerOptions = {}) {
|
|
3133
|
-
const options = defu4__default.default(compilerOptions, getDefaultCompilerOptions());
|
|
3134
|
-
const host = {
|
|
3135
|
-
name: "storm-vfs",
|
|
3136
|
-
root: context.workspaceConfig.workspaceRoot,
|
|
3137
|
-
...ts3__default.default.sys,
|
|
3138
|
-
realpath: /* @__PURE__ */ chunkSHUYVCID_js.__name((path2) => {
|
|
3139
|
-
if (context.fs.existsSync(path2)) {
|
|
3140
|
-
return context.fs.resolvePath(path2);
|
|
3141
|
-
}
|
|
3142
|
-
return ts3__default.default.sys.realpath?.(path2) ?? path2;
|
|
3143
|
-
}, "realpath"),
|
|
3144
|
-
getCurrentDirectory() {
|
|
3145
|
-
return context.workspaceConfig.workspaceRoot;
|
|
3146
|
-
},
|
|
3147
|
-
getCanonicalFileName(fileName) {
|
|
3148
|
-
return fileName;
|
|
3149
|
-
},
|
|
3150
|
-
getDefaultLibFileName(_options) {
|
|
3151
|
-
return ts3__default.default.getDefaultLibFileName(options);
|
|
3152
|
-
},
|
|
3153
|
-
getDefaultLibLocation() {
|
|
3154
|
-
return "/";
|
|
3155
|
-
},
|
|
3156
|
-
getNewLine() {
|
|
3157
|
-
return "\n";
|
|
3158
|
-
},
|
|
3159
|
-
useCaseSensitiveFileNames() {
|
|
3160
|
-
return true;
|
|
3161
|
-
},
|
|
3162
|
-
fileExists(fileName) {
|
|
3163
|
-
return context.fs.existsSync(fileName);
|
|
3164
|
-
},
|
|
3165
|
-
readFile(fileName) {
|
|
3166
|
-
if (context.fs.existsSync(fileName)) {
|
|
3167
|
-
return context.fs.readFileSync(fileName);
|
|
3168
|
-
}
|
|
3169
|
-
return void 0;
|
|
3170
|
-
},
|
|
3171
|
-
readDirectory: /* @__PURE__ */ chunkSHUYVCID_js.__name((path2, extensions = [], exclude = [], include = []) => {
|
|
3172
|
-
let results = [];
|
|
3173
|
-
if (context.fs.existsSync(path2)) {
|
|
3174
|
-
results = context.fs.readdirSync(path2, {
|
|
3175
|
-
encoding: "utf8",
|
|
3176
|
-
recursive: true
|
|
3177
|
-
});
|
|
3178
|
-
if (extensions.length > 0) {
|
|
3179
|
-
results = results.filter((file) => extensions.some((ext) => file.endsWith(ext.startsWith(".") ? ext : `.${ext}`)));
|
|
3180
|
-
}
|
|
3181
|
-
if (exclude.length > 0) {
|
|
3182
|
-
results = results.filter((file) => !exclude.some((pattern) => minimatch.minimatch(file, pattern)));
|
|
3183
|
-
}
|
|
3184
|
-
if (include.length > 0) {
|
|
3185
|
-
results = results.filter((file) => include.some((pattern) => minimatch.minimatch(file, pattern)));
|
|
3186
|
-
}
|
|
3187
|
-
}
|
|
3188
|
-
return results;
|
|
3189
|
-
}, "readDirectory"),
|
|
3190
|
-
writeFile(fileName, data) {
|
|
3191
|
-
context.fs.writeFileSync(fileName, data);
|
|
3192
|
-
},
|
|
3193
|
-
resolvePath: /* @__PURE__ */ chunkSHUYVCID_js.__name((fileName) => {
|
|
3194
|
-
if (context.fs.existsSync(fileName)) {
|
|
3195
|
-
return context.fs.resolvePath(fileName);
|
|
3196
|
-
}
|
|
3197
|
-
return ts3__default.default.sys.resolvePath(fileName);
|
|
3198
|
-
}, "resolvePath"),
|
|
3199
|
-
getSourceFile(fileName, languageVersionOrOptions, _, shouldCreateNewSourceFile) {
|
|
3200
|
-
if (context.fs.existsSync(fileName)) {
|
|
3201
|
-
return ts3__default.default.createSourceFile(fileName, context.fs.readFileSync(fileName), languageVersionOrOptions ?? compilerOptions.target ?? getDefaultCompilerOptions().target, false);
|
|
3202
|
-
} else if (shouldCreateNewSourceFile) {
|
|
3203
|
-
const sourceFile = ts3__default.default.createSourceFile(fileName, "", languageVersionOrOptions ?? compilerOptions.target ?? getDefaultCompilerOptions().target, false);
|
|
3204
|
-
context.fs.writeFileSync(fileName, sourceFile.text);
|
|
3205
|
-
return sourceFile;
|
|
3206
|
-
}
|
|
3207
|
-
return void 0;
|
|
3208
|
-
}
|
|
3209
|
-
};
|
|
3210
|
-
return ts3__default.default.createProgram(rootNames, options, host);
|
|
3211
|
-
}
|
|
3212
|
-
chunkSHUYVCID_js.__name(createVirtualProgram, "createVirtualProgram");
|
|
3213
|
-
|
|
3214
|
-
// ../powerlines/src/internal/helpers/tsc.ts
|
|
3215
|
-
async function typeCheck(context, sources) {
|
|
3216
|
-
if (sources) {
|
|
3217
|
-
await Promise.all(sources.entries().map(async ([path2, content]) => context.fs.writeFile(path2, content)));
|
|
3218
|
-
}
|
|
3219
|
-
const program = await createVirtualProgram(sources ? Array.from(sources.keys()) : [], context, {
|
|
3220
|
-
noEmit: true,
|
|
3221
|
-
lib: [
|
|
3222
|
-
"lib.esnext.d.ts"
|
|
3223
|
-
],
|
|
3224
|
-
types: []
|
|
3225
|
-
});
|
|
3226
|
-
const emitResult = program.emit();
|
|
3227
|
-
const allDiagnostics = ts3__default.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
3228
|
-
allDiagnostics.forEach((diagnostic) => {
|
|
3229
|
-
if (diagnostic.file) {
|
|
3230
|
-
const { line, character } = ts3__default.default.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
3231
|
-
const message = ts3__default.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
3232
|
-
context.log(types.LogLevelLabel.ERROR, `${diagnostic.file.fileName}:${line + 1}:${character + 1} : ${message}`);
|
|
3233
|
-
} else {
|
|
3234
|
-
context.log(types.LogLevelLabel.ERROR, ts3__default.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
3235
|
-
}
|
|
3236
|
-
});
|
|
3237
|
-
}
|
|
3238
|
-
chunkSHUYVCID_js.__name(typeCheck, "typeCheck");
|
|
3239
2771
|
|
|
3240
2772
|
// ../powerlines/src/internal/api.ts
|
|
3241
2773
|
var PowerlinesAPI = class _PowerlinesAPI {
|
|
@@ -3301,7 +2833,7 @@ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.outpu
|
|
|
3301
2833
|
await this.callPostHook(context, "configResolved");
|
|
3302
2834
|
context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
|
|
3303
2835
|
|
|
3304
|
-
${console
|
|
2836
|
+
${console.formatLogMessage(context.config)}`);
|
|
3305
2837
|
context.fs[chunkHHPODCTP_js.__VFS_INIT__]();
|
|
3306
2838
|
await chunkHHPODCTP_js.writeMetaFile(context);
|
|
3307
2839
|
context.persistedMeta = context.meta;
|
|
@@ -3409,11 +2941,7 @@ ${console$1.formatLogMessage(context.config)}`);
|
|
|
3409
2941
|
await this.prepare(inlineConfig);
|
|
3410
2942
|
await this.#executeEnvironments(async (context) => {
|
|
3411
2943
|
if (context.config.lint !== false) {
|
|
3412
|
-
await this.
|
|
3413
|
-
await typeCheck(context);
|
|
3414
|
-
await eslint(context, true, context.config.lint.eslint);
|
|
3415
|
-
await this.callNormalHook(context, "lint");
|
|
3416
|
-
await this.callPostHook(context, "lint");
|
|
2944
|
+
await this.callHook(context, "lint");
|
|
3417
2945
|
}
|
|
3418
2946
|
});
|
|
3419
2947
|
this.context.log(types.LogLevelLabel.TRACE, "Powerlines linting completed");
|
|
@@ -3763,9 +3291,9 @@ var DEFAULT_ESBUILD_CONFIG = {
|
|
|
3763
3291
|
function extractESBuildConfig(context) {
|
|
3764
3292
|
return defu4__default.default({
|
|
3765
3293
|
alias: context.fs.builtinIdMap.keys().reduce((ret, id) => {
|
|
3766
|
-
const
|
|
3767
|
-
if (
|
|
3768
|
-
ret[id] =
|
|
3294
|
+
const path = context.fs.builtinIdMap.get(id);
|
|
3295
|
+
if (path) {
|
|
3296
|
+
ret[id] = path;
|
|
3769
3297
|
}
|
|
3770
3298
|
return ret;
|
|
3771
3299
|
}, {})
|
|
@@ -3807,9 +3335,9 @@ function extractViteConfig(context) {
|
|
|
3807
3335
|
return defu4__default.default({
|
|
3808
3336
|
resolve: {
|
|
3809
3337
|
alias: context.fs.builtinIdMap.keys().reduce((ret, id) => {
|
|
3810
|
-
const
|
|
3811
|
-
if (
|
|
3812
|
-
ret[id] =
|
|
3338
|
+
const path = context.fs.builtinIdMap.get(id);
|
|
3339
|
+
if (path) {
|
|
3340
|
+
ret[id] = path;
|
|
3813
3341
|
}
|
|
3814
3342
|
return ret;
|
|
3815
3343
|
}, {})
|