Skip to content

Commit c30991e

Browse files
Merge branch 'master' of github.com:waku-org/js-waku into feat/metadata-protocol
2 parents 36c3990 + e681007 commit c30991e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1161
-833
lines changed

.cspell.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"ahadns",
88
"Alives",
99
"asym",
10+
"autoshard",
11+
"autosharding",
1012
"backoff",
1113
"backoffs",
1214
"bitauth",
@@ -123,7 +125,7 @@
123125
"Привет",
124126
"مرحبا"
125127
],
126-
"flagWords": ["pubSub", "pubSubTopics", "pubSubTopic"],
128+
"flagWords": ["pubSub: pubsub", "pubSubTopics: pubsubTopics", "pubSubTopic: pubsubTopic", "PubSub: Pubsub", "PubSubTopics: PubsubTopics", "PubSubTopic: PubsubTopic", "DefaultPubSubTopic: DefaultPubsubTopic"],
127129
"ignorePaths": [
128130
"package.json",
129131
"package-lock.json",

.eslintrc.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"@typescript-eslint/no-floating-promises": "error",
7373
"@typescript-eslint/await-thenable": "error",
7474
"@typescript-eslint/no-misused-promises": "error",
75-
"@typescript-eslint/no-explicit-any": "warn"
75+
"@typescript-eslint/no-explicit-any": "warn",
76+
"id-match": ["error", "^(?!.*[pP]ubSub)"]
7677
},
7778
"overrides": [
7879
{
@@ -99,6 +100,12 @@
99100
}
100101
]
101102
}
103+
},
104+
{
105+
"files": ["**/ci/*.js"],
106+
"rules": {
107+
"no-undef": "off"
108+
}
102109
}
103110
]
104111
}

.github/dependabot.yml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ updates:
55
open-pull-requests-limit: 2
66
schedule:
77
interval: "daily"
8-
reviewers: ["fryorcraken","danisharora099","weboko"]
98
versioning-strategy: increase
109
commit-message:
1110
prefix: "chore(deps)"

.github/workflows/pre-release.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
workflow_dispatch:
3+
4+
jobs:
5+
pre-release:
6+
name: pre-release
7+
runs-on: ubuntu-latest
8+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master'
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
repository: waku-org/js-waku
13+
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: ${{ env.NODE_JS }}
17+
registry-url: "https://registry.npmjs.org"
18+
19+
- run: npm install
20+
21+
- run: npm run build
22+
23+
- run: npm run publish -- --tag next
24+
env:
25+
NODE_AUTH_TOKEN: ${{ secrets.NPM_JS_WAKU_PUBLISH }}

.github/workflows/test-node.yml

+8
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,11 @@ jobs:
9797
with:
9898
name: ${{ inputs.test_type }}-logs
9999
path: packages/tests/log/
100+
101+
- name: Create test summary
102+
if: always() && env.ALLURE_REPORTS == 'true'
103+
run: |
104+
echo "## Run Information" >> $GITHUB_STEP_SUMMARY
105+
echo "- **NWAKU**: ${{ env.WAKUNODE_IMAGE }}" >> $GITHUB_STEP_SUMMARY
106+
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
107+
echo "Allure report will be available at: https://waku-org.github.io/allure-jswaku/${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY

.release-please-manifest.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"packages/utils": "0.0.12",
2+
"packages/utils": "0.0.13",
33
"packages/proto": "0.0.5",
4-
"packages/interfaces": "0.0.19",
5-
"packages/message-hash": "0.1.8",
6-
"packages/enr": "0.0.18",
7-
"packages/peer-exchange": "0.0.17",
8-
"packages/core": "0.0.24",
9-
"packages/dns-discovery": "0.0.18",
10-
"packages/message-encryption": "0.0.22",
11-
"packages/relay": "0.0.7",
12-
"packages/sdk": "0.0.20"
4+
"packages/interfaces": "0.0.20",
5+
"packages/message-hash": "0.1.9",
6+
"packages/enr": "0.0.19",
7+
"packages/peer-exchange": "0.0.18",
8+
"packages/core": "0.0.25",
9+
"packages/dns-discovery": "0.0.19",
10+
"packages/message-encryption": "0.0.23",
11+
"packages/relay": "0.0.8",
12+
"packages/sdk": "0.0.21"
1313
}

CONTRIBUTING.md

