Skip to content

Commit

Permalink
feat(katzencore): Trying to fix windows resolve issues after release …
Browse files Browse the repository at this point in the history
…(test)
  • Loading branch information
maxlkatze committed Jul 24, 2024
1 parent a5b9b44 commit 0682351
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
installModule,
} from '@nuxt/kit'

import pkg from '../package.json'
import { useContentStorage } from './runtime/storage/StorageManagement'
import { updateCheck } from './runtime/update'

export interface CmsUser {
name: string
Expand Down Expand Up @@ -56,11 +56,11 @@ export default defineNuxtModule<ModuleOptions>({
},
async setup(_options, _nuxt) {
updateCheck().then(
(latestVersion) => {
({ currentVersion, latestVersion }) => {
katzeError('There is a new version of Katze available')
console.info('\x1B[43m\x1B[30m Please update your package with \x1B[0m npm i @maxlkatze/cms^' + latestVersion)
console.info('\x1B[43m\x1B[30m If you\'re already on the @latest version run: \x1B[0m npm update')
console.info('\x1B[43m\x1B[30m Current version: ' + pkg.version + ' Latest version: ' + latestVersion + '\x1B[0m')
console.info('\x1B[43m\x1B[30m Current version: ' + currentVersion + ' Latest version: ' + latestVersion + '\x1B[0m')
},
)

Expand Down Expand Up @@ -178,24 +178,6 @@ const installModules = async () => {
],
})
}
const updateCheck = async () => {
const version = pkg.version
const https = await import('node:https')
return new Promise<string>((resolve) => {
https.get('https://registry.npmjs.org/@maxlkatze/cms/latest', (res) => {
let data = ''
res.on('data', (chunk) => {
data += chunk
})
res.on('end', () => {
const latestVersion = JSON.parse(data).version
if (version !== latestVersion) {
resolve(latestVersion)
}
})
})
})
}

const katzeLog = (message: string) => {
console.log('\x1B[42m\x1B[30m Katze \x1B[0m ' + message)
Expand Down
28 changes: 28 additions & 0 deletions src/runtime/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pkg from '../../package.json'

export interface UpdateResult {
currentVersion: string
latestVersion: string
}

export const updateCheck = async () => {
const version = pkg.version
const https = await import('node:https')
return new Promise<UpdateResult>((resolve) => {
https.get('https://registry.npmjs.org/@maxlkatze/cms/latest', (res) => {
let data = ''
res.on('data', (chunk) => {
data += chunk
})
res.on('end', () => {
const latestVersion = JSON.parse(data).version
if (version !== latestVersion) {
resolve({
currentVersion: version,
latestVersion,
})
}
})
})
})
}

0 comments on commit 0682351

Please sign in to comment.