diff --git a/.circleci/config.yml b/.circleci/config.yml index e7b5f023fba..2e01af9891a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -70,7 +70,7 @@ commands: steps: - checkout - concat_files: - glob: "*/*.csproj" + glob: "{src,test,tools}/*/*.csproj" to: .combined-package-files.txt - restore_cache: keys: @@ -105,14 +105,18 @@ commands: root: . paths: - <> - - "*/bin/" - - "*/obj/" + - "src/*/bin/" + - "src/*/obj/" + - "test/*/bin/" + - "test/*/obj/" + - "tools/*/bin/" + - "tools/*/obj/" mono_build_base: steps: - checkout - concat_files: - glob: "*/*.csproj" + glob: "{src,test,tools}/*/*.csproj" to: .combined-package-files.txt - restore_cache: keys: diff --git a/.github/bin/constants.sh b/.github/bin/constants.sh index 8c1f33f214f..c7ebeb043e3 100644 --- a/.github/bin/constants.sh +++ b/.github/bin/constants.sh @@ -3,29 +3,29 @@ # shellcheck disable=SC2034 solution="Libplanet" projects=( - "Libplanet" - "Libplanet.Action" - "Libplanet.Common" - "Libplanet.Crypto" - "Libplanet.Crypto.Secp256k1" - "Libplanet.Mocks" - "Libplanet.Net" - "Libplanet.Store" - "Libplanet.Store.Remote" - "Libplanet.Stun" - "Libplanet.Types" - "Libplanet.RocksDBStore" - "Libplanet.Analyzers" - "Libplanet.Tools" - "Libplanet.Explorer" - "Libplanet.Explorer.Executable" - "Libplanet.Explorer.Cocona" - "Libplanet.Extensions.Cocona" + "src/Libplanet" + "src/Libplanet.Action" + "src/Libplanet.Common" + "src/Libplanet.Crypto" + "src/Libplanet.Crypto.Secp256k1" + "src/Libplanet.Net" + "src/Libplanet.Store" + "src/Libplanet.Store.Remote" + "src/Libplanet.Stun" + "src/Libplanet.Types" + "src/Libplanet.RocksDBStore" + "test/Libplanet.Mocks" + "tools/Libplanet.Analyzers" + "tools/Libplanet.Tools" + "tools/Libplanet.Explorer" + "tools/Libplanet.Explorer.Executable" + "tools/Libplanet.Explorer.Cocona" + "tools/Libplanet.Extensions.Cocona" ) configuration=Release executables=( - "Libplanet.Tools" - "Libplanet.Explorer.Executable" + "tools/Libplanet.Tools" + "tools/Libplanet.Explorer.Executable" ) npm_packages=( "@planetarium/cli" diff --git a/.github/workflows/benchmarks-pr.yml b/.github/workflows/benchmarks-pr.yml index d685778c847..e40ad9763a1 100644 --- a/.github/workflows/benchmarks-pr.yml +++ b/.github/workflows/benchmarks-pr.yml @@ -26,7 +26,7 @@ jobs: with: dotnet-version: 6.0.x - name: Run benchmark - run: dotnet run --project Libplanet.Benchmarks -c Release -- --exporters json --filter '*' + run: dotnet run --project tools/Libplanet.Benchmarks -c Release -- --exporters json --filter '*' - name: Compare benchmark result uses: planetarium/github-action-benchmark@v1 diff --git a/.github/workflows/yarn.yaml b/.github/workflows/yarn.yaml index b0cef87c74f..efd11b02cb6 100644 --- a/.github/workflows/yarn.yaml +++ b/.github/workflows/yarn.yaml @@ -61,7 +61,7 @@ jobs: - if: runner.os != 'Windows' run: | set -ev - cd Libplanet.Tools/ + cd tools/Libplanet.Tools/ bin/npm-test.sh "$LATEST_VERSION" env: LATEST_VERSION: ${{ steps.latest-tag.outputs.tag }} @@ -69,7 +69,7 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - cd Libplanet.Tools\ + cd tools\Libplanet.Tools\ pwsh ` -ExecutionPolicy Bypass ` -File bin\npm-test.ps1 ` diff --git a/@planetarium/cli b/@planetarium/cli index 059870b2cdb..d16b8cf53dc 120000 --- a/@planetarium/cli +++ b/@planetarium/cli @@ -1 +1 @@ -../Libplanet.Tools \ No newline at end of file +../tools/Libplanet.Tools \ No newline at end of file diff --git a/@planetarium/tx/package.json b/@planetarium/tx/package.json index 1a5d44b5bbd..7723ed0ec1a 100644 --- a/@planetarium/tx/package.json +++ b/@planetarium/tx/package.json @@ -21,8 +21,8 @@ "scripts": { "build": "yarn && nanobundle build", "prepack": "yarn && yarn build", - "dev": "yarn && dotnet build ../../Libplanet.Tools && vitest", - "test": "yarn && yarn run -T tsc -p tsconfig.json && dotnet build ../../Libplanet.Tools && vitest run", + "dev": "yarn && dotnet build ../../tools/Libplanet.Tools && vitest", + "test": "yarn && yarn run -T tsc -p tsconfig.json && dotnet build ../../tools/Libplanet.Tools && vitest run", "coverage": "yarn && vitest run --coverage" }, "repository": { diff --git a/@planetarium/tx/test/tx/signed.test.ts b/@planetarium/tx/test/tx/signed.test.ts index c3d47916c09..7252944b22e 100644 --- a/@planetarium/tx/test/tx/signed.test.ts +++ b/@planetarium/tx/test/tx/signed.test.ts @@ -1,10 +1,10 @@ -import { encodeSignedTx, signTx } from "../../src/tx/signed"; -import { type UnsignedTx } from "../../src/tx/unsigned"; -import { account1, address1 } from "./fixtures"; +import { join } from "node:path"; import { RecordView, encode } from "@planetarium/bencodex"; import { execa } from "execa"; -import { join } from "node:path"; import { describe, expect, test } from "vitest"; +import { encodeSignedTx, signTx } from "../../src/tx/signed"; +import { type UnsignedTx } from "../../src/tx/unsigned"; +import { account1, address1 } from "./fixtures"; describe("signTx", () => { test("UnsignedTx", async () => { @@ -30,28 +30,28 @@ describe("signTx", () => { minters: [ Buffer.from( "47d082a115c63e7b58b1532d20e631538eafadde", - "hex", + "hex" ), ], ticker: "NCG", }, - "text", + "text" ), 1000n, ], recipient: Buffer.from( "5a533067D0cBa77490268b26195EdB10B990143D", - "hex", + "hex" ), sender: Buffer.from( "111CB8E18c6D70f5032000c5739c5ac36E793EDB", - "hex", + "hex" ), }, - "text", + "text" ), }, - "text", + "text" ), ], }; @@ -64,13 +64,13 @@ describe("signTx", () => { "run", "--no-build", "--project", - join(__dirname, "..", "..", "..", "..", "Libplanet.Tools"), + join(__dirname, "..", "..", "..", "..", "tools", "Libplanet.Tools"), "--", "tx", "analyze", "-", ], - { input: payload }, + { input: payload } ); expect(JSON.parse(stdout)).toStrictEqual({ id: "49a645bb80fa96757009615ec33bc15a2e90e9121877de9f14de35b7d657a118", diff --git a/@planetarium/tx/test/tx/unsigned.test.ts b/@planetarium/tx/test/tx/unsigned.test.ts index be972f20c0d..48ac83caa04 100644 --- a/@planetarium/tx/test/tx/unsigned.test.ts +++ b/@planetarium/tx/test/tx/unsigned.test.ts @@ -1,9 +1,9 @@ -import { encodeUnsignedTx } from "../../src/tx/unsigned"; -import { key1 } from "./fixtures"; +import { join } from "node:path"; import { RecordView, encode } from "@planetarium/bencodex"; import { execa } from "execa"; -import { join } from "node:path"; import { expect, test } from "vitest"; +import { encodeUnsignedTx } from "../../src/tx/unsigned"; +import { key1 } from "./fixtures"; test("encodeUnsignedTx", async () => { const encoded = encodeUnsignedTx({ @@ -28,25 +28,25 @@ test("encodeUnsignedTx", async () => { new Uint8Array( Buffer.from( "47d082a115c63e7b58b1532d20e631538eafadde", - "hex", - ), + "hex" + ) ), ], ticker: "NCG", }, - "text", + "text" ), 1000n, ], recipient: new Uint8Array( - Buffer.from("5a533067D0cBa77490268b26195EdB10B990143D", "hex"), + Buffer.from("5a533067D0cBa77490268b26195EdB10B990143D", "hex") ), sender: new Uint8Array( - Buffer.from("111CB8E18c6D70f5032000c5739c5ac36E793EDB", "hex"), + Buffer.from("111CB8E18c6D70f5032000c5739c5ac36E793EDB", "hex") ), }, }, - "text", + "text" ), ], }); @@ -57,7 +57,7 @@ test("encodeUnsignedTx", async () => { "run", "--no-build", "--project", - join(__dirname, "..", "..", "..", "..", "Libplanet.Tools"), + join(__dirname, "..", "..", "..", "..", "tools", "Libplanet.Tools"), "--", "tx", "analyze", @@ -66,7 +66,7 @@ test("encodeUnsignedTx", async () => { ], { input: Buffer.from(payload), - }, + } ); expect(JSON.parse(stdout)).toStrictEqual({ nonce: 123, diff --git a/Docs/docfx.json b/Docs/docfx.json index 09f560a223b..dffea54a550 100644 --- a/Docs/docfx.json +++ b/Docs/docfx.json @@ -4,20 +4,20 @@ "src": [ { "files": [ - "Libplanet/Libplanet.csproj", - "Libplanet.Action/Libplanet.Action.csproj", - "Libplanet.Common/Libplanet.Common.csproj", - "Libplanet.Crypto/Libplanet.Crypto.csproj", - "Libplanet.Crypto.Secp256k1/Libplanet.Crypto.Secp256k1.csproj", - "Libplanet.Explorer.Cocona/Libplanet.Explorer.Cocona.csproj", - "Libplanet.Extensions.Cocona/Libplanet.Extensions.Cocona.csproj", - "Libplanet.Mocks/Libplanet.Mocks.csproj", - "Libplanet.Net/Libplanet.Net.csproj", - "Libplanet.RocksDBStore/Libplanet.RocksDBStore.csproj", - "Libplanet.Store/Libplanet.Store.csproj", - "Libplanet.Store.Remote/Libplanet.Store.Remote.csproj", - "Libplanet.Stun/Libplanet.Stun.csproj", - "Libplanet.Types/Libplanet.Types.csproj" + "src/Libplanet/Libplanet.csproj", + "src/Libplanet.Action/Libplanet.Action.csproj", + "src/Libplanet.Common/Libplanet.Common.csproj", + "src/Libplanet.Crypto/Libplanet.Crypto.csproj", + "src/Libplanet.Crypto.Secp256k1/Libplanet.Crypto.Secp256k1.csproj", + "tools/Libplanet.Explorer.Cocona/Libplanet.Explorer.Cocona.csproj", + "tools/Libplanet.Extensions.Cocona/Libplanet.Extensions.Cocona.csproj", + "test/Libplanet.Mocks/Libplanet.Mocks.csproj", + "src/Libplanet.Net/Libplanet.Net.csproj", + "src/Libplanet.RocksDBStore/Libplanet.RocksDBStore.csproj", + "src/Libplanet.Store/Libplanet.Store.csproj", + "src/Libplanet.Store.Remote/Libplanet.Store.Remote.csproj", + "src/Libplanet.Stun/Libplanet.Stun.csproj", + "src/Libplanet.Types/Libplanet.Types.csproj" ], "exclude": ["**/bin/**", "**/obj/**"], "src": "../" @@ -48,7 +48,7 @@ ] }, { - "src": "../Libplanet.Analyzers", + "src": "../tools/Libplanet.Analyzers", "dest": "analyzer", "files": [ "*.md", @@ -56,14 +56,14 @@ ] }, { - "src": "../Libplanet.Tools", + "src": "../tools/Libplanet.Tools", "dest": "cli", "files": [ "*.md" ] }, { - "src": "../Libplanet.Explorer", + "src": "../tools/Libplanet.Explorer", "dest": "explorer", "files": [ "*.md" @@ -111,7 +111,6 @@ "fileMetadataFiles": [], "template": ["default"], - // "statictoc" has a bug that relative links with nested dirs in nav refer to incorrect destinations "theme": ["theme"], "postProcessors": [], diff --git a/hooks/check-projects b/hooks/check-projects index d06a06156e5..4fa193accc1 100755 --- a/hooks/check-projects +++ b/hooks/check-projects @@ -9,7 +9,7 @@ if ! [[ -f "$SOLUTION" ]]; then fi list-projects() { - dotnet sln "$SOLUTION" list | grep -E $'\\...proj\r?$' | sed 's/[/\].*//' + dotnet sln "$SOLUTION" list | grep -E $'\\...proj\r?$' | sed 's/[/][^/]*$//' } # shellcheck source=.github/bin/constants.sh @@ -26,7 +26,8 @@ check-github-actions() { } check-contributing() { - if ! grep -E "^ - \*$1\*: " CONTRIBUTING.md > /dev/null; then + name=$(echo "$1" | sed -re 's/(src|tools|test)\///') + if ! grep -E "^ - \*$name\*: " CONTRIBUTING.md > /dev/null; then echo "The project $1 is not documented in the CONTRIBUTING.md file." \ > /dev/stderr exit 1 diff --git a/hooks/pre-commit b/hooks/pre-commit index 2d30c09fa38..5e459f25805 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -15,7 +15,7 @@ if command -v yarn --help > /dev/null; then # FIXME: The following workaround should be removed when Rome fixes their bug # which fails to resolve symlinks referring to the parent directory. rm -f @planetarium/cli - trap "ln -sf ../Libplanet.Tools @planetarium/cli" EXIT + trap "ln -sf ../tools/Libplanet.Tools @planetarium/cli" EXIT yarn rome check . else echo warn: yarn is not available\; not running commands pertaining to node.js. >&2 diff --git a/package.json b/package.json index 1f5392e4921..6a1236314db 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "@planetarium/account-aws-kms", "@planetarium/account-web3-secret-storage", "@planetarium/tx", - "Libplanet.Tools" + "tools/Libplanet.Tools" ], "scripts": { "build": "printf \"\\033[41;97mLibplanet note: currently, it is expected for `yarn build` to fail on the first run and succeed on the second run due to an unknown issue unrelated to the codebase (see issue #3492,) so the build phase runs twice. Whenever the culprit is specified please remove this message and the duplicate call.\\033[0m\n\" >&2 && _libplanet_build=1 yarn workspaces foreach -p -A run build || _libplanet_build=1 yarn workspaces foreach -p -A run build", diff --git a/test/Libplanet.Tests/Tx/TxSigningMetadataTest.ts b/test/Libplanet.Tests/Tx/TxSigningMetadataTest.ts index 84fdfeffc23..f3b18a3b09a 100644 --- a/test/Libplanet.Tests/Tx/TxSigningMetadataTest.ts +++ b/test/Libplanet.Tests/Tx/TxSigningMetadataTest.ts @@ -1,6 +1,3 @@ -namespace Libplanet.Tests.Tx -{ - public class X { - - } -} \ No newline at end of file +namespace Libplanet.Tests.Tx { + class X {} +} diff --git a/yarn.lock b/yarn.lock index c6eb7cd6ac9..596388f4010 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1392,9 +1392,9 @@ __metadata: languageName: node linkType: hard -"@planetarium/cli@workspace:Libplanet.Tools": +"@planetarium/cli@workspace:tools/Libplanet.Tools": version: 0.0.0-use.local - resolution: "@planetarium/cli@workspace:Libplanet.Tools" + resolution: "@planetarium/cli@workspace:tools/Libplanet.Tools" dependencies: extract-zip: "npm:^2.0.1" node-fetch: "npm:^3.1.1" @@ -1532,11 +1532,11 @@ __metadata: linkType: hard "@types/yauzl@npm:^2.9.1": - version: 2.10.0 - resolution: "@types/yauzl@npm:2.10.0" + version: 2.10.3 + resolution: "@types/yauzl@npm:2.10.3" dependencies: "@types/node": "npm:*" - checksum: 55d27ae5d346ea260e40121675c24e112ef0247649073848e5d4e03182713ae4ec8142b98f61a1c6cbe7d3b72fa99bbadb65d8b01873e5e605cdc30f1ff70ef2 + checksum: 5ee966ea7bd6b2802f31ad4281c92c4c0b6dfa593c378a2582c58541fa113bec3d70eb0696b34ad95e8e6861a884cba6c3e351285816693ed176222f840a8c08 languageName: node linkType: hard @@ -2123,7 +2123,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.3.3, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -2135,6 +2135,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:^4.1.1": + version: 4.3.5 + resolution: "debug@npm:4.3.5" + dependencies: + ms: "npm:2.1.2" + peerDependenciesMeta: + supports-color: + optional: true + checksum: cb6eab424c410e07813ca1392888589972ce9a32b8829c6508f5e1f25f3c3e70a76731610ae55b4bbe58d1a2fffa1424b30e97fa8d394e49cd2656a9643aedd2 + languageName: node + linkType: hard + "decamelize-keys@npm:^1.1.0": version: 1.1.1 resolution: "decamelize-keys@npm:1.1.1"