-
Notifications
You must be signed in to change notification settings - Fork 39
Decaffeinate (ESM conversion) #197
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,19 @@ | |
| // **defaultargs.coffee** when called on the argv object this | ||
| // module will create reasonable defaults for options not supplied, | ||
| // based on what information is provided. | ||
| const path = require('node:path') | ||
| import path from 'node:path' | ||
| import { randomBytes } from 'node:crypto' | ||
| import { fileURLToPath } from 'node:url' | ||
| import { dirname } from 'node:path' | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url) | ||
| const __dirname = dirname(__filename) | ||
|
|
||
| const getUserHome = () => { | ||
| return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE | ||
| } | ||
|
|
||
| module.exports = argv => { | ||
| export default argv => { | ||
| argv = argv || {} | ||
| argv.root ||= __dirname | ||
| // the directory that contains all the packages that makeup the wiki | ||
|
|
@@ -32,7 +38,7 @@ module.exports = argv => { | |
| argv.url ||= `http://localhost${argv.port === 80 ? '' : ':' + argv.port}` | ||
| argv.id ||= path.join(argv.status, 'owner.json') | ||
| argv.uploadLimit ||= '5mb' | ||
| argv.cookieSecret ||= require('crypto').randomBytes(64).toString('hex') | ||
| argv.cookieSecret ||= randomBytes(64).toString('hex') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for moving the inline require() to an import() above. |
||
| argv.secure_cookie ||= false | ||
| argv.session_duration ||= 7 | ||
| argv.neighbors ||= '' | ||
|
|
@@ -43,18 +49,18 @@ module.exports = argv => { | |
| argv.database = JSON.parse(argv.database) | ||
| } | ||
| argv.database ||= {} | ||
| argv.database.type ||= './page' | ||
| argv.database.type ||= './page.js' | ||
| if (argv.database.type.charAt(0) === '.') { | ||
| if (argv.database.type != './page') { | ||
| if (argv.database.type != './page.js') { | ||
| console.log('\n\nWARNING: This storage option is depeciated.') | ||
| console.log(' See ReadMe for details of the changes required.\n\n') | ||
| } | ||
| } else { | ||
| argv.database.type = 'wiki-storage-' + argv.database.type | ||
| } | ||
|
|
||
| argv.security_type ||= './security' | ||
| if (argv.security_type === './security') { | ||
| argv.security_type ||= './security.js' | ||
| if (argv.security_type === './security.js') { | ||
| console.log('\n\nINFORMATION: Using default security module.') | ||
| } else { | ||
| argv.security_type = 'wiki-security-' + argv.security_type | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,15 +10,25 @@ | |
| // Everything is stored using json flat files. | ||
|
|
||
| // #### Requires #### | ||
| const fs = require('fs') | ||
| const path = require('path') | ||
| const events = require('events') | ||
| const glob = require('glob') | ||
|
|
||
| const async = require('async') | ||
|
|
||
| const random_id = require('./random_id') | ||
| const synopsis = require('wiki-client/lib/synopsis') | ||
| // const fs = require('fs') | ||
| // const path = require('path') | ||
| // const events = require('events') | ||
| // const glob = require('glob') | ||
| // | ||
| // const async = require('async') | ||
| // | ||
| // // const random_id = require('./random_id.cjs') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are several unused imports throughout the files. As far as I can tell, random_id is not used in pages. |
||
| // const synopsis = require('wiki-client/lib/synopsis') | ||
|
|
||
| import fs from 'node:fs' | ||
| import path from 'node:path' | ||
| import events from 'node:events' | ||
| import glob from 'glob' | ||
|
|
||
| import async from 'async' | ||
|
|
||
| // import random_id from './random_id.cjs'; // Uncomment if needed | ||
| import synopsis from 'wiki-client/lib/synopsis.js' // Add correct extension if necessary | ||
|
|
||
| const asSlug = name => | ||
| name | ||
|
|
@@ -28,7 +38,7 @@ const asSlug = name => | |
|
|
||
| // Export a function that generates a page handler | ||
| // when called with options object. | ||
| module.exports = exports = argv => { | ||
| export default argv => { | ||
| const wikiName = new URL(argv.url).hostname | ||
|
|
||
| fs.mkdir(argv.db, { recursive: true }, e => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can line 12 and line 15 be combined, since both are coming from
node:path?Maybe this would work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure. I still consider this an exploratory branch rather than something I'd offer to merge right now. Many things like this to tidy up. Thank you for looking it over and commenting.