Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Cleanup #363

Merged
merged 10 commits into from
Oct 12, 2023
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/pink-boxes-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-plugin-watch-and-run': minor
---

add shell option
5 changes: 5 additions & 0 deletions .changeset/red-badgers-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kitql/helper': minor
---

queryStringApprend has been removed
5 changes: 5 additions & 0 deletions .changeset/wicked-mayflies-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kitql/helper': minor
---

colors "logXxxx" has been renamed to "xxx"
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- uses: the-guild-org/shared-config/setup@main
- uses: jycouet/jycouet/shared-config/setup@main
name: setup env
with:
nodeVersion: 18
packageManager: pnpm
# with:
# nodeVersion: 18

- name: 🚧 Build Packages
run: pnpm run build
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,10 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Install Dependencies
run: pnpm i
- uses: jycouet/jycouet/shared-config/setup@main
name: setup env
# with:
# nodeVersion: 18

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
6 changes: 3 additions & 3 deletions packages/all-in/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
},
"devDependencies": {
"@babel/core": "^7.21.8",
"@sveltejs/adapter-auto": "2.0.1",
"@sveltejs/kit": "1.16.3",
"@sveltejs/adapter-auto": "2.1.0",
"@sveltejs/kit": "1.25.2",
"@sveltejs/package": "^2.0.2",
"@types/glob": "8.1.0",
"@typescript-eslint/eslint-plugin": "5.59.5",
Expand All @@ -32,7 +32,7 @@
"graphql": "^16.6.0",
"prettier": "2.8.8",
"prettier-plugin-svelte": "2.10.0",
"svelte-check": "3.3.2",
"svelte-check": "3.5.2",
"svelte-preprocess": "5.0.3",
"tslib": "2.5.0",
"typescript": "5.0.4",
Expand Down
46 changes: 23 additions & 23 deletions packages/all-in/src/lib/vite/generate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Log, logGreen, logRed } from '@kitql/helper'
import { green, Log, red } from '@kitql/helper'
import { basename, extname, join } from 'node:path'

import { actionContext } from './actionContexts.js'
Expand Down Expand Up @@ -65,9 +65,9 @@ export function generate(log: Log, config?: KitQLVite) {
localDev,
)
meta.enums = enumsKeys.length
// log.info(`${logGreen('✔')} ${logGreen('Enums')} created [${enumsKeys.map(c => logGreen(c)).join(',')}]`)
// log.info(`${green('✔')} ${green('Enums')} created [${enumsKeys.map(c => green(c)).join(',')}]`)
} else {
log.error(`file ${logRed(prismaFilePath)} not found!`)
log.error(`file ${red(prismaFilePath)} not found!`)
// throw new Error(`file ${prismaFilePath} not found!`)
}
}
Expand All @@ -84,7 +84,7 @@ export function generate(log: Log, config?: KitQLVite) {
mergeModuleAction.push('Contexts')
}
if (mergeModuleAction.length > 0) {
// log.info(`${logGreen('⏳')} merging ${mergeModuleAction.map(c => logGreen(c)).join(' and ')} in modules`)
// log.info(`${green('⏳')} merging ${mergeModuleAction.map(c => green(c)).join(' and ')} in modules`)
}

const contexts: { moduleName: string; ctxName: string }[] = []
Expand Down Expand Up @@ -129,7 +129,7 @@ export function generate(log: Log, config?: KitQLVite) {
withDbProvider,
)

