@frontity/file-settings
Advanced tools
Comparing version 1.1.5 to 1.1.6
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
## 1.1.6 | ||
### Patch Changes | ||
- [`b6ada1cc`](https://github.com/frontity/frontity/commit/b6ada1cc7075d32a9ef82d525e251e1554baaba3) [#465](https://github.com/frontity/frontity/pull/465) Thanks [@juanmaguitar](https://github.com/juanmaguitar)! - README.md with more detailed info of the package. | ||
## [1.1.5](https://github.com/frontity/frontity/compare/@frontity/file-settings@1.1.4...@frontity/file-settings@1.1.5) (2019-11-04) | ||
@@ -10,17 +13,8 @@ | ||
## [1.1.4](https://github.com/frontity/frontity/compare/@frontity/file-settings@1.1.3...@frontity/file-settings@1.1.4) (2019-10-02) | ||
### Bug Fixes | ||
* **typescript:** update to latest version ([a89b11c](https://github.com/frontity/frontity/commit/a89b11c)) | ||
- **typescript:** update to latest version ([a89b11c](https://github.com/frontity/frontity/commit/a89b11c)) | ||
## [1.1.3](https://github.com/frontity/frontity/compare/@frontity/file-settings@1.1.2...@frontity/file-settings@1.1.3) (2019-09-10) | ||
@@ -30,6 +24,2 @@ | ||
## [1.1.2](https://github.com/frontity/frontity/compare/@frontity/file-settings@1.1.1...@frontity/file-settings@1.1.2) (2019-08-12) | ||
@@ -39,6 +29,2 @@ | ||
## [1.1.1](https://github.com/frontity/frontity/compare/@frontity/file-settings@1.1.0...@frontity/file-settings@1.1.1) (2019-07-12) | ||
@@ -48,49 +34,28 @@ | ||
# [1.1.0](https://github.com/frontity/frontity/compare/@frontity/file-settings@1.0.0...@frontity/file-settings@1.1.0) (2019-06-19) | ||
### Features | ||
* **packages:** creates packages @frontity/components, @frontity/hooks, and adds image processor to @frontity/html2react ([#130](https://github.com/frontity/frontity/issues/130)) ([6af4aa1](https://github.com/frontity/frontity/commit/6af4aa1)) | ||
- **packages:** creates packages @frontity/components, @frontity/hooks, and adds image processor to @frontity/html2react ([#130](https://github.com/frontity/frontity/issues/130)) ([6af4aa1](https://github.com/frontity/frontity/commit/6af4aa1)) | ||
# [1.0.0](https://github.com/frontity/frontity/compare/@frontity/file-settings@0.3.0...@frontity/file-settings@1.0.0) (2019-06-05) | ||
### Bug Fixes | ||
* **all:** update typscript and fix some keywords ([1fe5fec](https://github.com/frontity/frontity/commit/1fe5fec)) | ||
- **all:** update typscript and fix some keywords ([1fe5fec](https://github.com/frontity/frontity/commit/1fe5fec)) | ||
### Features | ||
* add some keywords ([9267faa](https://github.com/frontity/frontity/commit/9267faa)) | ||
- add some keywords ([9267faa](https://github.com/frontity/frontity/commit/9267faa)) | ||
### BREAKING CHANGES | ||
* get this packages to 1.0.0 | ||
- get this packages to 1.0.0 | ||
# [0.3.0](https://github.com/frontity/frontity/compare/@frontity/file-settings@0.2.2...@frontity/file-settings@0.3.0) (2019-06-05) | ||
### Features | ||
* **core:** refactor entry-points for new modes and files ([#98](https://github.com/frontity/frontity/issues/98)) ([1713522](https://github.com/frontity/frontity/commit/1713522)) | ||
- **core:** refactor entry-points for new modes and files ([#98](https://github.com/frontity/frontity/issues/98)) ([1713522](https://github.com/frontity/frontity/commit/1713522)) | ||
## [0.2.2](https://github.com/frontity/frontity/compare/@frontity/file-settings@0.2.1...@frontity/file-settings@0.2.2) (2019-05-15) | ||
@@ -100,6 +65,2 @@ | ||
## [0.2.1](https://github.com/frontity/frontity/compare/@frontity/file-settings@0.2.0...@frontity/file-settings@0.2.1) (2019-05-15) | ||
@@ -109,22 +70,12 @@ | ||
# [0.2.0](https://github.com/frontity/frontity/compare/@frontity/file-settings@0.1.0...@frontity/file-settings@0.2.0) (2019-05-15) | ||
### Features | ||
* **frontity:** use the frontity package as interface for the core packages ([#48](https://github.com/frontity/frontity/issues/48)) ([429e795](https://github.com/frontity/frontity/commit/429e795)) | ||
- **frontity:** use the frontity package as interface for the core packages ([#48](https://github.com/frontity/frontity/issues/48)) ([429e795](https://github.com/frontity/frontity/commit/429e795)) | ||
# 0.1.0 (2019-03-27) | ||
### Features | ||
* **all:** create `file-settings` package ([a6b196a](https://github.com/frontity/frontity/commit/a6b196a)) | ||
- **all:** create `file-settings` package ([a6b196a](https://github.com/frontity/frontity/commit/a6b196a)) |
@@ -14,4 +14,4 @@ "use strict"; | ||
mode, | ||
packages: packages.filter(pkg => pkg.active).map(pkg => pkg.name) | ||
packages: packages.filter((pkg) => pkg.active).map((pkg) => pkg.name), | ||
})); | ||
}; |
@@ -19,3 +19,3 @@ "use strict"; | ||
if (name) { | ||
const settings = allSettings.find(s => s.name === name); | ||
const settings = allSettings.find((s) => s.name === name); | ||
if (settings) | ||
@@ -36,3 +36,3 @@ return settings; | ||
// Filter them to get only the ones that match the `url` | ||
.filter(match => new RegExp(match).test(url)) | ||
.filter((match) => new RegExp(match).test(url)) | ||
// Sort them by length and pick the longest one. | ||
@@ -42,6 +42,6 @@ .sort((a, b) => b.length - a.length)[0]; | ||
if (validMatch) | ||
return allSettings.find(settings => settings.match && settings.match.includes(validMatch)); | ||
return allSettings.find((settings) => settings.match && settings.match.includes(validMatch)); | ||
// 4. Return the first settings without a match defined or, | ||
// if all of them have match, the first settings in the array. | ||
return allSettings.filter(settings => !settings.match)[0] || allSettings[0]; | ||
return allSettings.filter((settings) => !settings.match)[0] || allSettings[0]; | ||
}; |
@@ -16,5 +16,4 @@ "use strict"; | ||
exports.default = async () => { | ||
const { default: settings } = await Promise.resolve().then(() => __importStar(require(process.env.CWD + | ||
"/frontity.settings"))); | ||
const { default: settings } = await Promise.resolve().then(() => __importStar(require(process.env.CWD + "/frontity.settings"))); | ||
return normalizeSettings_1.default(settings); | ||
}; |
@@ -22,7 +22,7 @@ "use strict"; | ||
mode: "default", | ||
state: {} | ||
state: {}, | ||
}; | ||
const defaultPackage = { | ||
active: true, | ||
state: {} | ||
state: {}, | ||
}; | ||
@@ -32,3 +32,3 @@ // This function merges the imported settings with the default settings. | ||
var { packages } = _a, settings = __rest(_a, ["packages"]); | ||
return (Object.assign(Object.assign({}, mergeDeepRight_1.default(defaultSettings, settings)), { packages: packages.map(pkg => typeof pkg === "string" | ||
return (Object.assign(Object.assign({}, mergeDeepRight_1.default(defaultSettings, settings)), { packages: packages.map((pkg) => typeof pkg === "string" | ||
? Object.assign(Object.assign({}, defaultPackage), { name: pkg }) : Object.assign(Object.assign({}, defaultPackage), pkg)) })); | ||
@@ -47,4 +47,4 @@ }; | ||
// Merge multi settings. | ||
return settings.map(s => mergeSettings(s)); | ||
return settings.map((s) => mergeSettings(s)); | ||
}; | ||
exports.default = normalizeSettings; |
@@ -12,4 +12,4 @@ "use strict"; | ||
const uniquePackages = uniq_1.default(packages | ||
.map(pkg => (typeof pkg === "string" ? pkg : pkg.name)) | ||
.filter(pkg => pkg)); | ||
.map((pkg) => (typeof pkg === "string" ? pkg : pkg.name)) | ||
.filter((pkg) => pkg)); | ||
if (uniquePackages.length < packages.length) { | ||
@@ -27,5 +27,5 @@ throw new Error("All the packages must have a unique name."); | ||
// Validate packages in multi settings. | ||
settings.forEach(s => validatePackages(s.packages)); | ||
settings.forEach((s) => validatePackages(s.packages)); | ||
// Check that every multi settings has a unique name. | ||
const uniqueNames = uniqBy_1.default(s => s.name, settings.filter(s => s.name)); | ||
const uniqueNames = uniqBy_1.default((s) => s.name, settings.filter((s) => s.name)); | ||
if (uniqueNames.length < settings.length) { | ||
@@ -32,0 +32,0 @@ throw new Error("All the settings must have a unique name."); |
@@ -1,6 +0,2 @@ | ||
module.exports = { | ||
transform: { "^.+\\.tsx?$": "ts-jest" }, | ||
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx"], | ||
testPathIgnorePatterns: ["/mocks/"] | ||
}; | ||
const rootConfig = require("../../jest.config.js"); | ||
module.exports = rootConfig; |
{ | ||
"name": "@frontity/file-settings", | ||
"version": "1.1.5", | ||
"description": "file settings package", | ||
"author": "Eduardo Campaรฑa <asrielo@gmail.com>", | ||
"version": "1.1.6", | ||
"description": "A settings package for Frontity that uses a frontity.settings.js file.", | ||
"homepage": "https://github.com/frontity/frontity", | ||
@@ -18,5 +17,2 @@ "license": "Apache-2.0", | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bugs": { | ||
@@ -26,5 +22,5 @@ "url": "https://github.com/frontity/frontity/issues" | ||
"scripts": { | ||
"test:ci": "jest", | ||
"test": "jest --watch", | ||
"test:inspect": "node --inspect ./node_modules/.bin/jest --watch --no-cache --runInBand", | ||
"test:ci": "../../node_modules/.bin/jest --ci --coverage", | ||
"test": "../../node_modules/.bin/jest --watch", | ||
"test:inspect": "node --inspect ../../node_modules/.bin/jest --watch --no-cache --runInBand", | ||
"build": "tsc --project ./tsconfig.build.json", | ||
@@ -37,10 +33,5 @@ "prepublish": "npm run build" | ||
"devDependencies": { | ||
"@frontity/types": "^1.1.2", | ||
"@types/jest": "^24.0.11", | ||
"@types/ramda": "^0.26.33", | ||
"jest": "^24.7.1", | ||
"ts-jest": "^24.0.2", | ||
"typescript": "^3.6.3" | ||
}, | ||
"gitHead": "89495b5f376c00114cc67ab666bbcc7104dadd6c" | ||
"@frontity/types": "^1.4.1", | ||
"@types/ramda": "0.26.33" | ||
} | ||
} |
144
README.md
@@ -1,135 +0,57 @@ | ||
# File Settings | ||
# `@frontity/file-settings` | ||
### _This is an internal package used by @frontity/core._ | ||
[![Version](https://img.shields.io/npm/v/@frontity/file-settings.svg)](https://www.npmjs.com/package/@frontity/file-settings) [![npm](https://img.shields.io/npm/dw/@frontity/file-settings)](https://www.npmjs.com/package/@frontity/file-settings) [![License: Apache--2.0](https://img.shields.io/badge/license-Apache%202-lightgrey)](https://github.com/frontity/frontity/blob/master/LICENSE) | ||
## Usage | ||
> This is an internal package used by [@frontity/core](https://github.com/frontity/frontity/tree/dev/packages/core) | ||
This package is used to import the Frontity settings from a local file. | ||
A settings package for Frontity that reads a `frontity.settings.js` file. | ||
You can install it with `npm`: | ||
_`frontity.settings.js` should contain data that allows it to be serializable (as a JSON) so it can be stored in DB_ | ||
``` | ||
npm i @frontity/file-settings | ||
``` | ||
## Table of contents | ||
Here is a small example of how to use `getSettings`: | ||
<!-- toc --> | ||
```js | ||
import { getSettings } from "@frontity/file-settings"; | ||
- [Feature Discussions](#feature-discussions) | ||
- [Changelog](#changelog) | ||
- [Open Source Community](#open-source-community) | ||
* [Channels](#channels) | ||
* [Get involved](#get-involved) | ||
const settings = await getSettings({ | ||
name: "example-name", | ||
url: "https://example.site" | ||
}); | ||
``` | ||
<!-- tocstop --> | ||
## API Reference | ||
## Feature Discussions | ||
### `async getSettings(options) => settings` | ||
[**Feature Discussions**](https://community.frontity.org/c/feature-discussions/33) about Frontity are public. You can join the discussions, vote for those you're interested in or create new ones. | ||
Used to retrieve the settings from the `frontity.settings.js` file. | ||
These are the ones related to this package: https://community.frontity.org/tags/c/feature-discussions/33/file-settings | ||
#### Parameters | ||
## Changelog | ||
**`options`** : `{ name?: string; url: string; }` | ||
Have a look at the latest updates of this package in the [CHANGELOG](https://github.com/frontity/frontity/blob/dev/packages/file-settings/CHANGELOG.md) | ||
Used to match the right set of settings when there is more than one. | ||
*** | ||
- **`options.name`** : `string (optional)`\ | ||
The name of the set of settings you want to retrieve. When provided, `getSettings` won't use `options.url`. | ||
## Open Source Community | ||
- **`options.url`** : `string`\ | ||
The url of the site using Frontity. The `matches` field of each set of settings will be tested against this url to determine which set of settings should be used. | ||
### Channels | ||
#### Return | ||
[![Community Forum Topics](https://img.shields.io/discourse/topics?color=blue&label=community%20forum&server=https%3A%2F%2Fcommunity.frontity.org%2F)](https://community.frontity.org/) [![Twitter: frontity](https://img.shields.io/twitter/follow/frontity.svg?style=social)](https://twitter.com/frontity) ![Frontity Github Stars](https://img.shields.io/github/stars/frontity/frontity?style=social) | ||
**`settings`** : `Settings`\ | ||
An object with type `Settings` containing a set of settings. | ||
Frontity has a number of different channels at your disposal where you can find out more information about the project, join in discussions about it, and also get involved: | ||
### `async getAllSites() => sites` | ||
- **๐ [Docs](https://docs.frontity.org/):** Frontity's primary documentation resource - this is the place to learn how to build amazing sites with Frontity. | ||
* **๐จโ๐ฉโ๐งโ๐ฆ [Community forum](https://community.frontity.org/):** join Frontity's forum and ask questions, share your knowledge, give feedback and meet other cool Frontity people. We'd love to know about what you're building with Frontity, so please do swing by the [forum](https://community.frontity.org/) and tell us about your projects. | ||
* **๐ Contribute:** Frontity uses [GitHub](https://github.com/frontity/frontity) for bugs and pull requests. Check out the [Contributing](../contributing/) section to find out how you can help develop Frontity, or improve this documentation. | ||
* **๐ฃ Social media**: interact with other Frontity users. Reach out to the Frontity team on [Twitter](https://twitter.com/frontity). Mention us in your tweets about Frontity and what you're building by using **`@frontity`**. | ||
* ๐ **Newsletter:** do you want to receive the latest news about Frontity and find out as soon as there's an update to the framework? Subscribe to our [newsletter](https://frontity.org/#newsletter). | ||
Used to retrieve all the sites with its name, mode and packages. | ||
### Get involved | ||
#### Return | ||
[![GitHub issues by-label](https://img.shields.io/github/issues/frontity/frontity/good%20first%20issue)](https://github.com/frontity/frontity/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) | ||
**Sites**: `{ name: string; mode: string; packages: string[]; }[]`\ | ||
An array of sites containing name, mode and packages. | ||
Got questions or feedback about Frontity? We'd love to hear from you in our [community forum](https://community.frontity.org). | ||
```js | ||
[ | ||
{ | ||
name: "my-site-1", | ||
mode: "html", | ||
packages: ["package-1", "package-2"] | ||
}, | ||
{ | ||
name: "my-site-1-amp", | ||
mode: "amp", | ||
packages: ["package-1", "package-3"] | ||
}, | ||
{ | ||
name: "my-site-2", | ||
mode: "html", | ||
packages: ["package-1", "package-2"] | ||
} | ||
]; | ||
``` | ||
Frontity also welcomes contributions. There are many ways to support the project! If you don't know where to start then this guide might help: [How to contribute?](https://docs.frontity.org/contributing/how-to-contribute). | ||
## Settings File | ||
The file must be located in the root directory of the project, it must be named `frontity.settings.ts` or `frontity.settings.js`, and it needs to export a serializable object. | ||
The settings exported can be **mono settings** (only one): | ||
```ts | ||
{ | ||
name?: string; | ||
match?: string[]; | ||
mode?: string; // Default: "html" | ||
state?: object, | ||
packages: [ | ||
string, | ||
{ | ||
name: string; | ||
active?: boolean; // Default: true | ||
state?: object; | ||
} | ||
] | ||
} | ||
``` | ||
Or **multi settings**: | ||
```ts | ||
// An array of more than one set of settings. | ||
[ | ||
{ | ||
name: string; // Here name is mandatory and must be unique. | ||
match?: string[]; | ||
mode?: string; // Default: "html" | ||
state?: { ... }, | ||
packages: [ ... ] | ||
}, | ||
{ | ||
name: string; // Here name is mandatory and must be unique. | ||
match?: string[]; | ||
mode?: string; // Default: "html" | ||
state?: { ... }, | ||
packages: [ ... ] | ||
} | ||
] | ||
``` | ||
## Typescript | ||
The `Settings` interface is exposed to be used in development. It can be accessed like this: | ||
```js | ||
import { Settings } from "@frontity/file-settings"; | ||
const settings: Settings = { ... }; | ||
``` | ||
### `Settings<T = Package>` | ||
Types for the imported settings object from the settings file. You'll want to use them on your `frontity.settings.ts` file. | ||
If you would like to start contributing to the code please open a pull request to address one of our [*good first issues*](https://github.com/frontity/frontity/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
37010
2
46
930
1
57
1