4.1 KiB
order | toc |
---|---|
100 | menu |
Contributing
Basic process
- Fork the source code to your own repository
- Modify source code
- Submit pull request
Installation and start-up
# Replace the following git address with your own repo
git clone https://github.com/nocobase/nocobase.git
cd nocobase
cp .env.example .env
yarn install
yarn bootstrap
yarn build
yarn nocobase init --import-demo
yarn start
Open http://localhost:8000/ in your browser
Involved in core code development, the project starts with a documentation page, not the application's login page.Main scripts
Startup and reboot
The above commands are only executed the first time, after that the project is restarted with
yarn start
Reinstallation
If you want to clear and reinstall
### If you want to import demo data, you can add --import-demo
yarn nocobase init --import-demo
# After reinstallation, you also need to restart
yarn start
Build
For integration testing or site-wide debugging, the following package changes need to be recompiled and repackaged.
- actions
- database
- resourcer
- server
- test
- utils
In addition to the compilation issues, there are many details of the project build that remain unresolved. If you have some good suggestions, you are welcome to discuss them on GitHub Discussions.
# for all packages
yarn build
# for specific package
yarn build <package_name_1> <package_name_2>
# e.g.
# yarn build database
Testing
After upgrading v0.5, some tests have not been fixed yet, and the ci tests are not available yet. The code tests are not perfect yet, more tests will be added and improved in phases...
# For all packages
yarn test
# For specific package
yarn test packages/<name>
More scripts
View scripts of package.json
Document revision and translation
The documentation is in the docs directory and follows Markdown syntax, defaults to English and ends with .zh-CN.md
in Chinese, e.g.
|- /docs/
|- index.md # English document
|- index.zh-CN.md # Chinese document, when it is missing, the content of index.md is displayed
After modification, open http://localhost:8000/ in your browser to see the final effect.
Back-end
Most of the changes on the back-end can be verified by the test command.
yarn test packages/<name>
Of course, if you are adding new content, you will need to write new tests. @nocobase/test
provides mockDatabase
and ``mockServer` for database and server testing, e.g.
import { mockServer, MockServer } from '@nocobase/test';
describe('mock server', () => {
let api: MockServer;
beforeEach(() => {
api = mockServer({
dataWrapping: false,
});
api.actions({
list: async (ctx, next) => {
ctx.body = [1, 2];
await next();
},
});
api.resource({
name: 'test',
});
});
afterEach(async () => {
return api.destroy();
});
it('agent.get', async () => {
const response = await api.agent().get('/test');
expect(response.body).toEqual([1, 2]);
});
it('agent.resource', async () => {
const response = await api.agent().resource('test').list();
expect(response.body).toEqual([1, 2]);
});
});
Full-stack demo
To facilitate local debugging for developers, the full-stack demo is also an embedded demo, which can be opened full-screen by clicking on the new tab in the bottom left corner.
Client components
The component library is still being organized...Each component is independent, easy to debug and use. See the component list at http://localhost:8000/components
Provide more examples
Examples are still being compiled...Examples are available at http://localhost:8000/examples