Skip to content

Commit

Permalink
Update some dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Apr 26, 2024
1 parent b7db976 commit 57c21b0
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 9 deletions.
6 changes: 3 additions & 3 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
"files": {
"ignore": ["**/dist", "**/tmp", "**/fixtures", "packages/docs/.astro"]
},
Expand All @@ -19,7 +19,6 @@
"useSimplifiedLogicExpression": "error"
},
"nursery": {
"useNodeAssertStrict": "error",
"noRestrictedImports": {
"level": "error",
"options": {
Expand All @@ -31,7 +30,8 @@
}
},
"style": {
"noParameterAssign": "off"
"noParameterAssign": "off",
"useNodeAssertStrict": "error"
}
}
},
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ci": "biome ci . && installed-check --no-include-workspace-root --ignore-dev"
},
"devDependencies": {
"@biomejs/biome": "1.6.4",
"@biomejs/biome": "1.7.1",
"installed-check": "^9.3.0"
}
}
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@astrojs/check": "0.5.10",
"@types/mdast": "4.0.3",
"@types/unist": "3.0.2",
"astro": "4.6.0",
"astro": "4.7.0",
"hastscript": "9.0.0",
"kleur": "4.1.5",
"remark-cli": "12.0.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/knip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@
"devDependencies": {
"@jest/types": "^29.6.3",
"@release-it/bumper": "^6.0.1",
"@types/bun": "^1.0.12",
"@types/bun": "^1.1.0",
"@types/file-entry-cache": "5.0.4",
"@types/js-yaml": "^4.0.9",
"@types/minimist": "^1.2.5",
"@types/picomatch": "2.3.3",
"@types/resolve": "^1.20.6",
"@types/webpack": "^5.28.5",
"glob": "^10.3.12",
"playwright": "^1.43.0",
"release-it": "^17.1.1",
"type-fest": "^4.15.0",
"playwright": "^1.43.1",
"release-it": "^17.2.0",
"type-fest": "^4.17.0",
"typescript": "^5.4.2"
},
"engines": {
Expand Down
239 changes: 239 additions & 0 deletions templates/demo/script/demo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
local home = os.getenv("HOME")
local knip = home .. "/p/knip/knip"
local demo = knip .. "/templates/demo/monorepo"

local screen = hs.screen.allScreens()[1]
local stageEnterDelay = 1;
local stageExitDelay = 0.5;
local typeSpeedNormal = 0.05;
local typeSpeedFast = 0.01;

-- Keys

local function pressReturn()
hs.eventtap.keyStroke({}, "return")
end

local function pressDown()
hs.eventtap.keyStroke({}, "down")
end

local function saveFile()
hs.eventtap.keyStroke({ "cmd" }, "S")
end

local function stopRecording()
hs.eventtap.keyStroke({ "ctrl", "cmd" }, "escape")
end

-- Generic helpers

local function runInSequence(tasks)
local index = 1
local function runNextTask()
if index <= #tasks then
local currentTask = tasks[index]
index = index + 1
currentTask(runNextTask)
end
end
runNextTask()
end

local function typeText(text, speed, callback)
local index = 1
hs.timer.doUntil(function()
return index > #text
end, function()
hs.eventtap.keyStrokes(text:sub(index, index))
index = index + 1
if index > #text and callback then
hs.timer.doAfter(0.3, function()
pressReturn()
callback()
end)
end
end, speed)
end

-- Stage helpers

local function showMessage(text)
local id = hs.alert.show(text, screen, s2, 20)
return function()
hs.alert.closeSpecific(id, 2)
end
end

local function leaveStage(close, done)
hs.timer.doAfter(stageExitDelay, function()
close()
hs.timer.doAfter(stageExitDelay, function()
done()
end)
end)
end

local function enterStage(done, text, fn)
local close = showMessage(text)
hs.timer.doAfter(stageEnterDelay, function()
if fn then
fn(function()
leaveStage(close, done);
end)
else
leaveStage(close, done);
end
end)
end

-- VS Code helpers

local function toFileStart()
hs.eventtap.keyStroke({ "cmd" }, "up")
end

local function goToTerminal()
hs.eventtap.keyStroke({ "ctrl" }, "`")
end

function openVSCodeWithFile(filePath, done)
hs.execute("code " .. filePath, true)
hs.timer.doAfter(stageEnterDelay, done);
end

-- Stages

local function init(done)
hs.execute("code ", true)
enterStage(done, "✂️ demo\n\nknip --watch\nknip --fix", function(cb)
openVSCodeWithFile(demo .. "/packages/shared/src/exports.ts", cb);
end)
end

local function startWatcher(done)
enterStage(done, "First up: start the watcher", function(cb)
goToTerminal()
hs.timer.doAfter(stageEnterDelay, function()
typeText("knip --watch", typeSpeedNormal, cb)
end);
end)
end

local function addUnusedExports(done)
enterStage(done, "Excellent, let's add some unused exports...", function(cb)
openVSCodeWithFile(
demo .. "/packages/shared/src/exports.ts",
function()
pressReturn()
typeText("export const UNUSED_EXPORT = 1;", typeSpeedFast, function()
saveFile();
pressReturn()
typeText("export interface UNUSED_INTERFACE {}", typeSpeedFast, function()
saveFile()
cb()
end)
end)
end)
end)
end

local function addUnlistedDependency(done)
enterStage(done, "Import an unlisted dependency...", function(cb)
openVSCodeWithFile(
demo .. "/packages/server/src/index.ts",
function()
toFileStart();
pressDown()
saveFile();
typeText("import { something } from 'not-in-package-json';", typeSpeedFast, function()
saveFile();
cb()
end)
end)
end)
end

local function undoUnlistedDependency(done)
enterStage(done, "...and get rid of it", function(cb)
toFileStart();
pressDown();
hs.eventtap.keyStroke({ "cmd", "shift" }, "K")
saveFile();
cb()
end)
end

local function splitTerminal(done)
goToTerminal()
hs.eventtap.keyStroke({ "cmd" }, "\\")
hs.timer.doAfter(stageEnterDelay, done);
end

local function createFiles(done)
enterStage(done, "Let's create some new files", function(cb)
typeText("touch packages/client/unused-file.js", typeSpeedFast, function()
typeText("touch packages/server/unused-as-well.js", typeSpeedFast, cb)
end)
end)
end

local function messageUnusedFiles(done)
enterStage(done, "Now we have some unused files and exports...", function(cb)
openVSCodeWithFile(
demo .. "/packages/server/src/index.ts",
function()
goToTerminal()
cb()
end)
end)
end

local function backToFirstFile(done)
enterStage(done, "Let's go back to the other package in the monorepo...", function(cb)
openVSCodeWithFile(demo .. "/packages/shared/src/exports.ts", cb)
end)
end

local function cleanupUsingAutoFix(done)
enterStage(done, "...and clean this up! ✂️", function(cb)
goToTerminal()
pressReturn()
typeText("knip --fix --allow-remove-files", typeSpeedNormal, function()
hs.timer.doAfter(stageEnterDelay, function()
hs.eventtap.keyStroke({ "option" }, "Z")
cb();
end);
end);
end);
end

local function endMessage(done)
enterStage(done, "That's it, thanks for watching!")
end

local function stop(done)
hs.timer.doAfter(stageEnterDelay, function()
stopRecording()
done();
end);
end

-- Set & run stages

local stages = {
init,
startWatcher,
addUnusedExports,
addUnlistedDependency,
undoUnlistedDependency,
splitTerminal,
createFiles,
messageUnusedFiles,
backToFirstFile,
cleanupUsingAutoFix,
endMessage,
stop
}

runInSequence(stages)

0 comments on commit 57c21b0

Please sign in to comment.