@sly-cli/sly
Advanced tools
Comparing version
@@ -150,3 +150,2 @@ #!/usr/bin/env node | ||
import * as z3 from "zod"; | ||
import { cachified } from "cachified"; | ||
@@ -157,5 +156,110 @@ // src/cache.ts | ||
import { LRUCache } from "lru-cache"; | ||
import { lruCacheAdapter } from "cachified"; | ||
import { | ||
cachified as baseCachified, | ||
totalTtl | ||
} from "@epic-web/cachified"; | ||
// package.json | ||
var package_default = { | ||
name: "@sly-cli/sly", | ||
version: "1.10.0", | ||
description: "Sly is a CLI tool to add components, icons, and utilities as code, not dependencies.", | ||
type: "module", | ||
exports: { | ||
".": "./dist/index.js", | ||
"./ts-loader": "./ts-loader.js" | ||
}, | ||
bin: { | ||
sly: "start.js" | ||
}, | ||
publishConfig: { | ||
access: "public" | ||
}, | ||
license: "MIT", | ||
author: "Jacob Paris (https://twitter.com/jacobmparis)", | ||
repository: { | ||
type: "git", | ||
url: "git+https://github.com/jacobparis-insiders/sly.git", | ||
directory: "cli" | ||
}, | ||
files: [ | ||
"dist", | ||
"ts-loader.js" | ||
], | ||
keywords: [ | ||
"jacobparis" | ||
], | ||
scripts: { | ||
dev: "tsup --watch", | ||
build: "tsup", | ||
typecheck: "tsc --noEmit", | ||
clean: "rimraf dist", | ||
"start:dev": "REGISTRY_URL=http://localhost:3000/registry node dist/index.js", | ||
start: "node dist/index.js", | ||
release: "changeset version", | ||
pub: "npm run build && npm publish --access public", | ||
test: "vitest run" | ||
}, | ||
dependencies: { | ||
"@epic-web/cachified": "^5.1.2", | ||
chalk: "^5.3.0", | ||
commander: "^11.0.0", | ||
"compare-versions": "^6.0.0", | ||
cosmiconfig: "^8.2.0", | ||
esbuild: "^0.19.11", | ||
execa: "^7.1.1", | ||
"lru-cache": "^10.0.0", | ||
ora: "^6.3.1", | ||
prompts: "^2.4.2", | ||
zod: "^3.21.4" | ||
}, | ||
devDependencies: { | ||
"@gmrchk/cli-testing-library": "github:jpulec/cli-testing-library#patch-1", | ||
"@types/prompts": "^2.4.4", | ||
"@typescript-eslint/eslint-plugin": "^6.1.0", | ||
"@typescript-eslint/parser": "^6.1.0", | ||
eslint: "^8.45.0", | ||
"eslint-plugin-no-template-curly-in-string-fix": "^1.0.4", | ||
prettier: "^3.0.0", | ||
rimraf: "^5.0.1", | ||
tsup: "^7.1.0", | ||
typescript: "^5.1.6", | ||
vite: "^5.0.10", | ||
vitest: "^1.0.4" | ||
}, | ||
types: "./dist/index.d.ts", | ||
bugs: { | ||
url: "https://github.com/jacobparis-insiders/sly/issues" | ||
}, | ||
homepage: "https://github.com/jacobparis-insiders/sly#readme", | ||
main: "index.js" | ||
}; | ||
// src/cache.ts | ||
var lru = new LRUCache({ max: 1e3 }); | ||
var cache = lruCacheAdapter(lru); | ||
var cache = { | ||
set(key, value) { | ||
const ttl = totalTtl(value?.metadata); | ||
return lru.set(key, value, { | ||
ttl: ttl === Infinity ? void 0 : ttl, | ||
start: value?.metadata?.createdTime | ||
}); | ||
}, | ||
get(key) { | ||
return lru.get(key); | ||
}, | ||
delete(key) { | ||
return lru.delete(key); | ||
} | ||
}; | ||
async function cachified(options) { | ||
return baseCachified({ | ||
cache, | ||
// If the user has disabled the cache, force a fresh value | ||
forceFresh: process.env.CACHE !== "true", | ||
...options, | ||
// When they update the CLI, get fresh values | ||
key: `${package_default.version}-${options.key}` | ||
}); | ||
} | ||
var CACHE_DIRECTORY = process.env.CACHE_DIRECTORY || "node_modules/.cache/@sly-cli"; | ||
@@ -200,3 +304,7 @@ var CACHE_FILENAME = path.join(CACHE_DIRECTORY, "sly.json"); | ||
const result = await fetchRegistry( | ||
tree.map((item) => `${library}/${item.name}.json`) | ||
tree.map((item) => `${library}/${item.name}.json`), | ||
{ | ||
// When we're fetching the actual item for download, get fresh data | ||
forceFresh: true | ||
} | ||
).catch((error) => { | ||
@@ -211,3 +319,3 @@ logger.error(error); | ||
} | ||
async function fetchRegistry(paths) { | ||
async function fetchRegistry(paths, options = {}) { | ||
try { | ||
@@ -217,5 +325,4 @@ const response = await Promise.all( | ||
(path4) => cachified({ | ||
// TODO: add package.json version to key | ||
...options, | ||
key: `${baseUrl}/registry/${path4}`, | ||
cache, | ||
async getFreshValue() { | ||
@@ -648,80 +755,2 @@ return fetch(`${baseUrl}/registry/${path4}`).then( | ||
import { compareVersions } from "compare-versions"; | ||
// package.json | ||
var package_default = { | ||
name: "@sly-cli/sly", | ||
version: "1.9.0", | ||
description: "Sly is a CLI tool to add components, icons, and utilities as code, not dependencies.", | ||
type: "module", | ||
exports: { | ||
".": "./dist/index.js", | ||
"./ts-loader": "./ts-loader.js" | ||
}, | ||
bin: { | ||
sly: "start.js" | ||
}, | ||
publishConfig: { | ||
access: "public" | ||
}, | ||
license: "MIT", | ||
author: "Jacob Paris (https://twitter.com/jacobmparis)", | ||
repository: { | ||
type: "git", | ||
url: "git+https://github.com/jacobparis-insiders/sly.git", | ||
directory: "cli" | ||
}, | ||
files: [ | ||
"dist", | ||
"ts-loader.js" | ||
], | ||
keywords: [ | ||
"jacobparis" | ||
], | ||
scripts: { | ||
dev: "tsup --watch", | ||
build: "tsup", | ||
typecheck: "tsc --noEmit", | ||
clean: "rimraf dist", | ||
"start:dev": "REGISTRY_URL=http://localhost:3000/registry node dist/index.js", | ||
start: "node dist/index.js", | ||
release: "changeset version", | ||
pub: "npm run build && npm publish --access public", | ||
test: "vitest run" | ||
}, | ||
dependencies: { | ||
cachified: "^3.5.4", | ||
chalk: "^5.3.0", | ||
commander: "^11.0.0", | ||
"compare-versions": "^6.0.0", | ||
cosmiconfig: "^8.2.0", | ||
esbuild: "^0.19.11", | ||
execa: "^7.1.1", | ||
"lru-cache": "^10.0.0", | ||
ora: "^6.3.1", | ||
prompts: "^2.4.2", | ||
zod: "^3.21.4" | ||
}, | ||
devDependencies: { | ||
"@gmrchk/cli-testing-library": "github:jpulec/cli-testing-library#patch-1", | ||
"@types/prompts": "^2.4.4", | ||
"@typescript-eslint/eslint-plugin": "^6.1.0", | ||
"@typescript-eslint/parser": "^6.1.0", | ||
eslint: "^8.45.0", | ||
"eslint-plugin-no-template-curly-in-string-fix": "^1.0.4", | ||
prettier: "^3.0.0", | ||
rimraf: "^5.0.1", | ||
tsup: "^7.1.0", | ||
typescript: "^5.1.6", | ||
vite: "^5.0.10", | ||
vitest: "^1.0.4" | ||
}, | ||
types: "./dist/index.d.ts", | ||
bugs: { | ||
url: "https://github.com/jacobparis-insiders/sly/issues" | ||
}, | ||
homepage: "https://github.com/jacobparis-insiders/sly#readme", | ||
main: "index.js" | ||
}; | ||
// src/check-version.ts | ||
import chalk7 from "chalk"; | ||
@@ -728,0 +757,0 @@ function checkVersion() { |
{ | ||
"name": "@sly-cli/sly", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "Sly is a CLI tool to add components, icons, and utilities as code, not dependencies.", | ||
@@ -42,3 +42,3 @@ "type": "module", | ||
"dependencies": { | ||
"cachified": "^3.5.4", | ||
"@epic-web/cachified": "^5.1.2", | ||
"chalk": "^5.3.0", | ||
@@ -45,0 +45,0 @@ "commander": "^11.0.0", |
Sorry, the diff of this file is not supported yet
86333
2.67%842
3.57%26
4%+ Added
+ Added
- Removed
- Removed