@roots/bud-framework
Advanced tools
Comparing version 2.0.0-next.4 to 2.0.0-next.5
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
exports.__esModule = true; | ||
exports.registerExtensionContainer = exports.registerFileContainer = exports.registerContainer = exports.container = void 0; | ||
var fs_extra_1 = require("fs-extra"); | ||
var logger_1 = require("./util/logger"); | ||
var lodash_1 = require("lodash"); | ||
@@ -29,5 +10,8 @@ var newContainer = function (key, repository) { | ||
}; | ||
var add = function (entry) { | ||
this.repository.push(entry); | ||
var addTo = function (key, item) { | ||
this.repository[key].push(item); | ||
}; | ||
var push = function (item) { | ||
this.repository.push(item); | ||
}; | ||
var get = function (key) { | ||
@@ -40,7 +24,5 @@ return lodash_1.get(this.repository, key); | ||
var containerRequire = function (key) { | ||
var module = this.get(key); | ||
require(module); | ||
require(this.get(key)); | ||
}; | ||
var set = function (key, value) { | ||
logger_1.logger.info({ name: 'container', key: key, value: value }, this.name + ".set"); | ||
lodash_1.set(this.repository, key, value); | ||
@@ -52,5 +34,3 @@ }; | ||
var merge = function (key, value) { | ||
this.repository[key] = this.repository[key] | ||
? __assign(__assign({}, this.repository[key]), value) : this.repository[key] | ||
? __spreadArrays(this.repository[key], value) : [this.repository[key], value]; | ||
lodash_1.merge(this.repository[key], value); | ||
}; | ||
@@ -64,7 +44,5 @@ var containerMethodDelete = function (key) { | ||
var enable = function (key) { | ||
logger_1.logger.info({ name: 'container', key: key, value: true }, this.name + ".enable"); | ||
this.repository[key] = true; | ||
}; | ||
var disable = function (key) { | ||
logger_1.logger.info({ name: 'container', key: key, value: false }, this.name + ".disable"); | ||
this.repository[key] = false; | ||
@@ -94,2 +72,3 @@ }; | ||
this["new"] = newContainer; | ||
this.addTo = addTo; | ||
this.get = get; | ||
@@ -100,2 +79,3 @@ this.has = has; | ||
this.entries = entries; | ||
this.push = push; | ||
this.merge = merge; | ||
@@ -132,3 +112,2 @@ this["delete"] = containerMethodDelete; | ||
var instance = new container(store.register, store.name); | ||
instance.add = add; | ||
return instance; | ||
@@ -135,0 +114,0 @@ }; |
@@ -7,10 +7,6 @@ "use strict"; | ||
registered: {}, | ||
make: function (fn) { | ||
if (fn === void 0) { fn = function () { return null; }; } | ||
return ({ | ||
fn: fn, | ||
value: null, | ||
fired: false | ||
}); | ||
}, | ||
make: function (fn) { return ({ | ||
fn: fn, | ||
fired: false | ||
}); }, | ||
entries: function () { | ||
@@ -20,6 +16,3 @@ return Object.entries(this.registered); | ||
on: function (name, callback) { | ||
this.logger.info({ | ||
name: name, | ||
callback: callback.name | ||
}, 'filter defined'); | ||
this.logger.info({ name: name, callback: callback.name }); | ||
var entry = this.make(callback); | ||
@@ -29,3 +22,5 @@ if (!this.registered[name]) { | ||
} | ||
this.registered[name].push(callback); | ||
else { | ||
this.registered[name].push(entry); | ||
} | ||
return this; | ||
@@ -42,3 +37,2 @@ }, | ||
name: hook.name, | ||
value: value, | ||
fired: true | ||
@@ -45,0 +39,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
declare const notify: (args: any) => any; | ||
declare const notify: (args: any) => import("node-notifier/notifiers/notificationcenter"); | ||
export { notify }; | ||
//# sourceMappingURL=notify.d.ts.map |
{ | ||
"name": "@roots/bud-framework", | ||
"description": "Bud's backing framework", | ||
"version": "2.0.0-next.4", | ||
"version": "2.0.0-next.5", | ||
"homepage": "https://roots.io/bud", | ||
@@ -26,4 +26,3 @@ "repository": { | ||
"files": [ | ||
"lib", | ||
"types" | ||
"lib" | ||
], | ||
@@ -47,3 +46,3 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@roots/bud-support": "^2.0.0-next.4", | ||
"@roots/bud-support": "^2.0.0-next.5", | ||
"@types/dotenv": "^8.2.0", | ||
@@ -57,3 +56,4 @@ "@types/eslint": "^7.2.0", | ||
"@types/yargs": "^15.0.5" | ||
} | ||
}, | ||
"gitHead": "0bf5eba9aeaa20148af7cd6b0ac6f8f36991aebc" | ||
} |
@@ -13,3 +13,3 @@ <p align="center"> | ||
<h1 align="center"> | ||
<strong>@roots/bud</strong> | ||
<strong>@roots/bud-framework</strong> | ||
</h1> | ||
@@ -19,50 +19,46 @@ | ||
A webpack framework combining the best parts of Laravel Mix and Symfony Encore. | ||
This is the core framework leveraged by @roots/bud. You may find it useful in other projects. It's kind of a bootstrap-y laravel/adonis style container-based framework. | ||
## Installation | ||
`yarn add @roots/bud --dev` | ||
`yarn add @roots/bud-framework` | ||
## Plugins | ||
## Some things you can do with it | ||
### Usage | ||
Attach things to it. | ||
Import plugins at the top of your `bud.config.js` file | ||
```js | ||
import {framework} from '@roots/bud-framework' | ||
```js | ||
const {eslint} = require('@roots/bud-eslint') | ||
framework.apply('method', () => console.log('attach a method to it')) | ||
const instance = new framework | ||
instance.method() // => 'attach a method to it' | ||
``` | ||
Then, utilize the `bud.use` method and register the plugin. Plugins will be called in the provided order. | ||
Log stuff. | ||
```js | ||
bud.use([eslint]) | ||
instance.logger.info({data: 100}, 'Logged message') | ||
``` | ||
Some plugins may provide additional configuration methods. Obviously, you can't call a plugin-provided method without first registering that plugin, which is one of the reasons it's generally a good idea to import and register everything at the top of your config. | ||
Create containers for storing, accessing and manipulating stuff. | ||
```js | ||
bud | ||
.use([dependencyExtraction]) | ||
.dependencyExtraction({ | ||
injectPolyfill: true, | ||
}) | ||
``` | ||
instance.bind('things', { | ||
some: { | ||
thing: 100, | ||
}, | ||
}) | ||
### First-party plugins | ||
instance.things.get('some.thing') | ||
// => 100 | ||
There are a number of Roots maintained plugins available to kickstart your projects. | ||
instance.things.set('some.thang', 200) | ||
instance.things.get('some') | ||
// => {some: {thing: 100, thang: 200}} | ||
``` | ||
| Name | Description | Usage | | ||
|------|-------------|-------| | ||
| @roots/bud-dependency-extraction | Adds @wordpress/dependency-extraction-webpack-plugin support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-dependency-extraction/README.md) | ||
| @roots/bud-eslint | Adds eslint support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-eslint/README.md) | | ||
| @roots/bud-palette-plugin | Adds palette-webpack-plugin support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-palette-plugin/README.md) | | ||
| @roots/bud-purgecss | Adds purgecss support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-purgecss/README.md) | | ||
| @roots/bud-react | Adds react support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-react/README.md) | | ||
| @roots/bud-sass | Adds sass preprocessor support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-sass/README.md) | | ||
| @roots/bud-stylelint | Adds stylelint support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-stylelint/README.md) | | ||
| @roots/bud-tailwind | Adds tailwindcss support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-tailwindcss/README.md) | | ||
| @roots/bud-typescript | Adds typescript support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-typescript/README.md) | | ||
| @roots/bud-vue | Adds Vue framework support. | [Usage ↗](https://github.com/roots/bud-support/blob/%40roots/bud/packages/bud-vue/README.md) | | ||
It definitely does other helpful stuff. As this is a lower-level utility it is largely undocumented, at the moment.. | ||
@@ -69,0 +65,0 @@ ## Contributing |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
43358
71
610
82