Skip to content

Commit

Permalink
refactor: remove monorepo approach (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cahllagerfeld authored Sep 25, 2022
1 parent 21cb899 commit f7a4f1f
Show file tree
Hide file tree
Showing 42 changed files with 244 additions and 403 deletions.
6 changes: 6 additions & 0 deletions .changeset/tricky-flies-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@webstone/cli": minor
"create-webstone-app": minor
---

remove monorepo approach
4 changes: 2 additions & 2 deletions .gitpod/tasks/2-app-dev/command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

cd webstone-dev-app
while [ ! -f ../webstone/packages/cli/dist/bin.js ]; do sleep 1; done
pnpm add -w -D ../webstone/packages/cli
pnpm add -D ../webstone/packages/cli
export HMR_HOST=`gp url 5173`
pnpm ws dev gitpod web-patch-svelte-config-js
pnpm ws dev
pnpm ws dev
4 changes: 2 additions & 2 deletions packages/cli/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Creates new API **C**reate, **R**ead, **U**pdate, **D**elete (CRUD) endpoints in
webstone web api create [api-path]
```

- `[api-path]` - The URL path of the API endpoints to create. For example, `/api/users` generates CRUD endpoints in `services/web/src/routes/api/users/`. If no API path is provided, you will be prompted to provide one interactively.
- `[api-path]` - The URL path of the API endpoints to create. For example, `/api/users` generates CRUD endpoints in `src/routes/api/users/`. If no API path is provided, you will be prompted to provide one interactively.

### webstone web api delete

Expand All @@ -71,7 +71,7 @@ Deletes an API endpoint in your `web` service. E.g.`/api/users`.
webstone web api delete [api-path]
```

- `[api-path]` - The URL path of the API endpoints to delete. For example, `/api/users` deletes all endpoints in `services/web/src/routes/api/users/`. If no API path is provided, you will be prompted to provide one interactively.
- `[api-path]` - The URL path of the API endpoints to delete. For example, `/api/users` deletes all endpoints in `src/routes/api/users/`. If no API path is provided, you will be prompted to provide one interactively.

### webstone web deployment configure

Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
}
},
"license": "MIT",
"dependencies": {
"gluegun": "^4.7.1"
},
"devDependencies": {
"npm-watch": "^0.11.0"
},
"dependencies": {
"@webstone/gluegun": "^0.0.4"
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WebstoneToolbox } from "./extensions/web";
import { build } from "gluegun";
import { build } from "@webstone/gluegun";

