GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — :construction: better terminal logs · nullstack/nullstack@c90ce81

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • builders
    • logger.js
    • spa.js
    • ssg.js
    • ssr.js
  • scripts
    • index.js
  • server
    • hmr.js
    • server.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎builders/logger.js‎

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
const clocks = ['🕛', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚']
3+
4+
function logger(bundle, mode) {
5+
let cindex = 0
6+
let timer = null
7+
let stoped = false
8+
9+
function dots() {
10+
return Array((cindex % 3) + 1).fill('.').join('')
11+
}
12+
13+
function reset() {
14+
if (process.stdout.clearLine) {
15+
process.stdout.clearLine()
16+
process.stdout.cursorTo(0)
17+
}
18+
}
19+
20+
function start() {
21+
reset()
22+
if (cindex >= clocks.length) {
23+
cindex = 0
24+
}
25+
let symbol = clocks[cindex]
26+
process.stdout.write(` ${symbol} Building your ${bundle} in ${mode} mode ${dots()}`)
27+
cindex++;
28+
timer = setTimeout(start, 200)
29+
}
30+
start()
31+
32+
function stop() {
33+
if (stoped) return
34+
clearTimeout(timer)
35+
reset()
36+
process.stdout.write(` ✅ Starting your ${bundle} in ${mode} mode\n`)
37+
stoped = true
38+
}
39+
40+
return { stop }
41+
}
42+
43+
module.exports = logger
Collapse file

‎builders/spa.js‎

Copy file name to clipboardExpand all lines: builders/spa.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = async function spa({ output, cache, environment }) {
3434
await copy('/robots.txt')
3535
console.info()
3636

37-
console.info('\x1b[36m%s\x1b[0m', ` ✅️ ${projectName} is ready at ${folder}\n`)
37+
console.info('\x1b[36m%s\x1b[0m', ` 🚀 ${projectName} is ready at ${folder}\n`)
3838

3939
if (cache) {
4040
console.info('Storing cache...')
Collapse file

‎builders/ssg.js‎

Copy file name to clipboardExpand all lines: builders/ssg.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ module.exports = async function ssg({ output, cache, environment }) {
7979
const urls = Object.keys(pages).map((p) => {
8080
const page = pages[p]
8181
const canonical = `https://${application.project.domain}${p}`
82-
return `<url><loc>${canonical}</loc><lastmod>${timestamp}</lastmod>${
83-
page.changes ? `<changefreq>${page.changes}</changefreq>` : ''
84-
}${page.priority ? `<priority>${page.priority.toFixed(1)}</priority>` : ''}</url>`
82+
return `<url><loc>${canonical}</loc><lastmod>${timestamp}</lastmod>${page.changes ? `<changefreq>${page.changes}</changefreq>` : ''
83+
}${page.priority ? `<priority>${page.priority.toFixed(1)}</priority>` : ''}</url>`
8584
})
8685
const xml = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${urls.join(
8786
'',
@@ -111,7 +110,7 @@ module.exports = async function ssg({ output, cache, environment }) {
111110
await createSitemap()
112111
console.info()
113112

114-
console.info('\x1b[36m%s\x1b[0m', ` ✅️ ${projectName} is ready at ${folder}\n`)
113+
console.info('\x1b[36m%s\x1b[0m', ` 🚀 ${projectName} is ready at ${folder}\n`)
115114

116115
if (cache) {
117116
console.info('Storing cache...')
Collapse file

‎builders/ssr.js‎

Copy file name to clipboardExpand all lines: builders/ssr.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = async function ssr({ cache }) {
33
const application = require(`${dir}/.production/server`).default
44
const projectName = application.project.name || 'The Nullstack application'
55

6-
console.info('\x1b[36m%s\x1b[0m', `\n ✅️ ${projectName} is ready for production\n`)
6+
console.info('\x1b[36m%s\x1b[0m', `\n 🚀 ${projectName} is ready for production\n`)
77

88
if (cache) {
99
console.info('Storing cache...')
Collapse file

‎scripts/index.js‎

Copy file name to clipboardExpand all lines: scripts/index.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ function clearDir() {
3838
}
3939

4040
async function start({ port, name, disk, skipCache, trace }) {
41+
process.env.__NULLSTACK_TRACE = (!!trace).toString()
42+
const progress = require('../builders/logger')('server', 'development')
4143
loadEnv(name)
42-
console.info(` 🚀️ Building your application in development mode...`)
4344
const environment = 'development'
4445
process.env.NULLSTACK_ENVIRONMENT_MODE = 'spa'
4546
process.env.NULLSTACK_ENVIRONMENT_DISK = (!!disk).toString()
46-
process.env.__NULLSTACK_TRACE = (!!trace).toString()
4747
process.env.__NULLSTACK_CLI_ENVIRONMENT = environment
4848
if (name) {
4949
process.env.NULLSTACK_ENVIRONMENT_NAME = name
@@ -57,6 +57,7 @@ async function start({ port, name, disk, skipCache, trace }) {
5757
const compiler = webpack(settings)
5858
clearDir()
5959
compiler.watch({ aggregateTimeout: 200, hot: true, ignored: /node_modules/ }, (error, stats) => {
60+
progress.stop()
6061
if (error) {
6162
console.error(error.stack || error)
6263
if (error.details) {
@@ -70,11 +71,11 @@ async function start({ port, name, disk, skipCache, trace }) {
7071

7172
function build({ mode = 'ssr', output, name, skipCache }) {
7273
const environment = 'production'
74+
const progress = require('../builders/logger')('application', environment)
7375
const compiler = getCompiler({ environment, skipCache, name })
7476
if (name) {
7577
process.env.NULLSTACK_ENVIRONMENT_NAME = name
7678
}
77-
console.info(` 🚀️ Building your application in ${mode} mode...`)
7879
compiler.run((error, stats) => {
7980
if (error) {
8081
console.error(error.stack || error)
@@ -86,6 +87,7 @@ function build({ mode = 'ssr', output, name, skipCache }) {
8687
process.exit(1)
8788
}
8889
if (stats.hasErrors()) process.exit(1)
90+
progress.stop()
8991
require(`../builders/${mode}`)({ output, environment })
9092
})
9193
}
Collapse file

‎server/hmr.js‎

Copy file name to clipboardExpand all lines: server/hmr.js
+6-16Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable nullstack/no-undef */
22
import { existsSync, open } from 'fs'
33
import path from 'path'
4+
import logger from '../builders/logger'
45

56
function waitCompiler(next) {
67
open(path.join(__dirname, '.compiling'), (error, exists) => {
@@ -15,6 +16,8 @@ function waitCompiler(next) {
1516
}
1617

1718
export default function hmr(server) {
19+
const progress = logger('client', 'development')
20+
1821
if (module.hot) {
1922
const customConfig = path.resolve(process.cwd(), 'webpack.config.js')
2023
const webpackConfigs = existsSync(customConfig)
@@ -45,30 +48,17 @@ export default function hmr(server) {
4548
writeToDisk: disk,
4649
}
4750

48-
server.use(async (request, _response, next) => {
49-
if (
50-
request.originalUrl.indexOf('/nullstack/hmr') === -1 &&
51-
request.originalUrl.indexOf('/nullstack-client-update') === -1 &&
52-
request.originalUrl.indexOf('/nullstack-server-update') === -1 &&
53-
(request.originalUrl.split('?')[0].indexOf('.json') > -1 ||
54-
request.originalUrl.split('?')[0].indexOf('.') === -1)
55-
) {
56-
if (request.originalUrl.startsWith('/nullstack/')) {
57-
console.info(` ⚙️ [${request.method}] ${request.originalUrl}`)
58-
} else {
59-
console.info(` 🕸️ [${request.method}] ${request.originalUrl}`)
60-
}
61-
}
51+
server.use(async (_request, _response, next) => {
6252
waitCompiler(next)
6353
})
6454

6555
const instance = webpackDevMiddleware(compiler, webpackDevMiddlewareOptions)
6656

6757
instance.waitUntilValid(() => {
58+
progress.stop()
6859
console.info(
6960
'\x1b[36m%s\x1b[0m',
70-
` ✅️ Your application is ready at http://${process.env.NULLSTACK_PROJECT_DOMAIN}:${process.env.NULLSTACK_SERVER_PORT || process.env.PORT || 3000
71-
}\n`,
61+
`\n 🚀 Your application is ready at http://${process.env.NULLSTACK_PROJECT_DOMAIN}:${process.env.NULLSTACK_SERVER_PORT || process.env.PORT || 3000}\n`,
7262
)
7363
})
7464

Collapse file

‎server/server.js‎

Copy file name to clipboardExpand all lines: server/server.js
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,18 @@ server.start = function () {
152152
}
153153
})
154154

155-
if (environment.development) {
155+
if (module.hot) {
156156
server.all(`/${prefix}/:version/:hash/:methodName.json`, async (request, response) => {
157157
const payload = request.method === 'GET' ? request.query.payload : request.body
158158
reqres.set(request, response)
159159
const args = deserialize(payload)
160160
const { version, hash, methodName } = request.params
161161
const [invokerHash, boundHash] = hash.split('-')
162+
let [filePath, klassName] = (invokerHash || boundHash).split("___")
163+
const file = path.resolve('..', filePath.replaceAll('__', '/'))
164+
console.info('\x1b[1;37m%s\x1b[0m', ` [${request.method}] ${request.path}`)
165+
console.info('\x1b[2;37m%s\x1b[0m', ` - ${file}`)
166+
console.info('\x1b[2;37m%s\x1b[0m', ` - ${klassName}.${methodName}(${JSON.stringify(args)})\n`)
162167
const key = `${invokerHash}.${methodName}`
163168
let invokerKlass;
164169
await load(boundHash || invokerHash)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.