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

Monorepo setup and fix some inteded bug cases. #1135

Merged
merged 10 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
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 .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Before submitting a Pull Request, please test your code.
If you created a new created a new feature, then create the unit test function, too.

```bash
# INSTALL PACKAGES
pnpm install

# COMPILE THE BACKEND SERVER
npm run build

Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: build
on:
push:
paths:
- '.github/workflows/build.yml'
- 'packages/{core,fetcher,sdk}/src/**'
- 'packages/{core,fetcher,sdk}/package.json'
- 'test/**'
- 'test/package.json'
pull_request:
paths:
- 'packages/*/src/**'
- 'packages/*/package.json'
- '.github/workflows/build.yml'
- 'packages/{core,fetcher,sdk}/src/**'
- 'packages/{core,fetcher,sdk}/package.json'
- 'test/**'
- 'test/package.json'

Expand All @@ -21,6 +23,12 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20.x
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Install dependencies
run: pnpm install

- name: test
working-directory: ./test
Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/migrate.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: build
name: migrate
on:
push:
paths:
- '.github/workflows/migrate.yaml'
- 'packages/migrate/assets/input/*.json'
- 'packages/migrate/src/**'
- 'packages/migrate/test/**'
- 'packages/migrate/package.json'
pull_request:
paths:
- 'packages/*/src/**'
- 'packages/*/package.json'
- 'test/**'
- 'test/package.json'
- '.github/workflows/migrate.yaml'
- 'packages/migrate/assets/input/*.json'
- 'packages/migrate/src/**'
- 'packages/migrate/test/**'
- 'packages/migrate/package.json'

jobs:
Ubuntu:
Expand All @@ -21,7 +23,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20.x
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Install dependencies
run: pnpm install && npm run build
- name: Build
working-directory: ./packages/migrate
run: npm run build
- name: test
working-directory: ./test
run: npm start
working-directory: ./packages/migrate
run: npm run test
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: release
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Install dependencies
run: pnpm install
- name: Publish to npm
run: npm run package:latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}
- name: Website
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ./website/out
8 changes: 6 additions & 2 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
paths:
- '.github/workflows/website.yml'
- 'website/**'
- 'website/package.json'
jobs:
Expand All @@ -14,8 +15,11 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Root Install
run: npm run package:tgz
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Root Setup
run: pnpm install && npm run build
- name: Build
working-directory: website
run: npm install && npm run build
Expand Down
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/core": "^4.0.0",
"@nestia/core": "workspace:^",
"@nestjs/common": "^10.3.7",
"@nestjs/core": "^10.3.7",
"@nestjs/platform-express": "^10.3.7",
Expand Down
32 changes: 0 additions & 32 deletions build/index.js

This file was deleted.

26 changes: 26 additions & 0 deletions deploy/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const cp = require("child_process");

const execute = (name) => {
console.log("=========================================");
console.log(` Build @nestia/${name}`);
console.log("=========================================");

process.chdir(`${__dirname}/../packages/${name}`);

cp.execSync("pnpm install", { stdio: "inherit" });
cp.execSync("npm run build", { stdio: "inherit" });
};

const build = async (packages) => {
for (const pack of packages ?? [
"fetcher",
"core",
"sdk",
"e2e",
"cli",
"benchmark",
])
await execute(pack);
};

module.exports = { build };
26 changes: 22 additions & 4 deletions deploy/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
const { version } = require("../package.json");
const { build } = require("./build");
const { migrate } = require("./migrate");
const { publish } = require("./publish");

const tag = process.argv[2];
if (tag !== "latest" && tag !== "next" && tag !== "tgz")
throw new Error("Invalid tag");
publish(tag);
const main = async () => {
await build();
if (process.argv[2] === "publish") {
const index = process.argv.indexOf("--tag");
const tag = index === -1 ? "next" : process.argv[index + 1];
await publish({
tag,
version: (name) =>
["fetcher", "core", "sdk"].includes(name) ? version : null,
packages: ["fetcher", "core", "sdk"],
});
if (tag === "latest" || process.argv.includes("--migrate"))
await migrate(tag);
}
};
main().catch((error) => {
console.error(error);
process.exit(-1);
});
38 changes: 38 additions & 0 deletions deploy/migrate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const cp = require("child_process");

const { build } = require("./build");
const { publish } = require("./publish");

const { version: stationVersion } = require("../package.json");
const { version: migrateVersion } = require("../packages/migrate/package.json");
const { version: editorVersion } = require("../packages/editor/package.json");

const website = async () => {
console.log("=========================================");
console.log(` Publish @nestia/website`);
console.log("=========================================");

for (const script of ["npm install", "npm run build"])
cp.execSync(script, {
cwd: `${__dirname}/../website`,
stdio: "inherit",
});
};

const migrate = async (tag) => {
await build(["migrate", "editor"]);
await publish({
tag,
packages: ["migrate", "editor"],
version: (name) =>
name === "migrate"
? migrateVersion
: name === "editor"
? editorVersion
: ["fetcher", "core", "sdk"].includes(name)
? stationVersion
: null,
});
await website();
};
module.exports = { migrate };
Loading
Loading