Skip to content

Commit

Permalink
add doc & fix compilation conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven committed Dec 3, 2023
1 parent 139c08e commit c7e2df5
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 72 deletions.
1 change: 1 addition & 0 deletions docs/website/pages/docs/developer-guides/_meta.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"title": "水龙头",
"display": "hidden"
},
"typescript-sdk": "Typescript-SDK",
"address-space": "地址空间",
"library": "",
"create-rooch-move-contract": "创建 Rooch Move 合约",
Expand Down
26 changes: 26 additions & 0 deletions docs/website/pages/docs/developer-guides/typescript-sdk.en-US.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Start a New Rooch Project

If you want to build a new app or a new website with Rooch, we recommend use rooch-create CLI create project. The CLI provides features that most apps and sites eventually need, including frameworks such as React and Vue (Vue support coming soon). It also encapsulates the relevant framework functionalities.

## Note

Before you begin, make sure to have Node.js installed for local development.

## Create Project

```shell
npm create @roochnetwork/rooch <name>
cd <name>
npm dev
```

This command sets up a new project named &lt;name&gt;, and you can navigate to it with cd &lt;name&gt;. Then, start the development server with npm dev.

The project comes with a counter example. The Increase method in the counter contract can be invoked either through Rooch SDK calls or by initiating Ethereum transactions through Metamask.

The Rooch context and wallet context are also included, making it easy to connect to wallets, send transactions, manage accounts, and handle chains.


## Learn More

Explore the Rooch SDK documentation (here)[https://www.npmjs.com/package/@roochnetwork/rooch-sdk].
25 changes: 25 additions & 0 deletions docs/website/pages/docs/developer-guides/typescript-sdk.zh-CN.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 创建一个新的 Rooch 项目

如果你想要使用 Rooch 构建一个新的应用程序或网站,我们建议使用 rooch-create CLI。CLI 提供了大多数应用程序和网站最终需要的功能,包括 React 和 Vue(即将推出)等框架的封装。

## 注意

在进行本地开发之前,请确保已安装 Node.js。

## 创建项目

```shell
npm create @roochnetwork/rooch <name>
cd <name>
npm dev
```

该命令会创建一个名为 &lt;name&gt; 的新项目,并可以通过 cd &lt;name&gt; 进入该项目。然后,使用 npm dev 启动开发服务器。

该项目包含一个计数器示例。计数器合约的 Increase 方法可以通过 rooch SDK 调用或通过 Metamask 发起以太坊交易来调用。

还包括了 Rooch 上下文和钱包上下文,方便连接钱包、发送交易、管理账户和处理链。

## 了解更多

查阅 (Rooch SDK 文档) [https://www.npmjs.com/package/@roochnetwork/rooch-sdk]
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 22 additions & 35 deletions sdk/typescript/rooch-create/.gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.env
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
*/**/.DS_Store
npm-debug.log
.npm/
/coverage
/tmp
node_modules
.idea/
.history/
.vscode/
dist/
.nyc_output/
build/

# Doc generation output
docs/

# client generation output
generated/

# yarn error
yarn-error.log
2 changes: 1 addition & 1 deletion sdk/typescript/rooch-create/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions sdk/typescript/rooch-create/dist/templates/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
"lint": "next lint"
},
"dependencies": {
"react": "^18",
"react-dom": "^18",
"next": "14.0.3"
"react": "18.2.0",
"react-dom": "18.2.0",
"next": "14.0.3",
"@roochnetwork/rooch-sdk": "{{rooch-version}}"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"typescript": "5.0.4",
"@types/node": "18.15.3",
"autoprefixer": "^10.0.1",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"eslint": "^8",
"@metamask/sdk": "^0.5.6",
"@metamask/detect-provider": "^2.0.0",
"eslint-config-next": "14.0.3"
}
}
2 changes: 1 addition & 1 deletion sdk/typescript/rooch-create/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@roochnetwork/create-rooch",
"version": "0.0.5",
"version": "0.0.6",
"description": "Create a new Rooch project",
"license": "Apache-2.0",
"author": "Rooch.network <[email protected]>",
Expand Down
43 changes: 21 additions & 22 deletions sdk/typescript/rooch-create/scripts/copy-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ git ls-files ../templates/ | rsync --files-from=- ../ dist

# Replace all Rooch package links with mustache placeholder used by create-create-app
# that will be replaced with the latest Rooch version number when the template is used
# find ./dist/templates/* -name "package.json" -type f | while read -r file; do
# echo "Before replacement in $file:"
# cat "$file"
# # GPT-4 recommended perl to edit-in-place rather than sed, because sed wasn't working on CI
# # perl -pi -e 's|"(?=@roochnetwork)([^"]+)":\s*"link:[^"]+"|"\1": "{{rooch-version}}"|g' "$file"
# echo "After replacement in $file:"
# cat "$file"
# echo
# done
find ./dist/templates/* -name "package.json" -type f | while read -r file; do
echo "Before replacement in $file:"
cat "$file"
perl -pi -e 's|"(?=@roochnetwork)([^"]+)":\s*"link:[^"]+"|"\1": "{{rooch-version}}"|g' "$file"
echo "After replacement in $file:"
cat "$file"
echo
done

# # Check if any files still have "link:" dependencies
# if grep -r -E 'link:' ./dist/templates; then
# echo "Linked dependencies found in dist/templates"
# exit 1
# fi
# Check if any files still have "link:" dependencies
if grep -r -E 'link:' ./dist/templates; then
echo "Linked dependencies found in dist/templates"
exit 1
fi

# # Since npm-packlist does not include ".gitignore" files in the packaging process,
# # these files are renamed to "gitignore".
# # create-create-app automatically renames them back to ".gitignore" upon execution.
# find ./dist/templates/* -name ".gitignore" -type f | while read -r file; do
# newfile="$(dirname "$file")/gitignore"
# echo "Renaming $file to $newfile"
# mv "$file" "$newfile"
# done
# Since npm-packlist does not include ".gitignore" files in the packaging process,
# these files are renamed to "gitignore".
# create-create-app automatically renames them back to ".gitignore" upon execution.
find ./dist/templates/* -name ".gitignore" -type f | while read -r file; do
newfile="$(dirname "$file")/gitignore"
echo "Renaming $file to $newfile"
mv "$file" "$newfile"
done
2 changes: 1 addition & 1 deletion sdk/typescript/rooch-create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ create('create-rooch', {
caveat: ({ answers, packageManager }) =>
`Done! Play in the rooch with \`cd ${answers.name}\` and \`${packageManager} run dev\``,
extra: {
'mud-version': {
'rooch-version': {
type: 'input',
describe: 'The version of Rooch packages to use, defaults to latest',
default: packageJson.version,
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/rooch-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@roochnetwork/rooch-sdk",
"author": "Rooch.network <[email protected]>",
"version": "0.0.1",
"version": "0.0.6",
"description": "Rooch SDK",
"license": "Apache-2.0",
"engines": {
Expand Down

0 comments on commit c7e2df5

Please sign in to comment.