@valbuild/cli 0.62.6 → 0.63.0

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.
@@ -65,9 +65,9 @@ async function validate({
65
65
  console.log("Validating...", valFiles.length, "files");
66
66
  async function validateFile(file) {
67
67
  var _eslintResultsByFile;
68
- const moduleId = `/${file}`.replace(/(\.val\.(ts|js))$/, ""); // TODO: check if this always works? (Windows?)
68
+ const moduleFilePath = `/${file}`; // TODO: check if this always works? (Windows?)
69
69
  const start = Date.now();
70
- const valModule = await service.get(moduleId, "", {
70
+ const valModule = await service.get(moduleFilePath, "", {
71
71
  source: true,
72
72
  schema: true,
73
73
  validate: true
@@ -76,10 +76,10 @@ async function validate({
76
76
  const eslintResult = (_eslintResultsByFile = eslintResultsByFile) === null || _eslintResultsByFile === void 0 ? void 0 : _eslintResultsByFile[file];
77
77
  eslintResult === null || eslintResult === void 0 || eslintResult.messages.forEach(m => {
78
78
  // display surrounding code
79
- logEslintMessage(fileContent, moduleId, m);
79
+ logEslintMessage(fileContent, moduleFilePath, m);
80
80
  });
81
81
  if (!valModule.errors && (eslintResult === null || eslintResult === void 0 ? void 0 : eslintResult.errorCount) === 0) {
82
- console.log(picocolors__default["default"].green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
82
+ console.log(picocolors__default["default"].green("✔"), moduleFilePath, "is valid (" + (Date.now() - start) + "ms)");
83
83
  return 0;
84
84
  } else {
85
85
  var _eslintResultsByFile2;
@@ -94,7 +94,7 @@ async function validate({
94
94
  projectRoot
95
95
  }, !!fix, sourcePath, v);
96
96
  if (fix && fixPatch !== null && fixPatch !== void 0 && fixPatch.patch && (fixPatch === null || fixPatch === void 0 ? void 0 : fixPatch.patch.length) > 0) {
97
- await service.patch(moduleId, fixPatch.patch);
97
+ await service.patch(moduleFilePath, fixPatch.patch);
98
98
  console.log(picocolors__default["default"].yellow("⚠"), "Applied fix for", sourcePath);
99
99
  }
100
100
  fixPatch === null || fixPatch === void 0 || (_fixPatch$remainingEr = fixPatch.remainingErrors) === null || _fixPatch$remainingEr === void 0 || _fixPatch$remainingEr.forEach(e => {
@@ -110,10 +110,10 @@ async function validate({
110
110
  }
111
111
  for (const fatalError of valModule.errors.fatal || []) {
112
112
  errors += 1;
113
- console.log(picocolors__default["default"].red("✘"), moduleId, "is invalid:", fatalError.message);
113
+ console.log(picocolors__default["default"].red("✘"), moduleFilePath, "is invalid:", fatalError.message);
114
114
  }
115
115
  } else {
116
- console.log(picocolors__default["default"].green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
116
+ console.log(picocolors__default["default"].green("✔"), moduleFilePath, "is valid (" + (Date.now() - start) + "ms)");
117
117
  }
118
118
  return errors;
119
119
  }
@@ -65,9 +65,9 @@ async function validate({
65
65
  console.log("Validating...", valFiles.length, "files");
66
66
  async function validateFile(file) {
67
67
  var _eslintResultsByFile;
68
- const moduleId = `/${file}`.replace(/(\.val\.(ts|js))$/, ""); // TODO: check if this always works? (Windows?)
68
+ const moduleFilePath = `/${file}`; // TODO: check if this always works? (Windows?)
69
69
  const start = Date.now();
70
- const valModule = await service.get(moduleId, "", {
70
+ const valModule = await service.get(moduleFilePath, "", {
71
71
  source: true,
72
72
  schema: true,
73
73
  validate: true
@@ -76,10 +76,10 @@ async function validate({
76
76
  const eslintResult = (_eslintResultsByFile = eslintResultsByFile) === null || _eslintResultsByFile === void 0 ? void 0 : _eslintResultsByFile[file];
77
77
  eslintResult === null || eslintResult === void 0 || eslintResult.messages.forEach(m => {
78
78
  // display surrounding code
79
- logEslintMessage(fileContent, moduleId, m);
79
+ logEslintMessage(fileContent, moduleFilePath, m);
80
80
  });
81
81
  if (!valModule.errors && (eslintResult === null || eslintResult === void 0 ? void 0 : eslintResult.errorCount) === 0) {
82
- console.log(picocolors__default["default"].green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
82
+ console.log(picocolors__default["default"].green("✔"), moduleFilePath, "is valid (" + (Date.now() - start) + "ms)");
83
83
  return 0;
84
84
  } else {
85
85
  var _eslintResultsByFile2;
@@ -94,7 +94,7 @@ async function validate({
94
94
  projectRoot
95
95
  }, !!fix, sourcePath, v);
96
96
  if (fix && fixPatch !== null && fixPatch !== void 0 && fixPatch.patch && (fixPatch === null || fixPatch === void 0 ? void 0 : fixPatch.patch.length) > 0) {
97
- await service.patch(moduleId, fixPatch.patch);
97
+ await service.patch(moduleFilePath, fixPatch.patch);
98
98
  console.log(picocolors__default["default"].yellow("⚠"), "Applied fix for", sourcePath);
99
99
  }
100
100
  fixPatch === null || fixPatch === void 0 || (_fixPatch$remainingEr = fixPatch.remainingErrors) === null || _fixPatch$remainingEr === void 0 || _fixPatch$remainingEr.forEach(e => {
@@ -110,10 +110,10 @@ async function validate({
110
110
  }
111
111
  for (const fatalError of valModule.errors.fatal || []) {
112
112
  errors += 1;
113
- console.log(picocolors__default["default"].red("✘"), moduleId, "is invalid:", fatalError.message);
113
+ console.log(picocolors__default["default"].red("✘"), moduleFilePath, "is invalid:", fatalError.message);
114
114
  }
115
115
  } else {
116
- console.log(picocolors__default["default"].green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
116
+ console.log(picocolors__default["default"].green("✔"), moduleFilePath, "is valid (" + (Date.now() - start) + "ms)");
117
117
  }
118
118
  return errors;
119
119
  }
@@ -55,9 +55,9 @@ async function validate({
55
55
  console.log("Validating...", valFiles.length, "files");
56
56
  async function validateFile(file) {
57
57
  var _eslintResultsByFile;
58
- const moduleId = `/${file}`.replace(/(\.val\.(ts|js))$/, ""); // TODO: check if this always works? (Windows?)
58
+ const moduleFilePath = `/${file}`; // TODO: check if this always works? (Windows?)
59
59
  const start = Date.now();
60
- const valModule = await service.get(moduleId, "", {
60
+ const valModule = await service.get(moduleFilePath, "", {
61
61
  source: true,
62
62
  schema: true,
63
63
  validate: true
@@ -66,10 +66,10 @@ async function validate({
66
66
  const eslintResult = (_eslintResultsByFile = eslintResultsByFile) === null || _eslintResultsByFile === void 0 ? void 0 : _eslintResultsByFile[file];
67
67
  eslintResult === null || eslintResult === void 0 || eslintResult.messages.forEach(m => {
68
68
  // display surrounding code
69
- logEslintMessage(fileContent, moduleId, m);
69
+ logEslintMessage(fileContent, moduleFilePath, m);
70
70
  });
71
71
  if (!valModule.errors && (eslintResult === null || eslintResult === void 0 ? void 0 : eslintResult.errorCount) === 0) {
72
- console.log(picocolors.green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
72
+ console.log(picocolors.green("✔"), moduleFilePath, "is valid (" + (Date.now() - start) + "ms)");
73
73
  return 0;
74
74
  } else {
75
75
  var _eslintResultsByFile2;
@@ -84,7 +84,7 @@ async function validate({
84
84
  projectRoot
85
85
  }, !!fix, sourcePath, v);
86
86
  if (fix && fixPatch !== null && fixPatch !== void 0 && fixPatch.patch && (fixPatch === null || fixPatch === void 0 ? void 0 : fixPatch.patch.length) > 0) {
87
- await service.patch(moduleId, fixPatch.patch);
87
+ await service.patch(moduleFilePath, fixPatch.patch);
88
88
  console.log(picocolors.yellow("⚠"), "Applied fix for", sourcePath);
89
89
  }
90
90
  fixPatch === null || fixPatch === void 0 || (_fixPatch$remainingEr = fixPatch.remainingErrors) === null || _fixPatch$remainingEr === void 0 || _fixPatch$remainingEr.forEach(e => {
@@ -100,10 +100,10 @@ async function validate({
100
100
  }
101
101
  for (const fatalError of valModule.errors.fatal || []) {
102
102
  errors += 1;
103
- console.log(picocolors.red("✘"), moduleId, "is invalid:", fatalError.message);
103
+ console.log(picocolors.red("✘"), moduleFilePath, "is invalid:", fatalError.message);
104
104
  }
105
105
  } else {
106
- console.log(picocolors.green("✔"), moduleId, "is valid (" + (Date.now() - start) + "ms)");
106
+ console.log(picocolors.green("✔"), moduleFilePath, "is valid (" + (Date.now() - start) + "ms)");
107
107
  }
108
108
  return errors;
109
109
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@valbuild/cli",
3
3
  "private": false,
4
- "version": "0.62.6",
4
+ "version": "0.63.0",
5
5
  "description": "Val CLI tools",
6
6
  "bin": {
7
7
  "val": "./bin.js"
@@ -18,9 +18,9 @@
18
18
  "typecheck": "tsc --noEmit"
19
19
  },
20
20
  "dependencies": {
21
- "@valbuild/core": "~0.62.6",
22
- "@valbuild/server": "~0.62.6",
23
- "@valbuild/eslint-plugin": "~0.62.6",
21
+ "@valbuild/core": "~0.63.0",
22
+ "@valbuild/server": "~0.63.0",
23
+ "@valbuild/eslint-plugin": "~0.63.0",
24
24
  "eslint": "^8.31.0",
25
25
  "@inquirer/confirm": "^2.0.15",
26
26
  "@inquirer/prompts": "^3.0.2",
package/src/validate.ts CHANGED
@@ -68,12 +68,9 @@ export async function validate({
68
68
  console.log("Validating...", valFiles.length, "files");
69
69
 
70
70
  async function validateFile(file: string): Promise<number> {
71
- const moduleId = `/${file}`.replace(
72
- /(\.val\.(ts|js))$/,
73
- ""
74
- ) as ModuleFilePath; // TODO: check if this always works? (Windows?)
71
+ const moduleFilePath = `/${file}` as ModuleFilePath; // TODO: check if this always works? (Windows?)
75
72
  const start = Date.now();
76
- const valModule = await service.get(moduleId, "" as ModulePath, {
73
+ const valModule = await service.get(moduleFilePath, "" as ModulePath, {
77
74
  source: true,
78
75
  schema: true,
79
76
  validate: true,
@@ -85,12 +82,12 @@ export async function validate({
85
82
  const eslintResult = eslintResultsByFile?.[file];
86
83
  eslintResult?.messages.forEach((m) => {
87
84
  // display surrounding code
88
- logEslintMessage(fileContent, moduleId, m);
85
+ logEslintMessage(fileContent, moduleFilePath, m);
89
86
  });
90
87
  if (!valModule.errors && eslintResult?.errorCount === 0) {
91
88
  console.log(
92
89
  picocolors.green("✔"),
93
- moduleId,
90
+ moduleFilePath,
94
91
  "is valid (" + (Date.now() - start) + "ms)"
95
92
  );
96
93
  return 0;
@@ -114,7 +111,7 @@ export async function validate({
114
111
  v
115
112
  );
116
113
  if (fix && fixPatch?.patch && fixPatch?.patch.length > 0) {
117
- await service.patch(moduleId, fixPatch.patch);
114
+ await service.patch(moduleFilePath, fixPatch.patch);
118
115
  console.log(
119
116
  picocolors.yellow("⚠"),
120
117
  "Applied fix for",
@@ -146,7 +143,7 @@ export async function validate({
146
143
  errors += 1;
147
144
  console.log(
148
145
  picocolors.red("✘"),
149
- moduleId,
146
+ moduleFilePath,
150
147
  "is invalid:",
151
148
  fatalError.message
152
149
  );
@@ -154,7 +151,7 @@ export async function validate({
154
151
  } else {
155
152
  console.log(
156
153
  picocolors.green("✔"),
157
- moduleId,
154
+ moduleFilePath,
158
155
  "is valid (" + (Date.now() - start) + "ms)"
159
156
  );
160
157
  }