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
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
34 changes: 34 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Prettier Check

on: [pull_request]

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: npm ci

- name: Run Prettier check
run: npm run prettier:check

- name: Annotate Pull Request with Results
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ Prettier found formatting issues. Please fix them.'
})
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scripts
.github
.prettier*
.vscode
.zed
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
"singleQuote": true,
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"printWidth": 120
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
7 changes: 7 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Folder-specific settings
//
// For a full list of overridable settings, and general information on folder-specific settings,
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
{
"format_on_save": "on"
}
115 changes: 0 additions & 115 deletions cli.coffee

This file was deleted.

134 changes: 134 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Federated Wiki : Node Server
*
* Copyright Ward Cunningham and other contributors
* Licensed under the MIT license.
* https://github.com/fedwiki/wiki/blob/master/LICENSE.txt
*/

// **cli.coffee** command line interface for the
// Smallest-Federated-Wiki express server

const http = require('http')
// socketio = require('socket.io')

const path = require('path')
const cluster = require('cluster')

const parseArgs = require('minimist')
const cc = require('config-chain')
const server = require('wiki-server')

const farm = require('./farm')

const getUserHome = () => process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE

// Handle command line options

const opts = {
alias: {
u: 'url',
p: 'port',
d: 'data',
r: 'root',
f: 'farm',
o: 'host',
h: 'help',
conf: 'config',
v: 'version',
},
}

const argv = parseArgs(process.argv.slice(2), opts)

const config = cc(
argv,
argv.config,
'config.json',
path.join(__dirname, '..', 'config.json'),
path.join(getUserHome(), '.wiki', 'config.json'),
cc.env('wiki_'),
{
port: 3000,
root: path.dirname(require.resolve('wiki-server')),
home: 'welcome-visitors',
security_type: './security',
data: path.join(getUserHome(), '.wiki'), // see also defaultargs
packageDir: path.resolve(path.join(__dirname, 'node_modules')),
cookieSecret: require('crypto').randomBytes(64).toString('hex'),
},
).store

if (!config.commons) {
config.commons = path.join(config.data, 'commons')
}

// If h/help is set print the help message and exit.
if (argv.help) {
console.log(`\
Usage: wiki

Options:
--help, -h Show this help info and exit
--config, --conf Optional config file.
--version, -v Show version number and exit\
`)
return
}

// If v/version is set print the version of the wiki components and exit.
if (argv.version) {
const details = require('./package')
console.log('wiki: ' + require('./package').version)
const components = Object.keys(details.dependencies).filter(i => i.startsWith('wiki'))
components.forEach(component => {
console.log(component + ': ' + require(component + '/package').version)
})
return
}

if (argv.test) {
console.log('WARNING: Server started in testing mode, other options ignored')
server({ port: 33333, data: path.join(argv.root, 'spec', 'data') })
return
}

if (cluster.isMaster) {
cluster.on('exit', function (worker, code, signal) {
if (code === 0) {
console.log('restarting wiki server')
cluster.fork()
} else {
console.error('server unexpectly exitted, %d (%s)', worker.process.pid, signal || code)
}
})
cluster.fork()
} else {
if (config.farm) {
console.log('Wiki starting in Farm mode, navigate to a specific server to start it.\n')
if (!argv.wikiDomains && !argv.allowed) {
console.log('WARNING : Starting Wiki Farm in promiscous mode\n')
}
if (argv.security_type === './security') {
if (!argv.security_legacy) {
console.log('INFORMATION : Using default security - Wiki Farm will be read-only\n')
}
}
farm(config)
} else {
const app = server(config)
app.on('owner-set', function (e) {
const local = http.Server(app)
// app.io = socketio(local)

const serv = local.listen(app.startOpts.port, app.startOpts.host)
console.log('Federated Wiki server listening on', app.startOpts.port, 'in mode:', app.settings.env)
if (argv.security_type === './security') {
if (!argv.security_legacy) {
console.log('INFORMATION : Using default security - Wiki will be read-only\n')
}
}
app.emit('running-serv', serv)
})
}
}
52 changes: 0 additions & 52 deletions error-page.coffee

This file was deleted.

Loading