Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init Changelog Sync Script #5776

Merged
merged 33 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5a687f0
Init changelog NPM script. Add @types/inquirer, inquirer, and yargs. …
spacesailor24 Jan 21, 2023
d3350fd
Add cypress/.cert and *.lock to prettierignore
spacesailor24 Jan 21, 2023
5420ab8
Ran yarn format
spacesailor24 Jan 21, 2023
7a08878
Bug fix and ts-expect-error reported after updating packages
spacesailor24 Jan 21, 2023
5620f74
Init changelog script
spacesailor24 Jan 21, 2023
dcc1559
Add missing headers for 5525 addition
spacesailor24 Jan 21, 2023
984b55a
Add chalk dev dep
spacesailor24 Jan 22, 2023
fcf7f0f
Add check-sync command
spacesailor24 Jan 22, 2023
69695e7
Remove chalk, inquirer, and yargs dev deps
spacesailor24 Jan 24, 2023
751b2e8
Init changelog script refactor
spacesailor24 Jan 24, 2023
e2b1697
Init changelog script tests
spacesailor24 Jan 24, 2023
b2a36f6
Configure mock page CHANGELOGs
spacesailor24 Jan 25, 2023
77261c3
Make mock_root_CHANGELOG a template
spacesailor24 Jan 25, 2023
f9b1845
Rename mock_parsed_package_changelog
spacesailor24 Jan 25, 2023
36e0ca4
Rename mock_parsed_root_changelog. Add mockRootSyncedChangelog
spacesailor24 Jan 25, 2023
e4f5787
Finish writing syncChangelogs test
spacesailor24 Jan 25, 2023
69e2c25
Finish writing syncChangelogs method
spacesailor24 Jan 25, 2023
796df0d
Merge branch '4.x' into wyatt/4.x/5451-refactor
spacesailor24 Jan 25, 2023
5c9b111
Replace rootChangelogPath with TestChangelogConfig.rootChangelogPath
spacesailor24 Jan 25, 2023
53b14ce
Merge branch 'wyatt/4.x/5451-refactor' of github.com:web3/web3.js int…
spacesailor24 Jan 25, 2023
91e337c
Ran yarn changelog sync
spacesailor24 Jan 25, 2023
df58424
Revert non-related changes to package.json and yarn.lock
spacesailor24 Jan 25, 2023
46a4ea6
Remove Unused '@ts-expect-error' directive
spacesailor24 Jan 25, 2023
ba69cad
Break out syncChangelogs into getSyncedGroupedUnreleasedEntries and f…
spacesailor24 Jan 25, 2023
33ddd76
Break changelog.ts into seperate files and init tests for newly expor…
spacesailor24 Jan 26, 2023
9ab00cd
Merge branch '4.x' into wyatt/4.x/5451-refactor
spacesailor24 Jan 26, 2023
f26c934
Init addChangelogEntry and tests
spacesailor24 Jan 26, 2023
ed815be
Name refactoring
spacesailor24 Jan 26, 2023
1e79dff
Merge branch 'wyatt/4.x/5451-refactor' of github.com:web3/web3.js int…
spacesailor24 Jan 26, 2023
fcfe283
Fix bug when CHANGELOG_CONFIG path not provided
spacesailor24 Jan 26, 2023
30f19e9
Merge branch '4.x' into wyatt/4.x/5451-refactor
spacesailor24 Jan 26, 2023
60f20bf
Merge branch '4.x' into wyatt/4.x/5451-refactor
jdevcs Feb 1, 2023
bb5afb8
Merge branch '4.x' into wyatt/4.x/5451-refactor
spacesailor24 Feb 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1137,4 +1137,8 @@ should use 4.0.1-alpha.0 for testing.

## [Unreleased]

### Added

#### web3-core

Comment on lines +1140 to +1143
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran yarn changelog sync to make this change as current 4.x CHANGELOG.md is missing these headers

image