// log.info(`${logGreen('⏳')} merging ${logGreen('Contexts')}`)
// log.info(`${green('⏳')} merging ${green('Contexts')}`)
providersFiles.forEach(providerFile => {
if (providerFile.startsWith('_ctx')) {
const ctxName = providerFile.replace('_ctx', '').replace('.ts', '')
Expand All @@ -146,9 +146,9 @@ export function generate(log: Log, config?: KitQLVite) {
meta.resolvers += resolversFilesLength
meta.contexts += contextsFilesLength
// log.info(
// `${logGreen('✔')} merged - ${logGreen(pad(typedefsFilesLength, 2))} Typedefs | ${logGreen(
// `${green('✔')} merged - ${green(pad(typedefsFilesLength, 2))} Typedefs | ${green(
// pad(resolversFilesLength, 2)
// )} Resolvers | ${logGreen(pad(contextsFilesLength, 2))} Contexts for [${logGreen(name)}]`
// )} Resolvers | ${green(pad(contextsFilesLength, 2))} Contexts for [${green(name)}]`
// )
}

Expand All @@ -158,12 +158,12 @@ export function generate(log: Log, config?: KitQLVite) {

// mergeContexts
if (mergeContexts) {
// log.info(`${logGreen('⏳')} merging ${logGreen('Contexts')}`)
// log.info(`${green('⏳')} merging ${green('Contexts')}`)
actionContext(contexts, outputFolder)

// log.info(
// `${logGreen('✔')} merged ${logGreen(pad(contexts.length, 2))} contexts [${contexts
// .map(c => logGreen(c.moduleName + '#' + c.ctxName))
// `${green('✔')} merged ${green(pad(contexts.length, 2))} contexts [${contexts
// .map(c => green(c.moduleName + '#' + c.ctxName))
// .join(',')}]`
// )
}
Expand All @@ -172,7 +172,7 @@ export function generate(log: Log, config?: KitQLVite) {
// if (true) {
// mergeModuleContexts
// if (config.actions.mergeContexts) {
// log.info(`${logGreen('⏳')} merging modules ${logGreen('Contexts')}`);
// log.info(`${green('⏳')} merging modules ${green('Contexts')}`);
// const providersFolder = 'providers';
// moduleNames.forEach(moduleName => {
// let dataloadersModule = [];
Expand All @@ -191,10 +191,10 @@ export function generate(log: Log, config?: KitQLVite) {
// config.config.moduleOutputFolder
// );
// log.info(
// `${logGreen('✔')} merged ${logGreen(
// `${green('✔')} merged ${green(
// pad(dataloadersModule.length, 2)
// )} contexts [${dataloadersModule
// .map(c => logGreen(c.moduleName + '#' + c.ctxName))
// .map(c => green(c.moduleName + '#' + c.ctxName))
// .join(',')}]`
// );
// });
Expand All @@ -204,24 +204,24 @@ export function generate(log: Log, config?: KitQLVite) {

// mergeModules
if (mergeModules) {
// log.info(`${logGreen('⏳')} merging ${logGreen('Modules')}`)
// log.info(`${green('⏳')} merging ${green('Modules')}`)
actionModules(modulesObj, outputFolder)
meta.modules = modulesObj.length
// log.info(
// `${logGreen('✔')} merged ${logGreen(pad(modules.length, 2))} modules [${modules
// .map(c => logGreen(c))
// `${green('✔')} merged ${green(pad(modules.length, 2))} modules [${modules
// .map(c => green(c))
// .join(',')}]`
// )
}

// Done
// log.info(`${logGreen('✔')} finished ${logGreen('successfully')}`)
// log.info(`${green('✔')} finished ${green('successfully')}`)
log.info(
`${logGreen('✔')} success ` +
`[${logGreen(String(meta.modules))} modules, ` +
`${logGreen(String(meta.enums))} enums, ` +
`${logGreen(String(meta.typedefs))} typedefs, ` +
`${logGreen(String(meta.resolvers))} resolvers, ` +
`${logGreen(String(meta.contexts))} contexts]`,
`${green('✔')} success ` +
`[${green(String(meta.modules))} modules, ` +
`${green(String(meta.enums))} enums, ` +
`${green(String(meta.typedefs))} typedefs, ` +
`${green(String(meta.resolvers))} resolvers, ` +
`${green(String(meta.contexts))} contexts]`,
)
}
98 changes: 79 additions & 19 deletions packages/helper/src/Log.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,108 @@
const config = {
reset: {
node: `\u001b[37m\u001b[0m`,
node: `\x1b[0m`,
browser: '',
},

// Base
black: {
node: `\x1b[30m`,
browser: 'color: black',
},
red: {
node: `\x1b[31m`,
browser: 'color: red',
},
green: {
node: `\x1b[32m`,
browser: 'color: green',
},
yellow: {
node: `\x1b[33m`,
browser: 'color: yellow',
},
blue: {
node: `\x1b[34m`,
browser: 'color: blue',
},
magneta: {
node: `\x1b[35m`,
browser: 'color: #ff00ff',
},
red: {
node: `\u001B[31m`,
browser: 'color: red',
},
cyan: {
node: `\x1b[36m`,
browser: 'color: cyan',
},
yellow: {
node: `\x1b[33m`,
browser: 'color: yellow',
white: {
node: `\x1b[37m`,
browser: 'color: white',
},
gray: {
node: `\x1b[90m`,
browser: 'color: gray',
},

// Modif
bold: {
node: `\x1b[1m`,
browser: 'font-weight: bold',
},
italic: {
node: `\x1b[3m`,
browser: 'font-style: italic',
},
strikethrough: {
node: `\x1b[9m`,
browser: 'text-decoration: line-through',
},
} as { [key: string]: { node: string; browser: string } }

export function logGreen(str: string) {
export function black(str: string) {
return `${config.black.node}${str}${config.reset.node}`
}

export function red(str: string) {
return `${config.red.node}${str}${config.reset.node}`
}

export function green(str: string) {
return `${config.green.node}${str}${config.reset.node}`
}

export function logMagneta(str: string) {
return `${config.magneta.node}${str}${config.reset.node}`
export function yellow(str: string) {
return `${config.yellow.node}${str}${config.reset.node}`
}

export function logRed(str: string) {
return `${config.red.node}${str}${config.reset.node}`
export function blue(str: string) {
return `${config.blue.node}${str}${config.reset.node}`
}

export function magneta(str: string) {
return `${config.magneta.node}${str}${config.reset.node}`
}

export function logCyan(str: string) {
export function cyan(str: string) {
return `${config.cyan.node}${str}${config.reset.node}`
}

export function logYellow(str: string) {
return `${config.yellow.node}${str}${config.reset.node}`
export function white(str: string) {
return `${config.white.node}${str}${config.reset.node}`
}

export function gray(str: string) {
return `${config.gray.node}${str}${config.reset.node}`
}

export function bold(str: string) {
return `${config.bold.node}${str}${config.reset.node}`
}

export function italic(str: string) {
return `${config.italic.node}${str}${config.reset.node}`
}

export function strikethrough(str: string) {
return `${config.strikethrough.node}${str}${config.reset.node}`
}

export class Log {
Expand Down Expand Up @@ -82,14 +142,14 @@ export class Log {
) {
const table = []
if (this.toolName) {
table.push(String(logMagneta(`[${this.toolName}]`)))
table.push(String(magneta(`[${this.toolName}]`)))
}

// DateTime or Time or nothing
if (this.withDate === 'dateTime') {
table.push(String(logMagneta(`[${new Date().toISOString()}]`)))
table.push(String(magneta(`[${new Date().toISOString()}]`)))
} else if (this.withDate === 'time') {
table.push(String(logMagneta(`[${new Date().toISOString().split('T')[1]}]`)))
table.push(String(magneta(`[${new Date().toISOString().split('T')[1]}]`)))
}

// Status icon or prefixEmoji
Expand Down
5 changes: 5 additions & 0 deletions packages/helper/src/Prettify.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Matt Pocock tips

export type Prettify<T> = {
[K in keyof T]: T[K]
} & {}
19 changes: 17 additions & 2 deletions packages/helper/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
export { Log, logCyan, logGreen, logMagneta, logRed, logYellow } from './Log.js'
export { queryStringApprend } from './queryStringApprend.js'
export {
Log,
black,
blue,
bold,
cyan,
gray,
green,
italic,
magneta,
red,
strikethrough,
white,
yellow,
} from './Log.js'
export { sleep } from './sleep.js'
export { stry, stry0 } from './stry.js'

export type { Prettify } from './Prettify.d.ts'
Loading