Skip to content

(Windows) build issues and contributing docs #1458

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

Merged
merged 10 commits into from
May 26, 2024
Merged
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf

*.bat text=auto eol=crlf
16 changes: 15 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -5,10 +5,24 @@ I want to think you first for considering contributing to ZenStack 🙏🏻. It'
## Prerequisites

- [Node.js](https://nodejs.org/): v18 or above
- [pnpm](https://pnpm.io/): latest version
- [pnpm](https://pnpm.io/): v8.x

If you want to run the tests, you should be aware that some of the integration tests run against postgres. These tests will attempt to set up and subsequently their own database, so you'll need to provide a connection details for a postgres user with at least those permissions. To provide connection details, you can configure the following environment variables or provide them when executing `pnpm test` commands.

- `ZENSTACK_TEST_DB_USER`: The postgres username, for a user with permission to create/drop databases. Default: `postgres`.
- `ZENSTACK_TEST_DB_PASS`: Password for said user. Default: `abc123`.
- `ZENSTACK_TEST_DB_NAME`: Default database to connect onto. This database isn't used any further, so it's recommended to just use the default `postgres` database. Default: `postgres`.
- `ZENSTACK_TEST_DB_HOST`: Hostname or IP to connect onto. Default: `localhost`.
- `ZENSTACK_TEST_DB_PORT`: Port number to connect onto. Default: `5432`.

## Get started

1. (Windows only) Your environment should support symlinks, by enabling "Developer mode" in `Settings => System => For developers` (Windows 10/11 only) and setting the `core.symlinks` setting in git to `true`. For more info [refer to this StackOverflow answer](https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201#59761201).

```pwsh
git config --global core.symlinks true
```
1. Make a fork of the repository
Make sure all branches are included.
9 changes: 6 additions & 3 deletions packages/ide/jetbrains/package.json
Original file line number Diff line number Diff line change
@@ -6,12 +6,15 @@
"homepage": "https://zenstack.dev",
"private": true,
"scripts": {
"build": "./gradlew buildPlugin"
"build": "run-script-os",
"build:win32": "gradlew.bat buildPlugin",
"build:default": "./gradlew buildPlugin"
},
"author": "ZenStack Team",
"license": "MIT",
"devDependencies": {
"zenstack": "workspace:*",
"@zenstackhq/language": "workspace:*"
"@zenstackhq/language": "workspace:*",
"run-script-os": "^1.1.6",
"zenstack": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"generate": "langium generate && npx ts-node script/generate-plist.ts",
"watch": "concurrently \"langium generate --watch\" \"tsc --watch\"",
"lint": "eslint src --ext ts",
"build": "pnpm lint --max-warnings=0 && pnpm clean && pnpm generate && tsc && copyfiles -F ./README.md ./LICENSE ./package.json 'syntaxes/**/*' dist && pnpm pack dist --pack-destination ../../../.build",
"build": "pnpm lint --max-warnings=0 && pnpm clean && pnpm generate && tsc && copyfiles -F ./README.md ./LICENSE ./package.json \"syntaxes/**/*\" dist && pnpm pack dist --pack-destination ../../../.build",
"prepublishOnly": "pnpm build"
},
"publishConfig": {
2 changes: 1 addition & 1 deletion packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
},
"scripts": {
"clean": "rimraf dist",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE 'res/**/*' dist && pnpm pack dist --pack-destination ../../../../.build",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE \"res/**/*\" dist && pnpm pack dist --pack-destination ../../../../.build",
"watch": "tsc --watch",
"lint": "eslint src --ext ts",
"test": "jest",
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
},
"scripts": {
"clean": "rimraf dist",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && tsup-node --config ./tsup-browser.config.ts && tsup-node --config ./tsup-cross.config.ts && copyfiles ./package.json ./README.md ../../LICENSE dist && copyfiles -u1 'res/**/*' dist && pnpm pack dist --pack-destination '../../../.build'",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && tsup-node --config ./tsup-browser.config.ts && tsup-node --config ./tsup-cross.config.ts && copyfiles ./package.json ./README.md ../../LICENSE dist && copyfiles -u1 \"res/**/*\" dist && pnpm pack dist --pack-destination ../../../.build",
"watch": "concurrently \"tsc --watch\" \"tsup-node --config ./tsup-browser.config.ts --watch\" \"tsup-node --config ./tsup-cross.config.ts --watch\"",
"lint": "eslint src --ext ts",
"prepublishOnly": "pnpm build"
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@
"vscode:prepublish": "pnpm bundle",
"vscode:package": "pnpm bundle && vsce package --no-dependencies",
"clean": "rimraf dist",
"build": "pnpm clean && pnpm lint --max-warnings=0 && tsc && copyfiles -F \"bin/*\" dist && copyfiles ./README-global.md ./LICENSE ./package.json dist && renamer --replace \"README.md\" dist/README-global.md && copyfiles -u 1 \"src/res/*\" dist && node build/post-build.js && pnpm pack dist --pack-destination '../../../.build'",
"build": "pnpm clean && pnpm lint --max-warnings=0 && tsc && copyfiles -F \"bin/*\" dist && copyfiles ./README-global.md ./LICENSE ./package.json dist && renamer --replace \"README.md\" dist/README-global.md && copyfiles -u 1 \"src/res/*\" dist && node build/post-build.js && pnpm pack dist --pack-destination ../../../.build",
"bundle": "rimraf bundle && pnpm lint --max-warnings=0 && node build/bundle.js --minify",
"watch": "tsc --watch",
"lint": "eslint src tests --ext ts",
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
"scripts": {
"clean": "rimraf dist",
"lint": "eslint src --ext ts",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./LICENSE ./README.md dist && pnpm pack dist --pack-destination '../../../.build'",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./LICENSE ./README.md dist && pnpm pack dist --pack-destination ../../../.build",
"watch": "tsc --watch",
"prepublishOnly": "pnpm build"
},
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
"homepage": "https://zenstack.dev",
"scripts": {
"clean": "rimraf dist",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../.build'",
"build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination ../../../.build",
"watch": "tsc --watch",
"lint": "eslint src --ext ts",
"test": "jest",
2 changes: 1 addition & 1 deletion packages/testtools/package.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"scripts": {
"clean": "rimraf dist",
"lint": "eslint src --ext ts",
"build": "pnpm lint && pnpm clean && tsc && copyfiles ./package.json ./LICENSE ./README.md dist && pnpm pack dist --pack-destination '../../../.build'",
"build": "pnpm lint && pnpm clean && tsc && copyfiles ./package.json ./LICENSE ./README.md dist && pnpm pack dist --pack-destination ../../../.build",
"watch": "tsc --watch",
"prepublishOnly": "pnpm build"
},
25 changes: 20 additions & 5 deletions packages/testtools/src/db.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import { Pool } from 'pg';

const USERNAME = 'postgres';
const PASSWORD = 'abc123';
const USERNAME = process.env.ZENSTACK_TEST_DB_USER || 'postgres';
const PASSWORD = process.env.ZENSTACK_TEST_DB_PASS || 'abc123';
const CONNECTION_DB = process.env.ZENSTACK_TEST_DB_NAME || 'postgres';
const HOST = process.env.ZENSTACK_TEST_DB_HOST || 'localhost';
const PORT = (process.env.ZENSTACK_TEST_DB_PORT ? parseInt(process.env.ZENSTACK_TEST_DB_PORT) : null) || 5432;

function connect() {
return new Pool({
user: USERNAME,
password: PASSWORD,
database: CONNECTION_DB,
host: HOST,
port: PORT
});
}

export async function createPostgresDb(db: string) {
const pool = new Pool({ user: USERNAME, password: PASSWORD });
const pool = connect();
await pool.query(`DROP DATABASE IF EXISTS "${db}";`);
await pool.query(`CREATE DATABASE "${db}";`);
return `postgresql://${USERNAME}:${PASSWORD}@localhost:5432/${db}`;
await pool.end();
return `postgresql://${USERNAME}:${PASSWORD}@${HOST}:${PORT}/${db}`;
}

export async function dropPostgresDb(db: string) {
const pool = new Pool({ user: USERNAME, password: PASSWORD });
const pool = connect();
await pool.query(`DROP DATABASE IF EXISTS "${db}";`);
await pool.end();
}
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

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