Cerebral

流行的 JavaScript 框架的声明状态和副作用管理。(Declarative state and side effects management for popular JavaScript frameworks)

Github stars Tracking Chart

Cerebral

流行的 JavaScript 框架的声明状态和副作用管理解决方案

文档

贡献

整个 Cerebral 代码库已被重写以鼓励贡献。代码被清理,注释并且所有代码都在“monorepo”中。这意味着您可以跨项目运行测试,并且对代码的一般管理进行了简化。

  1. 克隆 monorepo: git clone https://github.com/cerebral/cerebral.git
  2. 在 root 中: npm install

这些包位于 packages 文件夹下,无需为每个包运行 npm install。

为自己的应用程序使用 monorepo

如果要直接从克隆的 repo 中使用 Cerebral 2,可以为以下目录创建符号链接到应用程序的 node_modules 目录:

  • packages/node_modules/cerebral
  • packages/node_modules/function-tree
  • packages/node_modules/@cerebral

如果您的应用程序和 Cerebral monorepo 位于同一文件夹中,您可以在 app 目录中执行以下操作:

$ ln -s ../../cerebral/packages/node_modules/cerebral/ node_modules/
# ...

只需记住在从 npm 安装包之前 unlink 取消链接:

$ unlink node_modules/cerebral
# ...

运行演示

转到相应的 packages/demos/some-demo-folder 并运行 npm start

测试

您可以从 root 运行所有包中的所有测试:

npm test

或者您可以通过打包 root 来运行特定包的测试并执行相同的操作:

npm test

更改代码

当您进行代码更改时,您应该首先创建一个分支。当代码更改并由测试备份时,您可以使用以下命令从 root 用户提交代码:

npm run commit

这将为您提供创建提交消息的指南。然后你只需在 Github 上正常推送并创建一个拉取请求。

发布过程

  • 检查 PR 并将其合并到 next 分支中。使用 "Update branch" 是安全的,Github 创建的提交将不会成为 next 历史记录的一部分,
  • 如果更改 repo-cooker, 请清理 Travis NPM cache
  • 从命令行:
$ git checkout next
$ git pull
$ npm install # 确保安装了任何新的依赖项
$ npm install --no-save repo-cooker # 需要测试版本,请确保您有最新版本

$ npm run release # 并检查发布说明
$ git checkout master
$ git pull
$ git merge --ff-only next
$ git push

(First edition: vz edited at 2019.08.24)

Main metrics

Overview
Name With Ownercerebral/cerebral
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 4)
PlatformLinux, Mac, Windows
License:MIT License
所有者活动
Created At2015-05-09 11:40:05
Pushed At2025-03-25 20:48:13
Last Commit At2025-03-25 21:41:57
Release Count129
Last Release Namev2025-03-25_2048 (Posted on 2025-03-25 20:48:12)
First Release Namev0.5.0 (Posted on )
用户参与
Stargazers Count2k
Watchers Count44
Fork Count124
Commits Count2.3k
Has Issues Enabled
Issues Count467
Issue Open Count1
Pull Requests Count835
Pull Requests Open Count0
Pull Requests Close Count141
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Cerebral

A declarative state and side effects management solution for popular JavaScript frameworks

NPM version
Build status
Coverage Status
bitHound Score
Commitizen friendly
Discord

Documentation

Contribute

The entire Cerebral codebase has been rewritten to encourage contributions. The code is cleaned up, commented and all code is in a "monorepo". That means you can run tests across projects and general management of the code is simplified a lot.

  1. Clone the monorepo: git clone https://github.com/cerebral/cerebral.git
  2. In root: npm install

The packages are located under packages folder and there is no need to run npm install for each package.

Using monorepo for your own apps

If you want to use Cerebral 2 directly from your cloned repo, you can create a symlinks for following
directories into the node_modules directory of your app:

  • packages/node_modules/cerebral
  • packages/node_modules/function-tree
  • packages/node_modules/@cerebral

If your app and the cerebral monorepo are in the same folder you can do from inside your
app directory:

$ ln -s ../../cerebral/packages/node_modules/cerebral/ node_modules/
# ...

Just remember to unlink the package before installing it from npm:

$ unlink node_modules/cerebral
# ...

Running demos

Go to the respective packages/demos/some-demo-folder and run npm start

Testing

You can run all tests in all packages from root:

npm test

Or you can run tests for specific packages by going to package root and do the same:

npm test

Changing the code

When you make a code change you should create a branch first. When the code is changed and backed up by a test you can commit it from the root using:

npm run commit

This will give you a guide to creating a commit message. Then you just push and create a pull request as normal on Github.

Release process

  • Review and merge PRs into next branch. It is safe to use "Update branch", the commit created by Github will not be part of next history
  • If changes to repo-cooker, clean Travis NPM cache
  • From command line:
$ git checkout next
$ git pull
$ npm install # make sure any new dependencies are installed
$ npm install --no-save repo-cooker # needed to test release, make sure you have latest
$ npm run release # and check release notes
$ git checkout master
$ git pull
$ git merge --ff-only next
$ git push