Skip to content

Commit f410fd8

Browse files
committed
📖 DOC: Contributing guidelines
1 parent ac10bf5 commit f410fd8

File tree

3 files changed

+94
-3
lines changed

3 files changed

+94
-3
lines changed

.github/scripts/update-examples.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {execSync} from 'child_process';
2+
import fs from 'fs';
3+
import path from 'path';
4+
import {fileURLToPath} from 'url';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
9+
const examplesDir = path.join(__dirname, '..', '..', 'examples');
10+
11+
function installDependencies(packageDir) {
12+
console.log(`Installing dependencies in ${packageDir}`);
13+
try {
14+
execSync('pnpm i langbase@latest', {
15+
cwd: packageDir,
16+
stdio: 'inherit',
17+
});
18+
console.log(`Successfully installed dependencies in ${packageDir}`);
19+
} catch (error) {
20+
console.error(
21+
`Error installing dependencies in ${packageDir}:`,
22+
error.message,
23+
);
24+
}
25+
}
26+
27+
function processExamples() {
28+
if (!fs.existsSync(examplesDir)) {
29+
console.error('Examples directory not found');
30+
return;
31+
}
32+
33+
const entries = fs.readdirSync(examplesDir, {withFileTypes: true});
34+
35+
for (const entry of entries) {
36+
if (entry.isDirectory()) {
37+
const packageDir = path.join(examplesDir, entry.name);
38+
const packageJsonPath = path.join(packageDir, 'package.json');
39+
40+
if (fs.existsSync(packageJsonPath)) {
41+
installDependencies(packageDir);
42+
} else {
43+
console.log(`Skipping ${entry.name}: No package.json found`);
44+
}
45+
}
46+
}
47+
}
48+
49+
processExamples();

CONTRIBUTING.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,52 @@
22

33
We welcome contributions to this project.
44

5+
---
6+
7+
## Releasing a snapshot version
8+
9+
To release a snapshot version to test changes, run the following command:
10+
11+
```bash
12+
npm run snapshot
13+
```
14+
515
## Releasing a new version
616

717
```bash
8-
# Bug, have to remove example pkg json changes.
918
pnpm changeset
10-
pnpm version-packages && grlz 'new version'
19+
pnpm version-packages
20+
grlz 'new version'
1121
pnpm release
22+
pnpm update-examples
1223
```
24+
25+
## Testing locally
26+
27+
To test the changes locally, you can run the following command:
28+
29+
- Navigate to an example's folder like the Next.js one in `examples/nextjs`.
30+
31+
- Change the `package.json` to point to the local package for `langbase`.
32+
33+
```json
34+
{
35+
"dependencies": {
36+
"langbase": "workspace:*"
37+
},
38+
}
39+
```
40+
41+
- Now run in the root:
42+
43+
```bash
44+
pnpm clean-all && pnpm install
45+
```
46+
47+
Then run the development server:
48+
49+
```bash
50+
pnpm dev
51+
```
52+
53+
By doing this, the Next.js example will use the local packages instead of the published ones.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"ci:release": "turbo clean && turbo build && changeset publish",
2525
"clean-examples": "node .github/scripts/cleanup-examples-changesets.mjs",
2626
"ci:version": "changeset version && node .github/scripts/cleanup-examples-changesets.mjs && pnpm install --no-frozen-lockfile",
27-
"snapshot": "node .github/scripts/release-snapshot.js"
27+
"snapshot": "node .github/scripts/release-snapshot.js",
28+
"update-examples": "npx tsx .github/scripts/update-examples.ts"
2829
},
2930
"devDependencies": {
3031
"@langbase/eslint-config": "workspace:*",

0 commit comments

Comments
 (0)