@eslint-config-snapshot/cli 0.8.0 → 0.9.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.
- package/CHANGELOG.md +11 -0
- package/dist/index.cjs +53 -4
- package/dist/index.js +53 -4
- package/package.json +2 -2
- package/src/index.ts +65 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @eslint-config-snapshot/cli
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Release minor version with robust CLI version resolution and improved runtime log UX.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @eslint-config-snapshot/api@0.9.0
|
|
13
|
+
|
|
3
14
|
## 0.8.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ var import_commander = require("commander");
|
|
|
41
41
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
42
42
|
var import_node_fs = require("fs");
|
|
43
43
|
var import_promises = require("fs/promises");
|
|
44
|
+
var import_node_module = require("module");
|
|
44
45
|
var import_node_path = __toESM(require("path"), 1);
|
|
45
46
|
var import_node_readline = require("readline");
|
|
46
47
|
var SNAPSHOT_DIR = ".eslint-config-snapshot";
|
|
@@ -924,22 +925,45 @@ function readCliVersion() {
|
|
|
924
925
|
if (cachedCliVersion !== void 0) {
|
|
925
926
|
return cachedCliVersion;
|
|
926
927
|
}
|
|
928
|
+
const envPackageName = process.env.npm_package_name;
|
|
929
|
+
const envPackageVersion = process.env.npm_package_version;
|
|
930
|
+
if (isCliPackageName(envPackageName) && typeof envPackageVersion === "string" && envPackageVersion.length > 0) {
|
|
931
|
+
cachedCliVersion = envPackageVersion;
|
|
932
|
+
return cachedCliVersion;
|
|
933
|
+
}
|
|
927
934
|
const scriptPath = process.argv[1];
|
|
928
935
|
if (!scriptPath) {
|
|
929
936
|
cachedCliVersion = "unknown";
|
|
930
937
|
return cachedCliVersion;
|
|
931
938
|
}
|
|
939
|
+
try {
|
|
940
|
+
const req = (0, import_node_module.createRequire)(import_node_path.default.resolve(scriptPath));
|
|
941
|
+
const resolvedCliEntry = req.resolve("@eslint-config-snapshot/cli");
|
|
942
|
+
const resolvedVersion = readVersionFromResolvedEntry(resolvedCliEntry);
|
|
943
|
+
if (resolvedVersion !== void 0) {
|
|
944
|
+
cachedCliVersion = resolvedVersion;
|
|
945
|
+
return cachedCliVersion;
|
|
946
|
+
}
|
|
947
|
+
} catch {
|
|
948
|
+
}
|
|
932
949
|
let current = import_node_path.default.resolve(import_node_path.default.dirname(scriptPath));
|
|
950
|
+
let fallbackVersion;
|
|
933
951
|
while (true) {
|
|
934
952
|
const packageJsonPath = import_node_path.default.join(current, "package.json");
|
|
935
953
|
if ((0, import_node_fs.existsSync)(packageJsonPath)) {
|
|
936
954
|
try {
|
|
937
955
|
const raw = (0, import_node_fs.readFileSync)(packageJsonPath, "utf8");
|
|
938
956
|
const parsed = JSON.parse(raw);
|
|
939
|
-
|
|
940
|
-
|
|
957
|
+
if (typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
958
|
+
if (isCliPackageName(parsed.name)) {
|
|
959
|
+
cachedCliVersion = parsed.version;
|
|
960
|
+
return cachedCliVersion;
|
|
961
|
+
}
|
|
962
|
+
if (fallbackVersion === void 0) {
|
|
963
|
+
fallbackVersion = parsed.version;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
941
966
|
} catch {
|
|
942
|
-
break;
|
|
943
967
|
}
|
|
944
968
|
}
|
|
945
969
|
const parent = import_node_path.default.dirname(current);
|
|
@@ -948,9 +972,34 @@ function readCliVersion() {
|
|
|
948
972
|
}
|
|
949
973
|
current = parent;
|
|
950
974
|
}
|
|
951
|
-
cachedCliVersion = "unknown";
|
|
975
|
+
cachedCliVersion = fallbackVersion ?? "unknown";
|
|
952
976
|
return cachedCliVersion;
|
|
953
977
|
}
|
|
978
|
+
function isCliPackageName(value) {
|
|
979
|
+
return value === "@eslint-config-snapshot/cli" || value === "eslint-config-snapshot";
|
|
980
|
+
}
|
|
981
|
+
function readVersionFromResolvedEntry(entryAbs) {
|
|
982
|
+
let current = import_node_path.default.resolve(import_node_path.default.dirname(entryAbs));
|
|
983
|
+
while (true) {
|
|
984
|
+
const packageJsonPath = import_node_path.default.join(current, "package.json");
|
|
985
|
+
if ((0, import_node_fs.existsSync)(packageJsonPath)) {
|
|
986
|
+
try {
|
|
987
|
+
const raw = (0, import_node_fs.readFileSync)(packageJsonPath, "utf8");
|
|
988
|
+
const parsed = JSON.parse(raw);
|
|
989
|
+
if (isCliPackageName(parsed.name) && typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
990
|
+
return parsed.version;
|
|
991
|
+
}
|
|
992
|
+
} catch {
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
const parent = import_node_path.default.dirname(current);
|
|
996
|
+
if (parent === current) {
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
current = parent;
|
|
1000
|
+
}
|
|
1001
|
+
return void 0;
|
|
1002
|
+
}
|
|
954
1003
|
function writeRunContextHeader(cwd, commandLabel, configPath, storedSnapshots) {
|
|
955
1004
|
if (!shouldShowRunLogs()) {
|
|
956
1005
|
return;
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import { Command, CommanderError, InvalidArgumentError } from "commander";
|
|
|
22
22
|
import fg from "fast-glob";
|
|
23
23
|
import { existsSync, readFileSync } from "fs";
|
|
24
24
|
import { access, mkdir, readFile, writeFile } from "fs/promises";
|
|
25
|
+
import { createRequire } from "module";
|
|
25
26
|
import path from "path";
|
|
26
27
|
import { createInterface } from "readline";
|
|
27
28
|
var SNAPSHOT_DIR = ".eslint-config-snapshot";
|
|
@@ -905,22 +906,45 @@ function readCliVersion() {
|
|
|
905
906
|
if (cachedCliVersion !== void 0) {
|
|
906
907
|
return cachedCliVersion;
|
|
907
908
|
}
|
|
909
|
+
const envPackageName = process.env.npm_package_name;
|
|
910
|
+
const envPackageVersion = process.env.npm_package_version;
|
|
911
|
+
if (isCliPackageName(envPackageName) && typeof envPackageVersion === "string" && envPackageVersion.length > 0) {
|
|
912
|
+
cachedCliVersion = envPackageVersion;
|
|
913
|
+
return cachedCliVersion;
|
|
914
|
+
}
|
|
908
915
|
const scriptPath = process.argv[1];
|
|
909
916
|
if (!scriptPath) {
|
|
910
917
|
cachedCliVersion = "unknown";
|
|
911
918
|
return cachedCliVersion;
|
|
912
919
|
}
|
|
920
|
+
try {
|
|
921
|
+
const req = createRequire(path.resolve(scriptPath));
|
|
922
|
+
const resolvedCliEntry = req.resolve("@eslint-config-snapshot/cli");
|
|
923
|
+
const resolvedVersion = readVersionFromResolvedEntry(resolvedCliEntry);
|
|
924
|
+
if (resolvedVersion !== void 0) {
|
|
925
|
+
cachedCliVersion = resolvedVersion;
|
|
926
|
+
return cachedCliVersion;
|
|
927
|
+
}
|
|
928
|
+
} catch {
|
|
929
|
+
}
|
|
913
930
|
let current = path.resolve(path.dirname(scriptPath));
|
|
931
|
+
let fallbackVersion;
|
|
914
932
|
while (true) {
|
|
915
933
|
const packageJsonPath = path.join(current, "package.json");
|
|
916
934
|
if (existsSync(packageJsonPath)) {
|
|
917
935
|
try {
|
|
918
936
|
const raw = readFileSync(packageJsonPath, "utf8");
|
|
919
937
|
const parsed = JSON.parse(raw);
|
|
920
|
-
|
|
921
|
-
|
|
938
|
+
if (typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
939
|
+
if (isCliPackageName(parsed.name)) {
|
|
940
|
+
cachedCliVersion = parsed.version;
|
|
941
|
+
return cachedCliVersion;
|
|
942
|
+
}
|
|
943
|
+
if (fallbackVersion === void 0) {
|
|
944
|
+
fallbackVersion = parsed.version;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
922
947
|
} catch {
|
|
923
|
-
break;
|
|
924
948
|
}
|
|
925
949
|
}
|
|
926
950
|
const parent = path.dirname(current);
|
|
@@ -929,9 +953,34 @@ function readCliVersion() {
|
|
|
929
953
|
}
|
|
930
954
|
current = parent;
|
|
931
955
|
}
|
|
932
|
-
cachedCliVersion = "unknown";
|
|
956
|
+
cachedCliVersion = fallbackVersion ?? "unknown";
|
|
933
957
|
return cachedCliVersion;
|
|
934
958
|
}
|
|
959
|
+
function isCliPackageName(value) {
|
|
960
|
+
return value === "@eslint-config-snapshot/cli" || value === "eslint-config-snapshot";
|
|
961
|
+
}
|
|
962
|
+
function readVersionFromResolvedEntry(entryAbs) {
|
|
963
|
+
let current = path.resolve(path.dirname(entryAbs));
|
|
964
|
+
while (true) {
|
|
965
|
+
const packageJsonPath = path.join(current, "package.json");
|
|
966
|
+
if (existsSync(packageJsonPath)) {
|
|
967
|
+
try {
|
|
968
|
+
const raw = readFileSync(packageJsonPath, "utf8");
|
|
969
|
+
const parsed = JSON.parse(raw);
|
|
970
|
+
if (isCliPackageName(parsed.name) && typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
971
|
+
return parsed.version;
|
|
972
|
+
}
|
|
973
|
+
} catch {
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
const parent = path.dirname(current);
|
|
977
|
+
if (parent === current) {
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
current = parent;
|
|
981
|
+
}
|
|
982
|
+
return void 0;
|
|
983
|
+
}
|
|
935
984
|
function writeRunContextHeader(cwd, commandLabel, configPath, storedSnapshots) {
|
|
936
985
|
if (!shouldShowRunLogs()) {
|
|
937
986
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-config-snapshot/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"@inquirer/prompts": "^8.2.0",
|
|
31
31
|
"commander": "^14.0.3",
|
|
32
32
|
"fast-glob": "^3.3.3",
|
|
33
|
-
"@eslint-config-snapshot/api": "0.
|
|
33
|
+
"@eslint-config-snapshot/api": "0.9.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { Command, CommanderError, InvalidArgumentError } from 'commander'
|
|
|
20
20
|
import fg from 'fast-glob'
|
|
21
21
|
import { existsSync, readFileSync } from 'node:fs'
|
|
22
22
|
import { access, mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
23
|
+
import { createRequire } from 'node:module'
|
|
23
24
|
import path from 'node:path'
|
|
24
25
|
import { createInterface } from 'node:readline'
|
|
25
26
|
|
|
@@ -1129,23 +1130,51 @@ function readCliVersion(): string {
|
|
|
1129
1130
|
return cachedCliVersion
|
|
1130
1131
|
}
|
|
1131
1132
|
|
|
1133
|
+
const envPackageName = process.env.npm_package_name
|
|
1134
|
+
const envPackageVersion = process.env.npm_package_version
|
|
1135
|
+
if (isCliPackageName(envPackageName) && typeof envPackageVersion === 'string' && envPackageVersion.length > 0) {
|
|
1136
|
+
cachedCliVersion = envPackageVersion
|
|
1137
|
+
return cachedCliVersion
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1132
1140
|
const scriptPath = process.argv[1]
|
|
1133
1141
|
if (!scriptPath) {
|
|
1134
1142
|
cachedCliVersion = 'unknown'
|
|
1135
1143
|
return cachedCliVersion
|
|
1136
1144
|
}
|
|
1137
1145
|
|
|
1146
|
+
try {
|
|
1147
|
+
const req = createRequire(path.resolve(scriptPath))
|
|
1148
|
+
const resolvedCliEntry = req.resolve('@eslint-config-snapshot/cli')
|
|
1149
|
+
const resolvedVersion = readVersionFromResolvedEntry(resolvedCliEntry)
|
|
1150
|
+
if (resolvedVersion !== undefined) {
|
|
1151
|
+
cachedCliVersion = resolvedVersion
|
|
1152
|
+
return cachedCliVersion
|
|
1153
|
+
}
|
|
1154
|
+
} catch {
|
|
1155
|
+
// continue to path-walk fallback
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1138
1158
|
let current = path.resolve(path.dirname(scriptPath))
|
|
1159
|
+
let fallbackVersion: string | undefined
|
|
1139
1160
|
while (true) {
|
|
1140
1161
|
const packageJsonPath = path.join(current, 'package.json')
|
|
1141
1162
|
if (existsSync(packageJsonPath)) {
|
|
1142
1163
|
try {
|
|
1143
1164
|
const raw = readFileSync(packageJsonPath, 'utf8')
|
|
1144
|
-
const parsed = JSON.parse(raw) as { version?: string }
|
|
1145
|
-
|
|
1146
|
-
|
|
1165
|
+
const parsed = JSON.parse(raw) as { name?: string; version?: string }
|
|
1166
|
+
if (typeof parsed.version === 'string' && parsed.version.length > 0) {
|
|
1167
|
+
if (isCliPackageName(parsed.name)) {
|
|
1168
|
+
cachedCliVersion = parsed.version
|
|
1169
|
+
return cachedCliVersion
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
if (fallbackVersion === undefined) {
|
|
1173
|
+
fallbackVersion = parsed.version
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1147
1176
|
} catch {
|
|
1148
|
-
|
|
1177
|
+
// continue walking up
|
|
1149
1178
|
}
|
|
1150
1179
|
}
|
|
1151
1180
|
|
|
@@ -1156,10 +1185,41 @@ function readCliVersion(): string {
|
|
|
1156
1185
|
current = parent
|
|
1157
1186
|
}
|
|
1158
1187
|
|
|
1159
|
-
cachedCliVersion = 'unknown'
|
|
1188
|
+
cachedCliVersion = fallbackVersion ?? 'unknown'
|
|
1160
1189
|
return cachedCliVersion
|
|
1161
1190
|
}
|
|
1162
1191
|
|
|
1192
|
+
function isCliPackageName(value: string | undefined): boolean {
|
|
1193
|
+
return value === '@eslint-config-snapshot/cli' || value === 'eslint-config-snapshot'
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
function readVersionFromResolvedEntry(entryAbs: string): string | undefined {
|
|
1197
|
+
let current = path.resolve(path.dirname(entryAbs))
|
|
1198
|
+
|
|
1199
|
+
while (true) {
|
|
1200
|
+
const packageJsonPath = path.join(current, 'package.json')
|
|
1201
|
+
if (existsSync(packageJsonPath)) {
|
|
1202
|
+
try {
|
|
1203
|
+
const raw = readFileSync(packageJsonPath, 'utf8')
|
|
1204
|
+
const parsed = JSON.parse(raw) as { name?: string; version?: string }
|
|
1205
|
+
if (isCliPackageName(parsed.name) && typeof parsed.version === 'string' && parsed.version.length > 0) {
|
|
1206
|
+
return parsed.version
|
|
1207
|
+
}
|
|
1208
|
+
} catch {
|
|
1209
|
+
// continue walking up
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
const parent = path.dirname(current)
|
|
1214
|
+
if (parent === current) {
|
|
1215
|
+
break
|
|
1216
|
+
}
|
|
1217
|
+
current = parent
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
return undefined
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1163
1223
|
function writeRunContextHeader(
|
|
1164
1224
|
cwd: string,
|
|
1165
1225
|
commandLabel: string,
|