Skip to content

Commit

Permalink
Remove build:*:skippable scripts (#1785)
Browse files Browse the repository at this point in the history
The `build:*:skippable` scripts we added to improve startup performance
are very buggy. A better approach to developing is building all Comet
packages at least once and then only start what's needed. We update the
README to reflect this approach.

Also, we now promote using the dev-process-manager to start individual
processes over using the `dev:*` scripts. Having the ability to start
individual processes and process groups is superior when compared to
starting many processes where only a subset is actually needed.

---------

Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
  • Loading branch information
johnnyomair and thomasdax98 authored Mar 6, 2024
1 parent 8ce21f3 commit 63e9d26
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: pnpm run copy-schema-files

- name: Build
run: pnpm run build:lib
run: pnpm run build:packages

- name: Lint
run: |
Expand Down
89 changes: 73 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,76 @@ sh install.sh

_It is recommended to run `install.sh` every time you switch to the `main` branch._

### Build packages

Before starting individual development processes, build all Comet packages at least once.

```bash
pnpm run build:packages
```

_It is recommended to build all packages every time you switch to the `main` branch._

### Start development processes

[dev-process-manager](https://github.com/vivid-planet/dev-process-manager) is used for local development.
We recommend only running the development process you will need.
Typically, you will need a subset of the available development processes.

Start Comet Admin packages
Here are a few examples:

```bash
pnpm run dev:admin
```
1. You want to add a new component to `@comet/admin`

Start CMS packages
Start the development process for `@comet/admin`:

```bash
pnpm run dev:cms
```
```bash
npx dev-pm start @comet-admin
```

It is also possbile to start specific microservices
Create a development story in Storybook:

```bash
pnpm run dev:cms:api # (api|admin|site)
```
```bash
pnpm run storybook
```

2. You want to add a CMS feature to the API

Start the development process for `@comet/cms-api`:

```bash
npx dev-pm start @cms-api
```

Start Demo API:

```bash
npx dev-pm start @demo-api
```

The Demo API will be available at [http://localhost:4000/](http://localhost:4000/)

3. You want to add a CMS feature to the Admin

Start the development process for `@comet/cms-admin`:

```bash
npx dev-pm start @cms-admin
```

Start Demo API and Admin:

```bash
npx dev-pm start @demo-api @demo-admin
```

The Demo Admin will be available at [http://localhost:8000/](http://localhost:8000/)

See [dev-pm.config.js](/dev-pm.config.js) for a list of all available processes and process groups.

#### Start Demo

```bash
pnpm run dev:demo
npx dev-pm start @demo
```

Demo will be available at
Expand All @@ -68,10 +112,10 @@ Demo will be available at
- API: [http://localhost:4000/](http://localhost:4000/)
- Site: [http://localhost:3000/](http://localhost:3000/)

It is also possbile to start specific microservices
It is also possible to start specific microservices

```bash
pnpm run dev:demo:api # (api|admin|site)
npx dev-pm start @demo-api # (@demo-api|@demo-admin|@demo-site)
```

#### Start Storybook
Expand All @@ -90,12 +134,25 @@ pnpm run docs

The docs will be available at [http://localhost:3000/](http://localhost:3000/)

### Stop Processes
### Stop processes

```bash
npx dev-pm shutdown
```

### Dev scripts

We provide `dev:*` scripts for the most common use cases.
For example, to start the Demo, you can also run:

```bash
pnpm run dev:demo
```

However, we recommend directly using dev-process-manager for greater control over which development processes to start.

See [package.json](/package.json) for a list of all available dev scripts.

## Develop in a project

### additional Requirements
Expand Down
35 changes: 12 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,20 @@
},
"license": "BSD-2-Clause",
"scripts": {
"build": "pnpm recursive run build",
"build:admin": "pnpm recursive --filter '@comet/admin*' run build",
"build:admin:skippable": "test -f packages/admin/admin/lib/index.d.ts && echo 'Skipping Admin build' || $npm_execpath build:admin",
"build:cms": "pnpm recursive --filter '@comet/cms*' --filter '@comet/blocks*' run build",
"build:cms:admin": "pnpm recursive --filter '@comet/cms-admin' --filter '@comet/blocks-admin' run build",
"build:cms:admin:skippable": "test -f packages/admin/cms-admin/lib/index.d.ts && echo 'Skipping CMS Admin build' || $npm_execpath build:cms:admin",
"build:cms:api": "pnpm recursive --filter '@comet/cms-api' --filter '@comet/blocks-api' run build",
"build:cms:api:skippable": "test -f packages/api/cms-api/lib/index.d.ts && echo 'Skipping CMS API build' || $npm_execpath build:cms:api",
"build:cms:site": "pnpm recursive --filter '@comet/cms-site' run build",
"build:cms:site:skippable": "test -f packages/site/cms-site/lib/index.d.ts && echo 'Skipping CMS Site build' || $npm_execpath build:cms:site",
"build:cms:skippable": "test -f packages/admin/cms-admin/lib/index.d.ts && echo 'Skipping CMS build' || $npm_execpath build:cms",
"build:storybook": "pnpm recursive --filter '@comet/admin*' --filter '@comet/eslint-plugin' run build && pnpm --filter comet-storybook run build-storybook",
"build:lib": "pnpm recursive --filter '@comet/*' run build",
"build:packages": "pnpm recursive --filter '@comet/*' run build",
"build:docs": "pnpm recursive --filter '@comet/eslint-plugin' --filter '@comet/admin*' --filter 'comet-docs' run build",
"clean": "pnpm recursive run clean",
"copy-schema-files": "node copy-schema-files.js",
"dev:admin": "pnpm recursive --filter '@comet/admin*' run clean && dotenv -c -- dev-pm start @comet-admin",
"dev:cms": "pnpm recursive --filter '@comet/cms*' run clean && $npm_execpath build:admin:skippable && dotenv -c -- dev-pm start @cms",
"dev:cms:admin": "pnpm recursive --filter '@comet/cms-admin' --filter '@comet/blocks-admin' run clean && $npm_execpath build:admin:skippable && dotenv -c -- dev-pm start @cms-admin",
"dev:cms:api": "pnpm recursive --filter '@comet/cms-api' --filter '@comet/blocks-api' run clean && dotenv -c -- dev-pm start @cms-api",
"dev:cms:site": "pnpm recursive --filter '@comet/cms-site' run clean && dotenv -c -- dev-pm start @cms-site",
"dev:demo": "$npm_execpath build:admin:skippable && $npm_execpath build:cms:skippable && dotenv -c -- dev-pm start @demo",
"dev:demo:admin": "$npm_execpath build:admin:skippable && $npm_execpath build:cms:admin:skippable && dotenv -c -- dev-pm start @demo-admin",
"dev:demo:api": "$npm_execpath build:cms:api:skippable && dotenv -c -- dev-pm start @demo-api",
"dev:demo:site": "$npm_execpath build:cms:site:skippable && dotenv -c -- dev-pm start @demo-site",
"dev:admin": "dev-pm start @comet-admin",
"dev:cms": "dev-pm start @cms",
"dev:cms:admin": "dev-pm start @cms-admin",
"dev:cms:api": "dev-pm start @cms-api",
"dev:cms:site": "dev-pm start @cms-site",
"dev:demo": "dev-pm start @demo",
"dev:demo:admin": "dev-pm start @demo-admin",
"dev:demo:api": "dev-pm start @demo-api",
"dev:demo:site": "dev-pm start @demo-site",
"postinstall": "husky install",
"intl:extract": "formatjs extract './packages/admin/**/*.ts*' --out-file 'lang/en.json' --ignore './**.d.ts' --ignore './**.d.ts.map' --format simple --throws",
"lint": "pnpm recursive run lint",
Expand All @@ -41,10 +30,10 @@
"docs": "pnpm --filter ./docs run start",
"test": "pnpm recursive run test",
"version": "$npm_execpath changeset version && pnpm install --lockfile-only",
"publish": "pnpm run build:lib && $npm_execpath changeset publish"
"publish": "pnpm run build:packages && $npm_execpath changeset publish"
},
"devDependencies": {
"@comet/dev-process-manager": "^2.3.2",
"@comet/dev-process-manager": "^2.5.1",
"@comet/eslint-plugin": "workspace:*",
"@formatjs/cli": "^4.8.3",
"@types/node": "^18.0.0",
Expand Down
Loading

0 comments on commit 63e9d26

Please sign in to comment.