export const run = async () => {
const cli = build()
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: ["d"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
hidden: true,
run: async (toolbox) => {
const { patching, print } = toolbox;
const fileToPatch = "services/web/vite.config.ts";
const fileToPatch = "vite.config.ts";
print.info(`Patching ${fileToPatch}...`);
await patching.patch(fileToPatch, {
insert: `,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/web/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: "a",
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/web/api/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: ["c"],
Expand All @@ -22,18 +22,18 @@ const command: GluegunCommand = {
}

const filePath = apiPath.toLowerCase().replace(/^\//, "");
const targetDir = `services/web/src/routes/${filePath}`;
const targetDir = `src/routes/${filePath}`;

if (filesystem.exists(targetDir) === "dir") {
print.info(`The ${apiPath} API endpoint already exists.`);
return;
}

const spinner = print.spin(`Creating API endpoint at "${targetDir}"...`);
if (filesystem.exists("services/web/src/lib/types.d.ts") !== "file") {
if (filesystem.exists("src/lib/types.d.ts") !== "file") {
await template.generate({
template: "web/api/create/lib-types.d.ejs",
target: "services/web/src/lib/types.d.ts",
target: "src/lib/types.d.ts",
props: {
apiPath,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/web/api/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: ["d"],
Expand All @@ -22,7 +22,7 @@ const command: GluegunCommand = {
}

const filePath = apiPath.toLowerCase().replace(/^\//, "");
const targetDir = `services/web/src/routes/${filePath}`;
const targetDir = `src/routes/${filePath}`;

const spinner = print.spin(`Removing API endpoint at "${targetDir}"...`);
filesystem.remove(targetDir);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/web/deployment/configure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GluegunCommand } from "gluegun";
import type { GluegunCommand } from "@webstone/gluegun";
import type { WebstoneToolbox } from "../../../extensions/web";

const command: GluegunCommand = {
Expand Down Expand Up @@ -48,7 +48,7 @@ const command: GluegunCommand = {

if (!installedAdapter) {
print.error(
`An adapter should be installed, but isn't... This is an unexpected error, please manually review the "services/web/package.json file."`
`An adapter should be installed, but isn't... This is an unexpected error, please manually review the "package.json file."`
);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/web/deployment/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { WebstoneToolbox } from "../../../extensions/web";

import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: ["d"],
Expand All @@ -17,12 +17,12 @@ const command: GluegunCommand = {
}

const buildSpinner = print.spin(`Building the web service...`);
await system.run(`pnpm build --filter ./services/web`);
await system.run(`pnpm build`);
buildSpinner.succeed();

if (parameters.options.preview) {
print.info(`Previewing the web service...`);
await system.exec(`pnpm preview --filter ./services/web`, {
await system.exec(`pnpm preview`, {
stdout: "inherit",
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/web/deployment/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
description: "No-op entry for the `webstone web deployment` command.",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/web/dev/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: ["d"],
Expand All @@ -7,7 +7,7 @@ const command: GluegunCommand = {
const { print, system } = toolbox;

print.info(`Starting web service...`);
await system.exec(`pnpm run dev --filter ./services/web`, {
await system.exec(`pnpm run dev`, {
stdout: "inherit",
});
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/web/page/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: ["c"],
Expand All @@ -22,7 +22,7 @@ const command: GluegunCommand = {
}

const filename = strings.kebabCase(name);
const target = `services/web/src/routes/${filename}/+page.svelte`;
const target = `src/routes/${filename}/+page.svelte`;
const spinner = print.spin(`Creating page "${target}"...`);

await template.generate({
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/web/page/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: ["d"],
Expand All @@ -22,7 +22,7 @@ const command: GluegunCommand = {
}

const filename = strings.kebabCase(name);
const target = `services/web/src/routes/${filename}`;
const target = `src/routes/${filename}`;
const spinner = print.spin(`Removing page "${target}"...`);
filesystem.remove(target);
spinner.succeed(`Page deleted at: ${target}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/web/page/page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: "p",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/web/svelte-add.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

/**
* This is a wrapper for `npx svelte-add@latest <integration>`.
Expand All @@ -22,7 +22,7 @@ const command: GluegunCommand = {
const svelteAddCommand = `npx svelte-add@latest ${parameters.first}`;
print.highlight(`Delegating to svelte-add: ${svelteAddCommand}`);
const result = await system.run(svelteAddCommand, {
cwd: "./services/web",
cwd: "./",
});
print.info(result);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/web/web.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
alias: "w",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/webstone.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GluegunCommand } from "gluegun";
import { GluegunCommand } from "@webstone/gluegun";

const command: GluegunCommand = {
description: "No-op entry for the webstone CLI",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/extensions/pnpm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GluegunToolbox } from "gluegun";
import type { GluegunToolbox } from "@webstone/gluegun";

import add from "../toolbox/pnpm/add";
import remove from "../toolbox/pnpm/remove";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/extensions/web.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GluegunToolbox } from "gluegun";
import type { GluegunToolbox } from "@webstone/gluegun";
import type { WebToolbox } from "./web/types";

import webConfigureDeployment from "./web/deployment/configure";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/toolbox/pnpm/add.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PnpmOptions } from "./types";

import { system } from "gluegun";
import { system } from "@webstone/gluegun";

export default async (packageName: string, options?: PnpmOptions) => {
const dev = options?.dev ? "-D " : "";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/toolbox/pnpm/remove.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PnpmOptions } from "./types";

import { system } from "gluegun";
import { system } from "@webstone/gluegun";

export default async (packageName: string, options?: PnpmOptions) => {
const dev = options?.dev ? "-D " : "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { filesystem } from "gluegun";
import { filesystem } from "@webstone/gluegun";
import { availableAdapters } from "./adapters";
import { Adapter } from "./types";

export default () => {
const webPackageJson = filesystem.read("./services/web/package.json", "json");
const webPackageJson = filesystem.read("./package.json", "json");
const availableAdapterNpmPackages = availableAdapters.map(
(adapter) => adapter.npmPackage
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Adapter } from "./types";

import { print } from "gluegun";
import { print } from "@webstone/gluegun";
import add from "../../../pnpm/add";

export default async (adapter: Adapter) => {
Expand All @@ -11,7 +11,7 @@ export default async (adapter: Adapter) => {
);
await add(`${adapter.npmPackage}${adapter.npmPackageVersion || ""}`, {
dev: true,
dir: "./services/web",
dir: "./",
});
spinner.succeed(`Adapter added: ${adapter.npmPackage}`);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Adapter } from "./types";

import { print } from "gluegun";
import { print } from "@webstone/gluegun";
import remove from "../../../pnpm/remove";

export default async (adapter: Adapter) => {
Expand All @@ -9,7 +9,7 @@ export default async (adapter: Adapter) => {
);
await remove(adapter.npmPackage, {
dev: true,
dir: "./services/web",
dir: "./",
});
spinner.succeed(`Adapter removed: ${adapter.npmPackage}`);
};
2 changes: 1 addition & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dom"
],
"outDir": "dist",
"target": "es5",
"target": "ES6",
},
"include": ["src/**/*"],
"extends": "../../tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-webstone-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"chalk": "5.0.1",
"create-svelte": "2.0.0-next.177",
"create-svelte": "2.0.0-next.179",
"enquirer": "2.3.6",
"execa": "6.1.0",
"fs-extra": "10.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/create-webstone-app/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ListrTaskWrapper, ListrRenderer } from "listr2/dist/index";

export interface Ctx {
appDir: string;
webAppDir?: string;
}

export type WebstoneTask = ListrTaskWrapper<Ctx, typeof ListrRenderer>;
Expand Down

This file was deleted.

Loading

0 comments on commit f7a4f1f

Please sign in to comment.