- Added rpc exception codes following eip-1474 as an experimental feature (if `useRpcCallSpecification` at `enableExperimentalFeatures` is `true`) (#5525)
28 changes: 4 additions & 24 deletions fixtures/contracts/Basic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,11 @@ contract Basic {
return boolValue;
}

function getValues()
public
view
returns (
uint256,
string memory,
bool
)
{
function getValues() public view returns (uint256, string memory, bool) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These file changes are a result of running yarn format

return (intValue, stringValue, boolValue);
}

function setValues(
uint256 _value,
string memory _stringValue,
bool _boolValue
) public {
function setValues(uint256 _value, string memory _stringValue, bool _boolValue) public {
intValue = _value;
stringValue = _stringValue;
boolValue = _boolValue;
Expand All @@ -62,19 +50,11 @@ contract Basic {
revert('REVERTED WITH REVERT');
}

function firesMultiValueEvent(
string memory str,
uint256 val,
bool flag
) public {
function firesMultiValueEvent(string memory str, uint256 val, bool flag) public {
emit MultiValueEvent(str, val, flag);
}

function firesMultiValueIndexedEvent(
string memory str,
uint256 val,
bool flag
) public {
function firesMultiValueIndexedEvent(string memory str, uint256 val, bool flag) public {
emit MultiValueIndexedEvent(str, val, flag);
}

Expand Down
40 changes: 20 additions & 20 deletions fixtures/contracts/Greeter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
pragma solidity ^0.8.13;

contract Greeter {
uint256 counter;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These file changes are a result of running yarn format

string private greeting;
uint256 counter;
string private greeting;

event GREETING_CHANGING(string from, string to);
event GREETING_CHANGED(string greeting);
event GREETING_CHANGING(string from, string to);
event GREETING_CHANGED(string greeting);

constructor(string memory _greeting) {
greeting = _greeting;
counter = 0;
}
constructor(string memory _greeting) {
greeting = _greeting;
counter = 0;
}

function greet() public view returns (string memory) {
return greeting;
}
function greet() public view returns (string memory) {
return greeting;
}

function setGreeting(string memory _greeting) public returns (bool, string memory) {
emit GREETING_CHANGING(greeting, _greeting);
greeting = _greeting;
emit GREETING_CHANGED(greeting);
return (true, greeting);
}
function setGreeting(string memory _greeting) public returns (bool, string memory) {
emit GREETING_CHANGING(greeting, _greeting);
greeting = _greeting;
emit GREETING_CHANGED(greeting);
return (true, greeting);
}

function increment() public {
counter = counter + 1;
}
function increment() public {
counter = counter + 1;
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"build": "lerna run build --stream",
"build:web": "lerna run build:web --stream",
"build:docs": "cd docs && yarn install && yarn build",
"changelog": "ts-node scripts/changelog/src/index.ts",
"clean": "lerna run clean --stream --parallel",
"ganache:start": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start",
"ganache:start:background": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start 1",
Expand All @@ -49,9 +50,9 @@
"geth-binary:stop": "WEB3_SYSTEM_TEST_BACKEND=geth && ./scripts/geth_binary.sh stop",
"lint": "lerna run lint --stream --parallel",
"lint:fix": "lerna run lint:fix --stream --parallel",
"format": "lerna run format --stream --parallel",
"format": "lerna run format --stream --parallel && prettier --write ./scripts/**/*.ts",
"test": "lerna run test --stream --parallel",
"test:unit": "lerna run test:unit --stream --parallel",
"test:unit": "lerna run test:unit --stream --parallel && jest --config=./scripts/jest.config.js",
"test:integration": "lerna run test:integration --stream",
"test:e2e:ganache:http": "./scripts/test-runner.sh ganache http",
"test:e2e:ganache:ws": "./scripts/test-runner.sh ganache ws",
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-core/src/web3_subscription_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { Web3RequestManager, Web3RequestManagerEvent } from './web3_request_mana
import { Web3SubscriptionConstructor } from './web3_subscriptions';

type ShouldUnsubscribeCondition = ({
id: sub,
id,
sub,
Comment on lines +26 to +27
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error was reported after running yarn lint:fix

}: {
id: string;
sub: unknown;
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-errors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export * from './errors/transaction_errors';
export * from './errors/utils_errors';
export * from './errors/response_errors';
export * from './errors/core_errors';
export * from './errors/rpc_errors';
export * from './errors/rpc_errors';
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.8.7;

contract SampleStorageContract {
uint256 uintNum;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These file changes are a result of running yarn format


uint256 uintNum;
event NEWNUM(uint256 param);

event NEWNUM(uint256 param);
function storeNum(uint256 param) public {
uintNum = param;
emit NEWNUM(param);
}

function storeNum(uint256 param) public {
uintNum = param;
emit NEWNUM(param);
}

function retrieveNum() public view returns (uint256){
return uintNum;
}
}
function retrieveNum() public view returns (uint256) {
return uintNum;
}
}
2 changes: 1 addition & 1 deletion packages/web3-validator/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { isAbiParameterSchema } from './validation/abi';
import { isHexStrict } from './validation/string';
// import { abiToJsonSchemaCases } from '../test/fixtures/abi_to_json_schema';

export const parseBaseType = <T = typeof VALID_ETH_BASE_TYPES[number]>(
export const parseBaseType = <T = (typeof VALID_ETH_BASE_TYPES)[number]>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These file changes are a result of running yarn format

type: string,
): {
baseType?: T;
Expand Down
69 changes: 69 additions & 0 deletions scripts/changelog/src/add_changelog_entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
import { readFileSync, writeFileSync } from 'fs';

// eslint-disable-next-line import/no-cycle
import { ChangelogConfig, DEFAULT_CHANGELOG_CONFIG } from './types';
import { getPackageGroupedUnreleasedEntries, getUnreleasedSection } from './sync';

export const addChangelogEntry = (commandName: string, args: string[]) => {
let CHANGELOG_CONFIG: ChangelogConfig;
if (args?.[0] !== undefined && args[0].endsWith('.json')) {
CHANGELOG_CONFIG = JSON.parse(readFileSync(args[0], 'utf8')) as ChangelogConfig;
args.shift();
} else {
CHANGELOG_CONFIG = DEFAULT_CHANGELOG_CONFIG;
}

const [packageName, changelogEntry] = args;
const parsedChangelog = readFileSync(
`${CHANGELOG_CONFIG.packagesDirectoryPath}/${packageName}/${CHANGELOG_CONFIG.packagesChangelogPath}`,
'utf8',
).split(/\n/);
const groupedUnreleasedEntries = getPackageGroupedUnreleasedEntries(
getUnreleasedSection(parsedChangelog),
);
const formattedCommandName = `### ${
commandName.charAt(0).toUpperCase() + commandName.slice(1)
}`;
const formattedChangelogEntry = `- ${changelogEntry}`;

if (groupedUnreleasedEntries[formattedCommandName] !== undefined) {
groupedUnreleasedEntries[formattedCommandName].push(formattedChangelogEntry);
} else {
groupedUnreleasedEntries[formattedCommandName] = [formattedChangelogEntry];
}

const flattenedModifiedUnreleasedEntries: string[] = [];
for (const entryHeader of Object.keys(groupedUnreleasedEntries)) {
const entries = groupedUnreleasedEntries[entryHeader];
flattenedModifiedUnreleasedEntries.push(entryHeader);
flattenedModifiedUnreleasedEntries.push('');
for (const [index, entry] of entries.entries()) {
flattenedModifiedUnreleasedEntries.push(entry);
if (index + 1 === entries.length) flattenedModifiedUnreleasedEntries.push('');
}
}

// +2 is so the header, ## [Unreleased], and the newline after it don't get removed
parsedChangelog.splice(parsedChangelog.findIndex(item => item === '## [Unreleased]') + 2);
parsedChangelog.push(...flattenedModifiedUnreleasedEntries);
writeFileSync(
`${CHANGELOG_CONFIG.packagesDirectoryPath}/${packageName}/${CHANGELOG_CONFIG.packagesChangelogPath}`,
parsedChangelog.join('\n'),
);
};
40 changes: 40 additions & 0 deletions scripts/changelog/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
import { readdirSync } from 'fs';

// eslint-disable-next-line import/no-cycle
import { Command, getCommands } from './types';

export const parseArgs = (commands: Command[] = getCommands()): unknown => {
const commandArg = process.argv[2];
for (const command of commands) {
if (command.name === commandArg) {
return command.commandFunction(command.name, process.argv.slice(3));
}
}

// eslint-disable-next-line no-console
console.log('Invalid command, please refer to below table for expected commands:');
// eslint-disable-next-line no-console
console.table(commands);
return undefined;
};

export const getListOfPackageNames = (packagesDirectory: string) =>
readdirSync(packagesDirectory, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
20 changes: 20 additions & 0 deletions scripts/changelog/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
// eslint-disable-next-line import/no-cycle
import { parseArgs } from './helpers';

parseArgs();
Loading