Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antora/ui-loader

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antora/ui-loader - npm Package Compare versions

Comparing version 3.0.0-beta.2 to 3.0.0-beta.3

2

lib/constants.js

@@ -14,5 +14,5 @@ 'use strict'

nounique: true,
removeBOM: false,
strict: false,
uniqueBy: (m) => m,
},
})
'use strict'
const { compile: bracesToGroup } = require('braces')
const camelCaseKeys = require('camelcase-keys')

@@ -11,13 +12,21 @@ const concat = require('simple-concat')

const getCacheDir = require('cache-directory')
const minimatchAll = require('minimatch-all')
const globStream = require('glob-stream')
const ospath = require('path')
const { posix: path } = ospath
const picomatch = require('picomatch')
const posixify = ospath.sep === '\\' ? (p) => p.replace(/\\/g, '/') : undefined
const { Transform } = require('stream')
const { pipeline, Transform } = require('stream')
const map = (transform, flush = undefined) => new Transform({ objectMode: true, transform, flush })
const UiCatalog = require('./ui-catalog')
const yaml = require('js-yaml')
const vfs = require('vinyl-fs')
const vzip = require('gulp-vinyl-zip')
const STATIC_FILE_MATCHER_OPTS = {
expandRange: (begin, end, step, opts) => bracesToGroup(opts ? `{${begin}..${end}..${step}}` : `{${begin}..${end}}`),
fastpaths: false,
nobracket: true,
noquantifiers: true,
regex: false,
strictSlashes: true,
}
const { UI_CACHE_FOLDER, UI_DESC_FILENAME, UI_SRC_GLOB, UI_SRC_OPTS } = require('./constants')

@@ -98,7 +107,3 @@ const URI_SCHEME_RX = /^https?:\/\//

bundleFile.isDirectory()
? vfs
.src(UI_SRC_GLOB, Object.assign({ cwd: bundleFile.path }, UI_SRC_OPTS))
.on('error', reject)
.pipe(relativizeFiles())
.pipe(collectFiles(resolve))
? srcFs(bundleFile.path).then(resolve, reject)
: vzip

@@ -285,12 +290,3 @@ .src(bundleFile.path)

.access(cwd)
.then(
() =>
new Promise((resolve, reject) =>
vfs
.src(UI_SRC_GLOB, Object.assign({ cwd, dot: true }, UI_SRC_OPTS))
.on('error', reject)
.pipe(relativizeFiles())
.pipe(collectFiles(resolve))
)
)
.then(() => srcFs(cwd))
.catch((err) => {

@@ -303,13 +299,2 @@ // Q: should we skip unreadable files?

function relativizeFiles () {
return map((file, _, next) => {
if (file.isNull()) {
next()
} else {
const path_ = posixify ? posixify(file.relative) : file.relative
next(null, new File({ cwd: file.cwd, path: path_, contents: file.contents, stat: file.stat, local: true }))
}
})
}
function mergeFiles (files, supplementalFiles) {

@@ -325,11 +310,5 @@ if (supplementalFiles.size) supplementalFiles.forEach((file) => files.set(file.path, file))

const config = camelCaseKeys(yaml.load(configFile.contents.toString()), { deep: true })
const staticFiles = config.staticFiles
if (staticFiles && staticFiles.length) config.isStaticFile = picomatch(staticFiles, STATIC_FILE_MATCHER_OPTS)
if (outputDir !== undefined) config.outputDir = outputDir
const staticFiles = config.staticFiles
if (staticFiles) {
if (!Array.isArray(staticFiles)) {
config.staticFiles = [staticFiles]
} else if (staticFiles.length === 0) {
delete config.staticFiles
}
}
return config

@@ -342,3 +321,3 @@ } else {

function classifyFile (file, config) {
if (config.staticFiles && isStaticFile(file, config.staticFiles)) {
if (config.isStaticFile && config.isStaticFile(file.path)) {
file.type = 'static'

@@ -354,6 +333,2 @@ file.out = resolveOut(file, '')

function isStaticFile (file, staticFiles) {
return minimatchAll(file.path, staticFiles)
}
function resolveType (file) {

@@ -374,2 +349,50 @@ const firstPathSegment = file.path.split('/', 1)[0]

function srcFs (cwd) {
return new Promise((resolve, reject, cache = {}, files = new Map()) =>
pipeline(
globStream(UI_SRC_GLOB, Object.assign({ cache, cwd }, UI_SRC_OPTS)),
map(({ path: abspathPosix }, _, next) => {
const abspath = posixify ? ospath.normalize(abspathPosix) : abspathPosix
const relpath = abspath.substr(cwd.length + 1)
symlinkAwareStat(abspath).then(
(stat) => {
if (stat.isDirectory()) return next()
fsp.readFile(abspath).then(
(contents) => {
const path_ = posixify ? posixify(relpath) : relpath
files.set(path_, new File({ cwd, path: path_, contents, stat, local: true }))
next()
},
(readErr) => {
next(Object.assign(readErr, { message: readErr.message.replace(`'${abspath}'`, relpath) }))
}
)
},
(statErr) => {
if (statErr.symlink) {
statErr.message =
statErr.code === 'ELOOP'
? `Symbolic link cycle detected at ${relpath}`
: `Broken symbolic link detected at ${relpath}`
} else {
statErr.message = statErr.message.replace(`'${abspath}'`, relpath)
}
next(statErr)
}
)
}),
(err) => (err ? reject(err) : resolve(files))
)
)
}
function symlinkAwareStat (path_) {
return fsp.lstat(path_).then((lstat) => {
if (!lstat.isSymbolicLink()) return lstat
return fsp.stat(path_).catch((statErr) => {
throw Object.assign(statErr, { symlink: true })
})
})
}
module.exports = loadUi
{
"name": "@antora/ui-loader",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.3",
"description": "Downloads a UI bundle, if necessary, and loads the files into a UI catalog for use in an Antora documentation pipeline.",

@@ -21,2 +21,3 @@ "license": "MPL-2.0",

"@antora/expand-path-helper": "~2.0",
"braces": "~3.0",
"cache-directory": "~2.0",

@@ -27,8 +28,7 @@ "camelcase-keys": "~7.0",

"js-yaml": "~4.1",
"minimatch-all": "~1.1",
"picomatch": "~2.3",
"should-proxy": "~1.0",
"simple-concat": "~1.0",
"simple-get": "~4.0",
"vinyl": "~2.2",
"vinyl-fs": "~3.0"
"vinyl": "~2.2"
},

@@ -50,3 +50,3 @@ "engines": {

],
"gitHead": "5cd3f9cc70622e465cb44daf1aa2035ed5a35f54"
"gitHead": "45da95a2e2dea538379d2d9f42013d2208fb86c3"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc