@visulima/cerebro 1.0.27 → 1.0.29

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/package.json CHANGED
@@ -1,162 +1,163 @@
1
1
  {
2
- "name": "@visulima/cerebro",
3
- "version": "1.0.27",
4
- "description": "A delightful toolkit for building Node-powered CLIs.",
5
- "keywords": [
6
- "command",
7
- "line",
8
- "class",
9
- "terminal",
10
- "ansi",
11
- "cli",
12
- "opts",
13
- "nopt",
14
- "options",
15
- "args",
16
- "argv",
17
- "interactive",
18
- "commander",
19
- "clap",
20
- "cli-app",
21
- "minimist",
22
- "command line apps",
23
- "command-line-usage",
24
- "option",
25
- "parser",
26
- "argument",
27
- "flag",
28
- "gluegun",
29
- "meow",
30
- "oclif",
31
- "yargs"
32
- ],
33
- "homepage": "https://visulima.com/packages/cerebro",
34
- "repository": {
35
- "type": "git",
36
- "url": "https://github.com/visulima/visulima.git",
37
- "directory": "packages/cerebro"
2
+ "name": "@visulima/cerebro",
3
+ "version": "1.0.29",
4
+ "description": "A delightful toolkit for building Node-powered CLIs.",
5
+ "keywords": [
6
+ "command",
7
+ "line",
8
+ "class",
9
+ "terminal",
10
+ "ansi",
11
+ "cli",
12
+ "opts",
13
+ "nopt",
14
+ "options",
15
+ "args",
16
+ "argv",
17
+ "interactive",
18
+ "commander",
19
+ "clap",
20
+ "cli-app",
21
+ "minimist",
22
+ "command line apps",
23
+ "command-line-usage",
24
+ "option",
25
+ "parser",
26
+ "argument",
27
+ "flag",
28
+ "gluegun",
29
+ "meow",
30
+ "oclif",
31
+ "yargs"
32
+ ],
33
+ "homepage": "https://visulima.com/packages/cerebro",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/visulima/visulima.git",
37
+ "directory": "packages/cerebro"
38
+ },
39
+ "funding": [
40
+ {
41
+ "type": "github",
42
+ "url": "https://github.com/sponsors/prisis"
38
43
  },
39
- "funding": [
40
- {
41
- "type": "github",
42
- "url": "https://github.com/sponsors/prisis"
43
- },
44
- {
45
- "type": "consulting",
46
- "url": "https://anolilab.com/support"
47
- }
48
- ],
49
- "license": "MIT",
50
- "author": {
51
- "name": "Daniel Bannert",
52
- "email": "d.bannert@anolilab.de"
53
- },
54
- "sideEffects": false,
55
- "type": "module",
56
- "exports": {
57
- ".": {
58
- "require": {
59
- "types": "./dist/index.d.cts",
60
- "default": "./dist/index.cjs"
61
- },
62
- "import": {
63
- "types": "./dist/index.d.ts",
64
- "default": "./dist/index.js"
65
- }
66
- },
67
- "./package.json": "./package.json"
68
- },
69
- "main": "dist/index.cjs",
70
- "module": "dist/index.js",
71
- "source": "src/index.ts",
72
- "types": "dist/index.d.ts",
73
- "files": [
74
- "dist",
75
- "README.md",
76
- "CHANGELOG.md",
77
- "LICENSE.md"
78
- ],
79
- "scripts": {
80
- "build": "rimraf dist && cross-env NODE_ENV=development tsup",
81
- "build:prod": "rimraf dist && cross-env NODE_ENV=production tsup",
82
- "clean": "rimraf node_modules dist .eslintcache",
83
- "dev": "pnpm run build --watch",
84
- "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
85
- "lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix",
86
- "lint:packagejson": "publint --strict",
87
- "lint:prettier": "prettier --config=.prettierrc.cjs --check .",
88
- "lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
89
- "lint:types": "tsc --noEmit --project tsconfig.json",
90
- "test": "vitest run",
91
- "test:coverage": "vitest run --coverage",
92
- "test:ui": "vitest --ui --coverage.enabled=true",
93
- "test:watch": "vitest"
94
- },
95
- "dependencies": {
96
- "@visulima/boxen": "1.0.7",
97
- "@visulima/colorize": "1.4.0",
98
- "@visulima/package": "1.7.6",
99
- "@visulima/pail": "1.1.10",
100
- "cli-table3": "^0.6.5",
101
- "command-line-args": "^5.2.1",
102
- "fastest-levenshtein": "^1.0.16"
103
- },
104
- "devDependencies": {
105
- "@anolilab/eslint-config": "^15.0.3",
106
- "@anolilab/prettier-config": "^5.0.14",
107
- "@anolilab/semantic-release-preset": "^8.0.3",
108
- "@babel/core": "^7.24.5",
109
- "@eslint-types/deprecation": "^2.0.0",
110
- "@eslint-types/import": "^2.29.1",
111
- "@eslint-types/jsdoc": "^48.2.2",
112
- "@eslint-types/typescript-eslint": "^7.5.0",
113
- "@eslint-types/unicorn": "^52.0.0",
114
- "@rushstack/eslint-plugin-security": "^0.8.1",
115
- "@total-typescript/ts-reset": "^0.5.1",
116
- "@types/command-line-args": "^5.2.3",
117
- "@types/node": "18.18.5",
118
- "@visulima/nextra-theme-docs": "4.0.23",
119
- "@vitest/coverage-v8": "^1.6.0",
120
- "camelcase": "8.0.0",
121
- "cross-env": "^7.0.3",
122
- "eslint": "^8.57.0",
123
- "eslint-plugin-deprecation": "^2.0.0",
124
- "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
125
- "eslint-plugin-mdx": "^3.1.5",
126
- "eslint-plugin-vitest": "^0.4.1",
127
- "eslint-plugin-vitest-globals": "^1.5.0",
128
- "prettier": "^3.2.5",
129
- "rimraf": "^5.0.7",
130
- "semantic-release": "^23.1.1",
131
- "sort-package-json": "^2.10.0",
132
- "strip-ansi": "^7.1.0",
133
- "tsup": "^8.0.2",
134
- "typescript": "^5.4.5",
135
- "vitest": "^1.6.0"
136
- },
137
- "engines": {
138
- "node": ">=18.* <=21.*"
139
- },
140
- "os": [
141
- "darwin",
142
- "linux",
143
- "win32"
144
- ],
145
- "publishConfig": {
146
- "access": "public",
147
- "provenance": true
44
+ {
45
+ "type": "consulting",
46
+ "url": "https://anolilab.com/support"
47
+ }
48
+ ],
49
+ "license": "MIT",
50
+ "author": {
51
+ "name": "Daniel Bannert",
52
+ "email": "d.bannert@anolilab.de"
53
+ },
54
+ "sideEffects": false,
55
+ "type": "module",
56
+ "exports": {
57
+ ".": {
58
+ "require": {
59
+ "types": "./dist/index.d.cts",
60
+ "default": "./dist/index.cjs"
61
+ },
62
+ "import": {
63
+ "types": "./dist/index.d.ts",
64
+ "default": "./dist/index.js"
65
+ }
148
66
  },
149
- "anolilab": {
150
- "eslint-config": {
151
- "plugin": {
152
- "tsdoc": false,
153
- "etc": false
154
- },
155
- "warn_on_unsupported_typescript_version": false,
156
- "info_on_disabling_jsx_react_rule": false,
157
- "info_on_disabling_prettier_conflict_rule": false,
158
- "info_on_disabling_jsonc_sort_keys_rule": false,
159
- "info_on_disabling_etc_no_deprecated": false
160
- }
67
+ "./package.json": "./package.json"
68
+ },
69
+ "main": "dist/index.cjs",
70
+ "module": "dist/index.js",
71
+ "source": "src/index.ts",
72
+ "types": "dist/index.d.ts",
73
+ "files": [
74
+ "dist",
75
+ "README.md",
76
+ "CHANGELOG.md",
77
+ "LICENSE.md"
78
+ ],
79
+ "dependencies": {
80
+ "@visulima/boxen": "1.0.8",
81
+ "@visulima/colorize": "1.4.1",
82
+ "@visulima/pail": "1.1.11",
83
+ "cli-table3": "^0.6.5",
84
+ "command-line-args": "^5.2.1",
85
+ "fastest-levenshtein": "^1.0.16"
86
+ },
87
+ "devDependencies": {
88
+ "@anolilab/eslint-config": "^15.0.3",
89
+ "@anolilab/prettier-config": "^5.0.14",
90
+ "@anolilab/semantic-release-pnpm": "^1.1.0",
91
+ "@anolilab/semantic-release-preset": "^8.1.0",
92
+ "@babel/core": "^7.24.5",
93
+ "@eslint-types/deprecation": "^2.0.0",
94
+ "@eslint-types/import": "^2.29.1",
95
+ "@eslint-types/jsdoc": "^48.2.2",
96
+ "@eslint-types/typescript-eslint": "^7.5.0",
97
+ "@eslint-types/unicorn": "^52.0.0",
98
+ "@rushstack/eslint-plugin-security": "^0.8.1",
99
+ "@total-typescript/ts-reset": "^0.5.1",
100
+ "@types/command-line-args": "^5.2.3",
101
+ "@types/node": "18.18.5",
102
+ "@visulima/nextra-theme-docs": "4.0.24",
103
+ "@visulima/package": "1.8.3",
104
+ "@visulima/path": "1.0.1",
105
+ "@vitest/coverage-v8": "^1.6.0",
106
+ "camelcase": "8.0.0",
107
+ "cross-env": "^7.0.3",
108
+ "eslint": "^8.57.0",
109
+ "eslint-plugin-deprecation": "^2.0.0",
110
+ "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
111
+ "eslint-plugin-mdx": "^3.1.5",
112
+ "eslint-plugin-vitest": "^0.4.1",
113
+ "eslint-plugin-vitest-globals": "^1.5.0",
114
+ "prettier": "^3.2.5",
115
+ "rimraf": "^5.0.7",
116
+ "semantic-release": "^23.1.1",
117
+ "strip-ansi": "^7.1.0",
118
+ "tsup": "^8.0.2",
119
+ "typescript": "^5.4.5",
120
+ "vitest": "^1.6.0"
121
+ },
122
+ "engines": {
123
+ "node": ">=18.* <=21.*"
124
+ },
125
+ "os": [
126
+ "darwin",
127
+ "linux",
128
+ "win32"
129
+ ],
130
+ "publishConfig": {
131
+ "access": "public",
132
+ "provenance": true
133
+ },
134
+ "anolilab": {
135
+ "eslint-config": {
136
+ "plugin": {
137
+ "tsdoc": false,
138
+ "etc": false
139
+ },
140
+ "warn_on_unsupported_typescript_version": false,
141
+ "info_on_disabling_jsx_react_rule": false,
142
+ "info_on_disabling_prettier_conflict_rule": false,
143
+ "info_on_disabling_jsonc_sort_keys_rule": false,
144
+ "info_on_disabling_etc_no_deprecated": false
161
145
  }
162
- }
146
+ },
147
+ "scripts": {
148
+ "build": "rimraf dist && cross-env NODE_ENV=development tsup",
149
+ "build:prod": "rimraf dist && cross-env NODE_ENV=production tsup",
150
+ "clean": "rimraf node_modules dist .eslintcache",
151
+ "dev": "pnpm run build --watch",
152
+ "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
153
+ "lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix",
154
+ "lint:package-json": "publint --strict",
155
+ "lint:prettier": "prettier --config=.prettierrc.cjs --check .",
156
+ "lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
157
+ "lint:types": "tsc --noEmit --project tsconfig.json",
158
+ "test": "vitest run",
159
+ "test:coverage": "vitest run --coverage",
160
+ "test:ui": "vitest --ui --coverage.enabled=true",
161
+ "test:watch": "vitest"
162
+ }
163
+ }
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs');
4
- var path = require('path');
5
- var _package = require('@visulima/package');
6
- var https = require('https');
7
-
8
- var b=(t,e)=>{let r=t.split(".").map(Number),n=e.split(".").map(Number);for(let[i,o]of r.entries()){if(o>n[i])return !0;if(o<n[i])return !1}return !1},u=b;var S="last-update-check.json",f=t=>{let e=_package.findCacheDirectorySync(t);if(e===void 0)throw new Error("Could not find cache directory");return path.join(e,S)},l=t=>{let e=f(t);try{if(!fs.existsSync(e))return;let{lastUpdateCheck:r}=JSON.parse(fs.readFileSync(e,"utf8"));return r}catch{return}},g=t=>{let e=f(t),r=path.dirname(e);fs.existsSync(r)||fs.mkdirSync(r,{recursive:!0}),fs.writeFileSync(e,JSON.stringify({lastUpdateCheck:Date.now()}));};var x=async(t,e,r)=>{let n=r.replace("__NAME__",t);return await new Promise((i,o)=>{https.get(n,s=>{let a="";s.on("data",m=>a+=m),s.on("end",()=>{try{let p=JSON.parse(a)[e];p||o(new Error("Error getting version")),i(p);}catch{o(new Error("Could not parse version response"));}});}).on("error",s=>o(s));})},y=x;var D=async({alwaysRun:t,debug:e,distTag:r="latest",pkg:n,registryUrl:i="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:o=1e3*60*60*24})=>{let s=l(n.name);if(t||!s||s<Date.now()-o){let a=await y(n.name,r,i);if(g(n.name),u(a,n.version))return a;e&&console.error(`Latest version (${a}) not newer than current version (${n.version})`);}else e&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${o}ms but only ${Date.now()-s}ms since last check.`);return null},T=D;
9
-
10
- module.exports = T;
11
- //# sourceMappingURL=out.js.map
12
-
13
- module.exports = module.exports;
14
- //# sourceMappingURL=has-new-version-RHNN4QW4.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/util/semver-gt.ts","../src/update-notifier/cache.ts","../src/update-notifier/get-dist-version.ts","../src/update-notifier/has-new-version.ts"],"names":["semverGt","version1","version2","v1Components","v2Components","index","v1Component","semver_gt_default","existsSync","mkdirSync","readFileSync","writeFileSync","dirname","join","findCacheDirectorySync","FILE_NAME","getConfigFile","packageName","cacheDirectory","getLastUpdate","configFile","lastUpdateCheck","saveLastUpdate","configDirectory","get","getDistributionVersion","distributionTag","registryUrl","url","resolve","reject","message","body","chunk","version","error","get_dist_version_default","hasNewVersion","alwaysRun","debug","pkg","updateCheckInterval","latestVersion","has_new_version_default"],"mappings":"AAAA,IAAMA,EAAW,CAACC,EAAkBC,IAA8B,CAC9D,IAAMC,EAAyBF,EAAS,MAAM,GAAG,EAAE,IAAI,MAAM,EACvDG,EAAyBF,EAAS,MAAM,GAAG,EAAE,IAAI,MAAM,EAG7D,OAAW,CAACG,EAAOC,CAAW,IAAKH,EAAa,QAAQ,EAAG,CACvD,GAAIG,EAAeF,EAAaC,CAAe,EAC3C,MAAO,GAGX,GAAIC,EAAeF,EAAaC,CAAe,EAC3C,MAAO,EAEf,CAEA,MAAO,EACX,EAEOE,EAAQP,EClBf,OAAS,cAAAQ,EAAY,aAAAC,EAAW,gBAAAC,EAAc,iBAAAC,MAAqB,KACnE,OAAS,WAAAC,EAAS,QAAAC,MAAY,OAE9B,OAAS,0BAAAC,MAA8B,oBAEvC,IAAMC,EAAY,yBASZC,EAAiBC,GAAgC,CACnD,IAAMC,EAAiBJ,EAAuBG,CAAW,EAEzD,GAAIC,IAAmB,OACnB,MAAM,IAAI,MAAM,gCAAgC,EAGpD,OAAOL,EAAKK,EAAgBH,CAAS,CACzC,EAQaI,EAAiBF,GAA4C,CACtE,IAAMG,EAAaJ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AAI,EAE9C,GAAIF,GAAa,CAACjB,GAAmBA,EAAkB,KAAK,IAAI,EAAIoB,EAAqB,CACrF,IAAMC,EAAgB,MAAMN,EAAuBI,EAAI,KAAMd,EAAiBC,CAAW,EAIzF,GAFAL,EAAekB,EAAI,IAAI,EAEnBjC,EAASmC,EAAeF,EAAI,OAAO,EACnC,OAAOE,EAGPH,GAEA,QAAQ,MAAM,mBAAmBG,CAAa,qCAAqCF,EAAI,OAAO,GAAG,CAEzG,MAAWD,GAEP,QAAQ,MACJ,gFAAgFE,CAAmB,eAC/F,KAAK,IAAI,EAAIpB,CACjB,sBACJ,EAGJ,OAAO,IACX,EAYOsB,EAAQN","sourcesContent":["const semverGt = (version1: string, version2: string): boolean => {\n const v1Components: number[] = version1.split(\".\").map(Number);\n const v2Components: number[] = version2.split(\".\").map(Number);\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const [index, v1Component] of v1Components.entries()) {\n if (v1Component > (v2Components[index as number] as number)) {\n return true;\n }\n\n if (v1Component < (v2Components[index as number] as number)) {\n return false;\n }\n }\n\n return false;\n};\n\nexport default semverGt;\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nimport { findCacheDirectorySync } from \"@visulima/package\";\n\nconst FILE_NAME = \"last-update-check.json\";\n\n/**\n * Retrieves the configuration file path for the given package name.\n *\n * @param {string} packageName - The name of the package.\n * @throws {Error} - If the cache directory cannot be found.\n * @returns {string} - The absolute path to the configuration file.\n */\nconst getConfigFile = (packageName: string): string => {\n const cacheDirectory = findCacheDirectorySync(packageName);\n\n if (cacheDirectory === undefined) {\n throw new Error(\"Could not find cache directory\");\n }\n\n return join(cacheDirectory, FILE_NAME);\n};\n\n/**\n * Retrieves the last update check timestamp for the specified package.\n *\n * @param {string} packageName - The name of the package.\n * @returns {number | undefined} - The timestamp of the last update check, or undefined if the check failed.\n */\nexport const getLastUpdate = (packageName: string): number | undefined => {\n const configFile = getConfigFile(packageName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(configFile)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const { lastUpdateCheck } = JSON.parse(readFileSync(configFile, \"utf8\")) as { lastUpdateCheck: number };\n\n return lastUpdateCheck as number;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Saves the last update time for a given package.\n *\n * @param {string} packageName - The name of the package.\n * @returns {void}\n */\nexport const saveLastUpdate = (packageName: string): void => {\n const configFile = getConfigFile(packageName);\n const configDirectory = dirname(configFile);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(configDirectory)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(configDirectory, { recursive: true });\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));\n};\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { IncomingMessage } from \"node:http\";\nimport { get } from \"node:https\";\n\nconst getDistributionVersion = async (packageName: string, distributionTag: string, registryUrl: string): Promise<string> => {\n const url = registryUrl.replace(\"__NAME__\", packageName);\n\n // eslint-disable-next-line compat/compat\n return await new Promise<string>((resolve, reject) => {\n get(url, (message: IncomingMessage) => {\n let body = \"\";\n\n // eslint-disable-next-line no-return-assign\n message.on(\"data\", (chunk) => (body += chunk));\n message.on(\"end\", () => {\n try {\n const json = JSON.parse(body) as Record<string, string>;\n // eslint-disable-next-line security/detect-object-injection\n const version = json[distributionTag];\n\n if (!version) {\n reject(new Error(\"Error getting version\"));\n }\n\n resolve(version as string);\n } catch {\n reject(new Error(\"Could not parse version response\"));\n }\n });\n }).on(\"error\", (error) => reject(error));\n });\n};\n\nexport default getDistributionVersion;\n","import semverGt from \"../util/semver-gt\";\nimport { getLastUpdate, saveLastUpdate } from \"./cache\";\nimport getDistributionVersion from \"./get-dist-version\";\n\nconst hasNewVersion = async ({\n alwaysRun,\n debug,\n distTag: distributionTag = \"latest\",\n pkg,\n registryUrl = \"https://registry.npmjs.org/-/package/__NAME__/dist-tags\",\n updateCheckInterval = 1000 * 60 * 60 * 24,\n}: UpdateNotifierOptions): Promise<string | null> => {\n const lastUpdateCheck = getLastUpdate(pkg.name);\n\n if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {\n const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);\n\n saveLastUpdate(pkg.name);\n\n if (semverGt(latestVersion, pkg.version)) {\n return latestVersion;\n }\n\n if (debug) {\n // eslint-disable-next-line no-console\n console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);\n }\n } else if (debug) {\n // eslint-disable-next-line no-console\n console.error(\n `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${\n Date.now() - lastUpdateCheck\n }ms since last check.`,\n );\n }\n\n return null;\n};\n\nexport type UpdateNotifierOptions = {\n alwaysRun?: boolean;\n debug?: boolean;\n distTag?: string;\n pkg: { name: string; version: string };\n registryUrl?: string;\n shouldNotifyInNpmScript?: boolean;\n updateCheckInterval?: number;\n};\n\nexport default hasNewVersion;\n"]}
@@ -1,10 +0,0 @@
1
- import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
2
- import { dirname, join } from 'node:path';
3
- import { findCacheDirectorySync } from '@visulima/package';
4
- import { get } from 'node:https';
5
-
6
- var h=(t,e)=>{let r=t.split(".").map(Number),n=e.split(".").map(Number);for(let[i,o]of r.entries()){if(o>n[i])return !0;if(o<n[i])return !1}return !1},d=h;var _="last-update-check.json",l=t=>{let e=findCacheDirectorySync(t);if(e===void 0)throw new Error("Could not find cache directory");return join(e,_)},g=t=>{let e=l(t);try{if(!existsSync(e))return;let{lastUpdateCheck:r}=JSON.parse(readFileSync(e,"utf8"));return r}catch{return}},y=t=>{let e=l(t),r=dirname(e);existsSync(r)||mkdirSync(r,{recursive:!0}),writeFileSync(e,JSON.stringify({lastUpdateCheck:Date.now()}));};var D=async(t,e,r)=>{let n=r.replace("__NAME__",t);return await new Promise((i,o)=>{get(n,s=>{let a="";s.on("data",p=>a+=p),s.on("end",()=>{try{let u=JSON.parse(a)[e];u||o(new Error("Error getting version")),i(u);}catch{o(new Error("Could not parse version response"));}});}).on("error",s=>o(s));})},b=D;var E=async({alwaysRun:t,debug:e,distTag:r="latest",pkg:n,registryUrl:i="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:o=1e3*60*60*24})=>{let s=g(n.name);if(t||!s||s<Date.now()-o){let a=await b(n.name,r,i);if(y(n.name),d(a,n.version))return a;e&&console.error(`Latest version (${a}) not newer than current version (${n.version})`);}else e&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${o}ms but only ${Date.now()-s}ms since last check.`);return null},G=E;
7
-
8
- export { G as default };
9
- //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=has-new-version-UY375FY3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/util/semver-gt.ts","../src/update-notifier/cache.ts","../src/update-notifier/get-dist-version.ts","../src/update-notifier/has-new-version.ts"],"names":["semverGt","version1","version2","v1Components","v2Components","index","v1Component","semver_gt_default","existsSync","mkdirSync","readFileSync","writeFileSync","dirname","join","findCacheDirectorySync","FILE_NAME","getConfigFile","packageName","cacheDirectory","getLastUpdate","configFile","lastUpdateCheck","saveLastUpdate","configDirectory","get","getDistributionVersion","distributionTag","registryUrl","url","resolve","reject","message","body","chunk","version","error","get_dist_version_default","hasNewVersion","alwaysRun","debug","pkg","updateCheckInterval","latestVersion","has_new_version_default"],"mappings":"AAAA,IAAMA,EAAW,CAACC,EAAkBC,IAA8B,CAC9D,IAAMC,EAAyBF,EAAS,MAAM,GAAG,EAAE,IAAI,MAAM,EACvDG,EAAyBF,EAAS,MAAM,GAAG,EAAE,IAAI,MAAM,EAG7D,OAAW,CAACG,EAAOC,CAAW,IAAKH,EAAa,QAAQ,EAAG,CACvD,GAAIG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,IAAMG,EAFO,KAAK,MAAMF,CAAI,EAEPN,CAAe,EAE/BQ,GACDJ,EAAO,IAAI,MAAM,uBAAuB,CAAC,EAG7CD,EAAQK,CAAiB,CAC7B,MAAQ,CACJJ,EAAO,IAAI,MAAM,kCAAkC,CAAC,CACxD,CACJ,CAAC,CACL,CAAC,EAAE,GAAG,QAAUK,GAAUL,EAAOK,CAAK,CAAC,CAC3C,CAAC,CACL,EAEOC,EAAQX,EC7Bf,IAAMY,EAAgB,MAAO,CACzB,UAAAC,EACA,MAAAC,EACA,QAASb,EAAkB,SAC3B,IAAAc,EACA,YAAAb,EAAc,0DACd,oBAAAc,EAAsB,IAAO,GAAK,GAAK,EAC3C,IAAqD,CACjD,IAAMpB,EAAkBF,EAAcqB,EAAI,IAAI,EAE9C,GAAIF,GAAa,CAACjB,GAAmBA,EAAkB,KAAK,IAAI,EAAIoB,EAAqB,CACrF,IAAMC,EAAgB,MAAMN,EAAuBI,EAAI,KAAMd,EAAiBC,CAAW,EAIzF,GAFAL,EAAekB,EAAI,IAAI,EAEnBjC,EAASmC,EAAeF,EAAI,OAAO,EACnC,OAAOE,EAGPH,GAEA,QAAQ,MAAM,mBAAmBG,CAAa,qCAAqCF,EAAI,OAAO,GAAG,CAEzG,MAAWD,GAEP,QAAQ,MACJ,gFAAgFE,CAAmB,eAC/F,KAAK,IAAI,EAAIpB,CACjB,sBACJ,EAGJ,OAAO,IACX,EAYOsB,EAAQN","sourcesContent":["const semverGt = (version1: string, version2: string): boolean => {\n const v1Components: number[] = version1.split(\".\").map(Number);\n const v2Components: number[] = version2.split(\".\").map(Number);\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const [index, v1Component] of v1Components.entries()) {\n if (v1Component > (v2Components[index as number] as number)) {\n return true;\n }\n\n if (v1Component < (v2Components[index as number] as number)) {\n return false;\n }\n }\n\n return false;\n};\n\nexport default semverGt;\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nimport { findCacheDirectorySync } from \"@visulima/package\";\n\nconst FILE_NAME = \"last-update-check.json\";\n\n/**\n * Retrieves the configuration file path for the given package name.\n *\n * @param {string} packageName - The name of the package.\n * @throws {Error} - If the cache directory cannot be found.\n * @returns {string} - The absolute path to the configuration file.\n */\nconst getConfigFile = (packageName: string): string => {\n const cacheDirectory = findCacheDirectorySync(packageName);\n\n if (cacheDirectory === undefined) {\n throw new Error(\"Could not find cache directory\");\n }\n\n return join(cacheDirectory, FILE_NAME);\n};\n\n/**\n * Retrieves the last update check timestamp for the specified package.\n *\n * @param {string} packageName - The name of the package.\n * @returns {number | undefined} - The timestamp of the last update check, or undefined if the check failed.\n */\nexport const getLastUpdate = (packageName: string): number | undefined => {\n const configFile = getConfigFile(packageName);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(configFile)) {\n return undefined;\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const { lastUpdateCheck } = JSON.parse(readFileSync(configFile, \"utf8\")) as { lastUpdateCheck: number };\n\n return lastUpdateCheck as number;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Saves the last update time for a given package.\n *\n * @param {string} packageName - The name of the package.\n * @returns {void}\n */\nexport const saveLastUpdate = (packageName: string): void => {\n const configFile = getConfigFile(packageName);\n const configDirectory = dirname(configFile);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(configDirectory)) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdirSync(configDirectory, { recursive: true });\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));\n};\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { IncomingMessage } from \"node:http\";\nimport { get } from \"node:https\";\n\nconst getDistributionVersion = async (packageName: string, distributionTag: string, registryUrl: string): Promise<string> => {\n const url = registryUrl.replace(\"__NAME__\", packageName);\n\n // eslint-disable-next-line compat/compat\n return await new Promise<string>((resolve, reject) => {\n get(url, (message: IncomingMessage) => {\n let body = \"\";\n\n // eslint-disable-next-line no-return-assign\n message.on(\"data\", (chunk) => (body += chunk));\n message.on(\"end\", () => {\n try {\n const json = JSON.parse(body) as Record<string, string>;\n // eslint-disable-next-line security/detect-object-injection\n const version = json[distributionTag];\n\n if (!version) {\n reject(new Error(\"Error getting version\"));\n }\n\n resolve(version as string);\n } catch {\n reject(new Error(\"Could not parse version response\"));\n }\n });\n }).on(\"error\", (error) => reject(error));\n });\n};\n\nexport default getDistributionVersion;\n","import semverGt from \"../util/semver-gt\";\nimport { getLastUpdate, saveLastUpdate } from \"./cache\";\nimport getDistributionVersion from \"./get-dist-version\";\n\nconst hasNewVersion = async ({\n alwaysRun,\n debug,\n distTag: distributionTag = \"latest\",\n pkg,\n registryUrl = \"https://registry.npmjs.org/-/package/__NAME__/dist-tags\",\n updateCheckInterval = 1000 * 60 * 60 * 24,\n}: UpdateNotifierOptions): Promise<string | null> => {\n const lastUpdateCheck = getLastUpdate(pkg.name);\n\n if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {\n const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);\n\n saveLastUpdate(pkg.name);\n\n if (semverGt(latestVersion, pkg.version)) {\n return latestVersion;\n }\n\n if (debug) {\n // eslint-disable-next-line no-console\n console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);\n }\n } else if (debug) {\n // eslint-disable-next-line no-console\n console.error(\n `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${\n Date.now() - lastUpdateCheck\n }ms since last check.`,\n );\n }\n\n return null;\n};\n\nexport type UpdateNotifierOptions = {\n alwaysRun?: boolean;\n debug?: boolean;\n distTag?: string;\n pkg: { name: string; version: string };\n registryUrl?: string;\n shouldNotifyInNpmScript?: boolean;\n updateCheckInterval?: number;\n};\n\nexport default hasNewVersion;\n"]}