Features: - Full RBAC with 3 roles (superadmin/manager/contributor) - Ownership tracking on posts, tasks, campaigns, projects - Task system: assign to anyone, filter combobox, visibility scoping - Team members merged into users table (single source of truth) - Post thumbnails on kanban cards from attachments - Publication link validation before publishing - Interactive onboarding tutorial with Settings restart - Full Arabic/English i18n with RTL layout support - Language toggle in sidebar, IBM Plex Sans Arabic font - Brand-based visibility filtering for non-superadmins - Manager can only create contributors - Profile completion flow for new users - Cookie-based sessions (express-session + SQLite)
40 lines
1009 B
JavaScript
40 lines
1009 B
JavaScript
const { join, sep } = require('path')
|
|
|
|
const getOptions = require('./common/get-options.js')
|
|
const mkdir = require('./mkdir/index.js')
|
|
const mkdtemp = require('./mkdtemp.js')
|
|
const rm = require('./rm/index.js')
|
|
|
|
// create a temp directory, ensure its permissions match its parent, then call
|
|
// the supplied function passing it the path to the directory. clean up after
|
|
// the function finishes, whether it throws or not
|
|
const withTempDir = async (root, fn, opts) => {
|
|
const options = getOptions(opts, {
|
|
copy: ['tmpPrefix'],
|
|
})
|
|
// create the directory, and fix its ownership
|
|
await mkdir(root, { recursive: true, owner: 'inherit' })
|
|
|
|
const target = await mkdtemp(join(`${root}${sep}`, options.tmpPrefix || ''), { owner: 'inherit' })
|
|
let err
|
|
let result
|
|
|
|
try {
|
|
result = await fn(target)
|
|
} catch (_err) {
|
|
err = _err
|
|
}
|
|
|
|
try {
|
|
await rm(target, { force: true, recursive: true })
|
|
} catch (err) {}
|
|
|
|
if (err) {
|
|
throw err
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
module.exports = withTempDir
|