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

Nest plugin cli commands #405

Merged
merged 3 commits into from
Aug 23, 2023
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
5 changes: 5 additions & 0 deletions .changeset/great-foxes-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webstone-plugin-request-logger": minor
---

Migrate to the new plugins CLI command structure.
5 changes: 5 additions & 0 deletions .changeset/sharp-ants-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-webstone-app": minor
---

Group plugin commands under a "plugins" sub-command.
31 changes: 12 additions & 19 deletions .config/devbox/scripts/dev-app-configure-and-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,35 @@ set -e
(
if [ ! -d "_dev-app" ]
then
node ./packages/create-webstone-app/bin.js _dev-app --type=application
node ./packages/create-webstone-app/bin.js _dev-app --type=app
fi
cd _dev-app
echo "⏳ Waiting for the CLI's binary to be built..."
while [ ! -f ../packages/cli/dist/bin.js ]; do sleep 1; done
pnpm add -D ../packages/cli
npm install -D ../packages/cli
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching this to npm rather than pnpm so it doesn't pollute the root-level pnpm-lock.yaml file.

Even if we exclude the _dev-app package in pnpm-workspace.yaml, running pnpm commands updates the root-level pnpm-lock.yaml.


# Install all plugin-*/ packages
for FILE in $(find ../packages/plugin-*/package.json)
do
DIR=`dirname $FILE`
npm install -D $DIR
done

# Install all plugin-*/cli packages (without nested monorepo)
# This is for the plugin-trpc package. If / when we migrate that to a monorepo, we can remove this code
for FILE in $(find ../packages/plugin-*/cli/package.json)
do
DIR=`dirname $FILE`
pnpm add -D $DIR
npm install -D $DIR
done

# Install all plugin-*/web packages (without nested monorepo)
# This is for the plugin-trpc package. If / when we migrate that to a monorepo, we can remove this code
for FILE in $(find ../packages/plugin-*/web/package.json)
do
DIR=`dirname $FILE`
pnpm add -D $DIR
done

# Install all plugin-*/cli packages (with nested monorepo)
for FILE in $(find ../packages/plugin-*/packages/cli/package.json)
do
DIR=`dirname $FILE`
pnpm add -D $DIR
done

# Install all plugin-*/web packages (with nested monorepo)
for FILE in $(find ../packages/plugin-*/packages/web/package.json)
do
DIR=`dirname $FILE`
pnpm add -D $DIR
npm install -D $DIR
done

pnpm ws dev
npx ws dev
)
2 changes: 1 addition & 1 deletion packages/create-webstone-app/src/functions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe("copyCLIExtension", () => {
//Commands
deepStrictEqual(
mockCopySync.mock.calls[0].arguments[1],
"dummy/src/cli/commands/dummy/hello-world.ts",
"dummy/src/cli/commands/plugins/dummy/hello-world.ts",
);

// Extensions
Expand Down
2 changes: 1 addition & 1 deletion packages/create-webstone-app/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function copyCLIExtension(cwd: string) {
fs.copySync(
new URL("../templates/plugin-structure/command.ts", import.meta.url)
.pathname,
`${cwd}/src/cli/commands/${getRawAppName(cwd)}/hello-world.ts`,
`${cwd}/src/cli/commands/plugins/${getRawAppName(cwd)}/hello-world.ts`,
);

//copy extension
Expand Down
33 changes: 5 additions & 28 deletions pnpm-lock.yaml

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