@meterian/cli 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/dist/cli.js +80 -5
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -20705,7 +20705,7 @@ var require_log4js = __commonJS({
20705
20705
  var require_api_timeouts = __commonJS({
20706
20706
  "../../src/meterian/api-timeouts.js"(exports2, module2) {
20707
20707
  var API_TIMEOUTS = {
20708
- KIWI_API: 5e3,
20708
+ KIWI_API: 15e3,
20709
20709
  // KiwiAPI advisories, safe versions
20710
20710
  ACCOUNT_OPERATION: 1e4,
20711
20711
  // AccountsAPI
@@ -20887,8 +20887,15 @@ var require_FileSystemFacadeNetwork = __commonJS({
20887
20887
  dir: {
20888
20888
  read: async (path3) => {
20889
20889
  if (typeof path3 == "string") path3 = vscode.Uri.file(path3);
20890
- const files = await vscode.workspace.fs.readDirectory(path3);
20891
- return files.map((f) => f[0]);
20890
+ try {
20891
+ const files = await vscode.workspace.fs.readDirectory(path3);
20892
+ return files.map((f) => f[0]);
20893
+ } catch (err) {
20894
+ if (err instanceof vscode.FileSystemError && err.code === "Canceled") {
20895
+ return [];
20896
+ }
20897
+ throw err;
20898
+ }
20892
20899
  },
20893
20900
  create: async (path3) => {
20894
20901
  if (typeof path3 == "string") path3 = vscode.Uri.file(path3);
@@ -21040,6 +21047,40 @@ var require_vs = __commonJS({
21040
21047
  }
21041
21048
  });
21042
21049
 
21050
+ // ../../src/meterian/CanonicalUserId.js
21051
+ var require_CanonicalUserId = __commonJS({
21052
+ "../../src/meterian/CanonicalUserId.js"(exports2, module2) {
21053
+ var fs = require("fs");
21054
+ var path2 = require("path");
21055
+ var os2 = require("os");
21056
+ var log = require_log4js().getLogger("Heidi.CanonicalUserId");
21057
+ var USER_JSON_PATH = path2.join(os2.homedir(), ".meterian", "heidi", "config", "user.json");
21058
+ function getOrCreate(computeFn) {
21059
+ try {
21060
+ const content = fs.readFileSync(USER_JSON_PATH, "utf8");
21061
+ const { canonicalUserId } = JSON.parse(content);
21062
+ if (canonicalUserId && typeof canonicalUserId === "string") {
21063
+ return canonicalUserId;
21064
+ }
21065
+ } catch (_) {
21066
+ }
21067
+ const id = computeFn();
21068
+ if (!id || typeof id !== "string") {
21069
+ log.warn("computeFn returned invalid ID; canonical user ID not persisted");
21070
+ return id;
21071
+ }
21072
+ try {
21073
+ fs.mkdirSync(path2.dirname(USER_JSON_PATH), { recursive: true });
21074
+ fs.writeFileSync(USER_JSON_PATH, JSON.stringify({ canonicalUserId: id }));
21075
+ } catch (e) {
21076
+ log.warn(`Unable to persist canonical user ID: ${e.message}`);
21077
+ }
21078
+ return id;
21079
+ }
21080
+ module2.exports = { getOrCreate };
21081
+ }
21082
+ });
21083
+
21043
21084
  // ../../src/meterian/Auth.js
21044
21085
  var require_Auth = __commonJS({
21045
21086
  "../../src/meterian/Auth.js"(exports2, module2) {
@@ -21051,7 +21092,8 @@ var require_Auth = __commonJS({
21051
21092
  this.token = token;
21052
21093
  if (config != null) {
21053
21094
  const { workspace } = require_vs();
21054
- this.id = workspace.getId();
21095
+ const { getOrCreate } = require_CanonicalUserId();
21096
+ this.id = getOrCreate(() => workspace.getId());
21055
21097
  this.config = config;
21056
21098
  }
21057
21099
  }
@@ -21063,8 +21105,9 @@ var require_Auth = __commonJS({
21063
21105
  const machineId = crypto.createHash("sha256").update(data).digest("hex");
21064
21106
  const username = os2.userInfo().username;
21065
21107
  const usernameHash = crypto.createHash("md5").update(username).digest("hex");
21108
+ const { getOrCreate } = require_CanonicalUserId();
21066
21109
  const auth = new _Auth(null, null);
21067
- auth.id = machineId + ":" + usernameHash;
21110
+ auth.id = getOrCreate(() => machineId + ":" + usernameHash);
21068
21111
  return auth;
21069
21112
  }
21070
21113
  async isAuthenticated() {
@@ -21351,6 +21394,36 @@ var require_check = __commonJS({
21351
21394
  }
21352
21395
  });
21353
21396
 
21397
+ // package.json
21398
+ var require_package = __commonJS({
21399
+ "package.json"(exports2, module2) {
21400
+ module2.exports = {
21401
+ name: "@meterian/cli",
21402
+ version: "0.1.2",
21403
+ description: "Meterian security audit CLI \u2014 check open-source dependencies for vulnerabilities",
21404
+ bin: {
21405
+ meterian: "bin/meterian"
21406
+ },
21407
+ files: [
21408
+ "dist/",
21409
+ "bin/"
21410
+ ],
21411
+ scripts: {
21412
+ prepack: "esbuild src/cli.js --bundle --platform=node --external:vscode --outfile=dist/cli.js",
21413
+ build: "esbuild src/cli.js --bundle --platform=node --external:vscode --outfile=dist/cli.js",
21414
+ test: "echo 'Run tests from project root: npx jest tests/cli'"
21415
+ },
21416
+ devDependencies: {
21417
+ esbuild: "^0.25.0"
21418
+ },
21419
+ engines: {
21420
+ node: ">=18"
21421
+ },
21422
+ license: "MIT"
21423
+ };
21424
+ }
21425
+ });
21426
+
21354
21427
  // src/cli.js
21355
21428
  var path = require("path");
21356
21429
  var os = require("os");
@@ -21407,6 +21480,8 @@ async function dispatch(kiwi, kiwiLanguages, args, stdinContent) {
21407
21480
  ${HELP}`);
21408
21481
  }
21409
21482
  async function main() {
21483
+ const { version } = require_package();
21484
+ require_axios().defaults.headers.common["User-Agent"] = `meterian/cli ${version}`;
21410
21485
  const log4js = require_log4js();
21411
21486
  const logFilePath = path.join(os.homedir(), ".meterian", "heidi", "logs", "cli.log");
21412
21487
  log4js.configure({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meterian/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Meterian security audit CLI — check open-source dependencies for vulnerabilities",
5
5
  "bin": {
6
6
  "meterian": "bin/meterian"