+9
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,12 @@ Commit messages should never contain any `@` mentions (usernames prefixed with "
6060

6161
Please refer to the [Git manual](https://git-scm.com/doc) for more information
6262
about Git.
63+
64+
### Releasing
65+
66+
`js-waku` has two types of releases:
67+
- public releases;
68+
- pre releases;
69+
70+
Public releases happen by merging PRs opened by `release-please` action.
71+
Pre releases happen manually by triggering [this workflow](https://github.com/waku-org/js-waku/actions/workflows/pre-release.yml)

ci/publish.js

+87-14
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ const PACKAGE_JSON = "package.json";
88
// hack to get __dirname
99
const DIR = path.dirname(fileURLToPath(import.meta.url));
1010

11+
const NEXT_TAG = "next";
12+
const LATEST_TAG = "latest";
13+
const CURRENT_TAG = readPublishTag();
14+
1115
const exec = promisify(cp.exec);
1216
const readFile = promisify(fs.readFile);
17+
const writeFile = promisify(fs.writeFile);
1318

1419
run()
1520
.then(() => {
@@ -23,26 +28,31 @@ async function run() {
2328
const rootPackage = await readJSON(path.resolve(DIR, "../", PACKAGE_JSON));
2429
const workspacePaths = rootPackage.workspaces;
2530

26-
const workspaces = await Promise.all(
27-
workspacePaths.map(async (workspacePath) => {
28-
const workspaceInfo = await readWorkspace(workspacePath);
29-
const allowPublishing = await shouldBePublished(workspaceInfo);
31+
if (CURRENT_TAG === NEXT_TAG) {
32+
await makeReleaseCandidate();
33+
}
3034

31-
if (allowPublishing) {
32-
return workspaceInfo;
33-
}
35+
const workspaces = await Promise.all(workspacePaths.map(readWorkspace));
3436

35-
return;
36-
})
37-
);
37+
if (CURRENT_TAG === NEXT_TAG) {
38+
await upgradeWakuDependencies(workspaces);
39+
}
3840

3941
await Promise.all(
4042
workspaces
41-
.filter((v) => !!v)
43+
.filter(async (info) => {
44+
const allowPublishing = await shouldBePublished(info);
45+
46+
if (allowPublishing) {
47+
return true;
48+
}
49+
50+
return false;
51+
})
4252
.map(async (info) => {
4353
try {
4454
await exec(
45-
`npm publish --workspace ${info.workspace} --tag latest --access public`
55+
`npm publish --workspace ${info.workspace} --tag ${CURRENT_TAG} --access public`
4656
);
4757
console.info(
4858
`Successfully published ${info.workspace} with version ${info.version}.`
@@ -61,6 +71,11 @@ async function readJSON(path) {
6171
return JSON.parse(rawJSON);
6272
}
6373

74+
async function writeWorkspace(packagePath, text) {
75+
const resolvedPath = path.resolve(DIR, "../", packagePath, PACKAGE_JSON);
76+
await writeFile(resolvedPath, text);
77+
}
78+
6479
async function readWorkspace(packagePath) {
6580
const json = await readJSON(
6681
path.resolve(DIR, "../", packagePath, PACKAGE_JSON)
@@ -70,13 +85,14 @@ async function readWorkspace(packagePath) {
7085
name: json.name,
7186
private: !!json.private,
7287
version: json.version,
73-
workspace: packagePath
88+
workspace: packagePath,
89+
rawPackageJson: json
7490
};
7591
}
7692

7793
async function shouldBePublished(info) {
7894
if (info.private) {
79-
console.info(`Skipping ${info.path} because it is private.`);
95+
console.info(`Skipping ${info.name} because it is private.`);
8096
return false;
8197
}
8298

@@ -99,3 +115,60 @@ async function shouldBePublished(info) {
99115
);
100116
}
101117
}
118+
119+
async function makeReleaseCandidate() {
120+
try {
121+
console.info("Marking workspace versions as release candidates.");
122+
await exec(
123+
`npm version prerelease --preid $(git rev-parse --short HEAD) --workspaces true`
124+
);
125+
} catch (e) {
126+
console.error("Failed to mark release candidate versions.", e);
127+
}
128+
}
129+
130+
function readPublishTag() {
131+
const args = process.argv.slice(2);
132+
const tagIndex = args.indexOf("--tag");
133+
134+
if (tagIndex !== -1 && args[tagIndex + 1]) {
135+
return args[tagIndex + 1];
136+
}
137+
138+
return LATEST_TAG;
139+
}
140+
141+
async function upgradeWakuDependencies(workspaces) {
142+
console.log("Upgrading Waku dependencies in workspaces.");
143+
const map = workspaces.reduce((acc, item) => {
144+
if (!item.private) {
145+
acc[item.name] = item;
146+
}
147+
return acc;
148+
}, {});
149+
const packageNames = Object.keys(map);
150+
workspaces.forEach(async (info) => {
151+
if (info.private) {
152+
return;
153+
}
154+
["dependencies", "devDependencies", "peerDependencies"].forEach((type) => {
155+
const deps = info.rawPackageJson[type];
156+
if (!deps) {
157+
return;
158+
}
159+
packageNames.forEach((name) => {
160+
if (deps[name]) {
161+
deps[name] = map[name].version;
162+
}
163+
});
164+
});
165+
try {
166+
await writeWorkspace(info.workspace, JSON.stringify(info.rawPackageJson));
167+
} catch (error) {
168+
console.error(
169+
`Failed to update package.json for ${info.name} with: `,
170+
error
171+
);
172+
}
173+
});
174+
}

0 commit comments

Comments
 (0)