Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-eagles-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kitql/helpers': patch
---

enable spread args to log functions info, success, error. Add infoO and successO for options.
7 changes: 7 additions & 0 deletions .changeset/modern-rings-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'vite-plugin-watch-and-run': minor
'vite-plugin-kit-routes': minor
'vite-plugin-striper': minor
---

bump to vite 5
5 changes: 5 additions & 0 deletions .changeset/purple-paws-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-kitql': patch
---

using vite 5 for templates
5 changes: 5 additions & 0 deletions .changeset/quick-singers-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kitql/eslint-config': patch
---

tweak rules to have better default
15 changes: 9 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ jobs:
# with:
# nodeVersion: 18

- name: 🛠️ Prepare nx 1/2
uses: nrwl/nx-set-shas@v4
# - name: 🛠️ Prepare nx 1/2
# uses: nrwl/nx-set-shas@v4

- name: 🛠️ Prepare nx 2/2
run: git branch --track main origin/main
# - name: 🛠️ Prepare nx 2/2
# run: git branch --track main origin/main

- name: 👌 Run nx affected
run: pnpm nx:affected
# - name: 👌 Run nx affected
# run: pnpm nx:affected

- name: 👌 Run nx all
run: pnpm nx:all

# - name: 🚧 Build Packages
# run: pnpm run build
Expand Down
9 changes: 5 additions & 4 deletions packages/create-kitql/templates/kit-routes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.27.4",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.28.0",
Expand All @@ -30,8 +31,8 @@
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.5.0",
"vite": "^5.0.0",
"vite-plugin-kit-routes": "0.2.13-next.0",
"vitest": "^0.34.0"
"vitest": "^1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand Down
9 changes: 5 additions & 4 deletions packages/create-kitql/templates/sveltekit-remult/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.27.4",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.28.0",
Expand All @@ -32,9 +33,9 @@
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.5.0",
"vite": "^5.0.0",
"vite-plugin-kit-routes": "0.2.13-next.0",
"vite-plugin-striper": "0.1.6-next.1",
"vitest": "^0.34.0"
"vitest": "^1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"experimentalDecorators": true,
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
Expand Down
12 changes: 11 additions & 1 deletion packages/eslint-config/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ module.exports = {
],
plugins: ['unused-imports', 'svelte', '@typescript-eslint'],
rules: {
'no-console': ['error', { allow: ['info', 'warn', 'error', 'time', 'timeEnd'] }],
'no-console': ['error', { allow: ['info', 'warn', 'error', 'time', 'timeEnd', 'dir'] }],
'unused-imports/no-unused-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'no-empty': ['error', { allowEmptyCatch: true }],
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
Expand All @@ -38,6 +47,7 @@ module.exports = {
extends: ['plugin:@graphql-eslint/schema-all', 'plugin:@graphql-eslint/operations-all'],
rules: {
'@graphql-eslint/alphabetize': 'off',
'@graphql-eslint/no-one-place-fragments': 'off',
},
},
],
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"@theguild/eslint-config": "^0.11.1",
"@theguild/prettier-config": "2.0.2",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@typescript-eslint/parser": "6.14.0",
"@typescript-eslint/eslint-plugin": "6.15.0",
"@typescript-eslint/parser": "6.15.0",
"@vue/compiler-sfc": "3.3.4",
"commander": "^11.1.0",
"eslint": "8.55.0",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-svelte": "2.35.0",
"eslint-plugin-unused-imports": "3.0.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/handles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@
"devDependencies": {
"@kitql/eslint-config": "workspace:*",
"@kitql/helpers": "workspace:*",
"@sveltejs/adapter-node": "1.3.1",
"@sveltejs/kit": "1.30.1",
"@sveltejs/adapter-node": "^2.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/package": "2.2.2",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"publint": "0.2.4",
"svelte": "4.2.1",
"svelte-check": "3.6.0",
"tslib": "2.6.2",
"typescript": "5.3.2",
"vite": "4.5.1",
"vitest": "0.34.6"
"vite": "^5.0.0",
"vitest": "^1.0.0"
},
"sideEffects": false,
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/handles/src/lib/hooks/handleProxies.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const handleProxies = options => {

// We should not find more than 1
if (proxies_found.length > 1) {
throw error(
error(
403,
JSON.stringify({
error: 'Multiple proxies found',
Expand All @@ -37,7 +37,7 @@ export const handleProxies = options => {

// reject requests that don't come from the webapp, to avoid your proxy being abused.
if (!origin || new URL(origin).origin !== event.url.origin) {
throw error(403, 'Request Forbidden.')
error(403, 'Request Forbidden.')
}

// strip "from" from the request path
Expand Down
9 changes: 5 additions & 4 deletions packages/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@
"format": "kitql-lint --format"
},
"devDependencies": {
"@sveltejs/adapter-auto": "2.1.0",
"@sveltejs/kit": "1.30.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/package": "2.2.2",
"@kitql/eslint-config": "workspace:*",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"publint": "0.2.4",
"rollup-plugin-visualizer": "^5.9.2",
"svelte": "4.2.1",
"svelte-check": "3.6.0",
"tslib": "2.6.2",
"typescript": "5.3.2",
"vite": "4.5.1",
"vitest": "0.34.6"
"vite": "^5.0.0",
"vitest": "^1.0.0"
},
"sideEffects": false,
"publishConfig": {
Expand Down
18 changes: 9 additions & 9 deletions packages/helpers/src/lib/Log.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ describe('kitql - helper - Log', () => {
expect(log).to.have.property('toolName', 'tool name')

const spy = vi.spyOn(console, 'info')
log.info('level 0', { level: 0 })
log.info('level 1', { level: 1 })
log.info('level 2', { level: 2 })
log.infoO({ level: 0 }, 'level 0', { level: 0 })
log.infoO({ level: 1 }, 'level 1', { level: 1 })
log.infoO({ level: 2 }, 'level 2', { level: 2 })
expect(spy).toHaveBeenCalledTimes(3)
})

Expand All @@ -99,9 +99,9 @@ describe('kitql - helper - Log', () => {
expect(log).to.have.property('toolName', 'tool name')

const spy = vi.spyOn(console, 'info')
log.success('level 0', { level: 0 })
log.success('level 1', { level: 1 })
log.success('level 2', { level: 2 })
log.successO({ level: 0 }, 'level 0', { level: 0 })
log.successO({ level: 1 }, 'level 1', { level: 1 })
log.successO({ level: 2 }, 'level 2', { level: 2 })
expect(spy).toHaveBeenCalledTimes(3)
})

Expand Down Expand Up @@ -159,7 +159,7 @@ describe('kitql - helper - Log', () => {
expect(spy).toHaveBeenCalledOnce()

expect(stry0(result)).toMatchInlineSnapshot(
'"[\\"\\\\u001b[104m tool name \\\\u001b[49m with all colors: \\\\n \\\\u001b[40mbgBlack\\\\u001b[49m\\\\n \\\\u001b[100mbgBlackBright\\\\u001b[49m\\\\n \\\\u001b[44mbgBlue\\\\u001b[49m\\\\n \\\\u001b[104mbgBlueBright\\\\u001b[49m\\\\n \\\\u001b[46mbgCyan\\\\u001b[49m\\\\n \\\\u001b[106mbgCyanBright\\\\u001b[49m\\\\n \\\\u001b[42mbgGreen\\\\u001b[49m\\\\n \\\\u001b[102mbgGreenBright\\\\u001b[49m\\\\n \\\\u001b[45mbgMagenta\\\\u001b[49m\\\\n \\\\u001b[105mbgMagentaBright\\\\u001b[49m\\\\n \\\\u001b[41mbgRed\\\\u001b[49m\\\\n \\\\u001b[101mbgRedBright\\\\u001b[49m\\\\n \\\\u001b[47mbgWhite\\\\u001b[49m\\\\n \\\\u001b[107mbgWhiteBright\\\\u001b[49m\\\\n \\\\u001b[43mbgYellow\\\\u001b[49m\\\\n \\\\u001b[103mbgYellowBright\\\\u001b[49m\\\\n \\\\u001b[30mblack\\\\u001b[39m\\\\n \\\\u001b[90mblackBright\\\\u001b[39m\\\\n \\\\u001b[34mblue\\\\u001b[39m\\\\n \\\\u001b[94mblueBright\\\\u001b[39m\\\\n \\\\u001b[1mbold\\\\u001b[22m\\\\n \\\\u001b[36mcyan\\\\u001b[39m\\\\n \\\\u001b[96mcyanBright\\\\u001b[39m\\\\n \\\\u001b[2mdim\\\\u001b[22m\\\\n \\\\u001b[90mgray\\\\u001b[39m\\\\n \\\\u001b[32mgreen\\\\u001b[39m\\\\n \\\\u001b[92mgreenBright\\\\u001b[39m\\\\n \\\\u001b[8mhidden\\\\u001b[28m\\\\n \\\\u001b[7minverse\\\\u001b[27m\\\\n \\\\u001b[3mitalic\\\\u001b[23m\\\\n \\\\u001b[35mmagenta\\\\u001b[39m\\\\n \\\\u001b[95mmagentaBright\\\\u001b[39m\\\\n \\\\u001b[31mred\\\\u001b[39m\\\\n \\\\u001b[91mredBright\\\\u001b[39m\\\\n \\\\u001b[0mreset\\\\u001b[0m\\\\n \\\\u001b[9mstrikethrough\\\\u001b[29m\\\\n \\\\u001b[4munderline\\\\u001b[24m\\\\n \\\\u001b[37mwhite\\\\u001b[39m\\\\n \\\\u001b[97mwhiteBright\\\\u001b[39m\\\\n \\\\u001b[33myellow\\\\u001b[39m\\\\n \\\\u001b[93myellowBright\\\\u001b[39m\\\\n \\"]"',
`"["\\u001b[104m tool name \\u001b[49m","with all colors: \\n \\u001b[40mbgBlack\\u001b[49m\\n \\u001b[100mbgBlackBright\\u001b[49m\\n \\u001b[44mbgBlue\\u001b[49m\\n \\u001b[104mbgBlueBright\\u001b[49m\\n \\u001b[46mbgCyan\\u001b[49m\\n \\u001b[106mbgCyanBright\\u001b[49m\\n \\u001b[42mbgGreen\\u001b[49m\\n \\u001b[102mbgGreenBright\\u001b[49m\\n \\u001b[45mbgMagenta\\u001b[49m\\n \\u001b[105mbgMagentaBright\\u001b[49m\\n \\u001b[41mbgRed\\u001b[49m\\n \\u001b[101mbgRedBright\\u001b[49m\\n \\u001b[47mbgWhite\\u001b[49m\\n \\u001b[107mbgWhiteBright\\u001b[49m\\n \\u001b[43mbgYellow\\u001b[49m\\n \\u001b[103mbgYellowBright\\u001b[49m\\n \\u001b[30mblack\\u001b[39m\\n \\u001b[90mblackBright\\u001b[39m\\n \\u001b[34mblue\\u001b[39m\\n \\u001b[94mblueBright\\u001b[39m\\n \\u001b[1mbold\\u001b[22m\\n \\u001b[36mcyan\\u001b[39m\\n \\u001b[96mcyanBright\\u001b[39m\\n \\u001b[2mdim\\u001b[22m\\n \\u001b[90mgray\\u001b[39m\\n \\u001b[32mgreen\\u001b[39m\\n \\u001b[92mgreenBright\\u001b[39m\\n \\u001b[8mhidden\\u001b[28m\\n \\u001b[7minverse\\u001b[27m\\n \\u001b[3mitalic\\u001b[23m\\n \\u001b[35mmagenta\\u001b[39m\\n \\u001b[95mmagentaBright\\u001b[39m\\n \\u001b[31mred\\u001b[39m\\n \\u001b[91mredBright\\u001b[39m\\n \\u001b[0mreset\\u001b[0m\\n \\u001b[9mstrikethrough\\u001b[29m\\n \\u001b[4munderline\\u001b[24m\\n \\u001b[37mwhite\\u001b[39m\\n \\u001b[97mwhiteBright\\u001b[39m\\n \\u001b[33myellow\\u001b[39m\\n \\u001b[93myellowBright\\u001b[39m\\n "]"`,
)
})

Expand Down Expand Up @@ -191,7 +191,7 @@ describe('kitql - helper - Log', () => {

expect(result).toMatchInlineSnapshot(`
[
" with no name",
"with no name",
]
`)
})
Expand All @@ -206,7 +206,7 @@ describe('kitql - helper - Log', () => {
expect(spy).toHaveBeenCalledOnce()

expect(stry0(result)).toMatchInlineSnapshot(
'"[\\"\\\\u001b[104m tool name \\\\u001b[49m with red: \\\\u001b[31mred\\\\u001b[39m and another \\\\u001b[31mred2\\\\u001b[39m\\"]"',
`"["\\u001b[104m tool name \\u001b[49m","with red: \\u001b[31mred\\u001b[39m and another \\u001b[31mred2\\u001b[39m"]"`,
)
})
})
74 changes: 50 additions & 24 deletions packages/helpers/src/lib/Log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Log {
this.prefixEmoji = options?.prefixEmoji ?? ''
}

private buildStr(msg: string, withError: boolean, withSuccess: boolean, indent: string) {
private buildStr(withError: boolean, withSuccess: boolean, level: number, ...msgs: any[]) {
const table = []
if (this.toolName) {
const strTool = ` ${this.toolName} `
Expand All @@ -50,44 +50,70 @@ export class Log {

// Status icon or prefixEmoji
if (withError) {
table.push(bold(redBright(' ✘ ')))
table.push(bold(redBright(' ✘')))
} else if (withSuccess) {
table.push(bold(greenBright(' ✔ ')))
table.push(bold(greenBright(' ✔')))
} else {
table.push(String(' ' + this.prefixEmoji))
table.push(String('' + this.prefixEmoji))
}

table.push(indent)
if (level > 0) {
const indent = ' '.repeat(level)
table.push(indent)
}

table.push(String(msg))
if (table.length === 0 || (table.length === 1 && table[0] === '')) {
return colorProcess(...[...msgs.flatMap(c => c)])
}

const str = table.join('')
return colorProcess(...[table.join(''), ...msgs.flatMap(c => c)])
}

return colorProcess(str)
/**
* console.info with options
* @param conf with level of indentation
*/
infoO(conf: { level: number }, ...msgs: any[]) {
const built = this.buildStr(false, false, conf.level, ...msgs)
console.info(...built.flatMap(c => c))
return built
}

info(msg: string, conf?: { level?: number; withSuccess?: boolean }) {
const level = conf?.level ?? 0
const withSuccess = conf?.withSuccess ?? false
/**
* console.info
*/
info(...msgs: any[]) {
const built = this.buildStr(false, false, 0, ...msgs)
console.info(...built.flatMap(c => c))
return built
}

if (this.levelsToShow !== null && level <= this.levelsToShow) {
const indent = ' '.repeat(level)
const built = this.buildStr(msg, false, withSuccess, indent)
console.info(...built)
return built
}
return null
/**
* console.info with options and success icon
* @param conf with level of indentation
*/
successO(conf: { level: number }, ...msgs: any[]) {
const built = this.buildStr(false, true, conf.level, msgs)
console.info(...built.flatMap(c => c))
return built
}

success(msg: string, conf?: { level?: number }) {
const level = conf?.level ?? 0
return this.info(msg, { level, withSuccess: true })
/**
* console.info with success icon
*/
success(...msgs: any[]) {
const built = this.buildStr(false, true, 0, msgs)
console.info(...built.flatMap(c => c))
return built
}

error(msg: string) {
const built = this.buildStr(msg, true, false, '')
/**
* console.error with error icon
*/
error(...msgs: any[]) {
const built = this.buildStr(true, false, 0, msgs)
// Keep error to have the stacktrace in the browser
console.error(...built)
console.error(...built.flatMap(c => c))
return built
}
}
Loading