bajo 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { isEmpty } from 'lodash-es'
|
|
1
|
+
import { isEmpty, find } from 'lodash-es'
|
|
2
2
|
|
|
3
|
-
function breakNsPath (item = '') {
|
|
4
|
-
const { error
|
|
3
|
+
function breakNsPath (item = '', defaultNs = 'bajo') {
|
|
4
|
+
const { error } = this.bajo.helper
|
|
5
5
|
let [ns, ...path] = item.split(':')
|
|
6
6
|
path = path.join(':')
|
|
7
7
|
if (isEmpty(path)) {
|
|
8
8
|
path = ns
|
|
9
|
-
ns =
|
|
9
|
+
ns = defaultNs
|
|
10
|
+
}
|
|
11
|
+
if (ns.length === 1) return [ns, path].join(':') // windows fs
|
|
12
|
+
if (!this[ns]) {
|
|
13
|
+
const ref = find(this.bajo.pluginRefs ?? [], { alias: ns })
|
|
14
|
+
if (ref) ns = ref.plugin
|
|
10
15
|
}
|
|
11
|
-
// if (path.startsWith('.')) throw error('Path \'%s\' must be an absolute path', path)
|
|
12
|
-
if (!this[ns]) ns = (getPlugin(ns) || {}).name
|
|
13
16
|
if (!this[ns]) throw error('Unknown plugin \'%s\' or plugin isn\'t loaded yet', ns)
|
|
14
17
|
return [ns, path]
|
|
15
18
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { get } from 'lodash-es'
|
|
2
|
+
import breakNsPath from './break-ns-path.js'
|
|
2
3
|
|
|
3
4
|
function getPluginFile (file) {
|
|
5
|
+
if (!get(this, 'bajo.helper')) return file
|
|
4
6
|
if (file.includes(':')) {
|
|
5
|
-
const [plugin, path] =
|
|
7
|
+
const [plugin, path] = breakNsPath.call(this, file)
|
|
6
8
|
if (plugin !== 'file' && this && this[plugin] && plugin.length > 1) {
|
|
7
9
|
const dir = get(this[plugin], 'config.dir.pkg')
|
|
8
10
|
file = `${dir}${path}`
|
|
@@ -4,6 +4,7 @@ import getModuleDir from './get-module-dir.js'
|
|
|
4
4
|
import resolvePath from './resolve-path.js'
|
|
5
5
|
import readJson from './read-json.js'
|
|
6
6
|
import defaultsDeep from './defaults-deep.js'
|
|
7
|
+
import breakNsPath from './break-ns-path.js'
|
|
7
8
|
import path from 'path'
|
|
8
9
|
import fs from 'fs-extra'
|
|
9
10
|
|
|
@@ -14,11 +15,7 @@ async function importPkg (...pkgs) {
|
|
|
14
15
|
opts = defaultsDeep(pkgs.pop(), opts)
|
|
15
16
|
}
|
|
16
17
|
for (const pkg of pkgs) {
|
|
17
|
-
|
|
18
|
-
if (!name) {
|
|
19
|
-
name = plugin
|
|
20
|
-
plugin = 'bajo'
|
|
21
|
-
}
|
|
18
|
+
const [plugin, name] = breakNsPath.call(this, pkg)
|
|
22
19
|
const dir = getModuleDir.call(this, name, plugin)
|
|
23
20
|
const p = readJson(`${dir}/package.json`, opts.thrownNotFound)
|
|
24
21
|
const mainFileOrg = dir + '/' + (p.main ?? get(p, 'exports.default', 'index.js'))
|
package/boot/lib/shim.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// taken from: https://vanillajstoolkit.com/polyfills/stringreplaceall/
|
|
2
|
-
|
|
3
1
|
function shim () {
|
|
2
|
+
// taken from: https://vanillajstoolkit.com/polyfills/stringreplaceall/
|
|
4
3
|
if (!String.prototype.replaceAll) {
|
|
5
|
-
String.prototype.replaceAll = function(str, newStr){
|
|
4
|
+
String.prototype.replaceAll = function(str, newStr) { // eslint-disable-line
|
|
6
5
|
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
|
|
7
6
|
return this.replace(str, newStr)
|
|
8
7
|
}
|