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

Create Core-Plugin #281

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Cahllagerfeld
Copy link
Member

closes #280

@changeset-bot
Copy link

changeset-bot bot commented Nov 12, 2022

⚠️ No Changeset found

Latest commit: 6534a62

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member Author

@Cahllagerfeld Cahllagerfeld left a comment

Choose a reason for hiding this comment

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

I created the packages in a subdirectory, and not in a nested monorepo, because I think it's not required, as we are already having a parent directory. Let me know what you think about it!

@mikenikles
Copy link
Collaborator

mikenikles commented Nov 12, 2022

Nice, I like the plugin-* naming convention within our monorepo.

This means we can delete packages/core.

Update: I take it we use the same naming convention for all plugins we release, agreed? E.g. plugin-trpc, plugin-stripe, etc.

@Cahllagerfeld
Copy link
Member Author

I take it we use the same naming convention for all plugins we release, agreed? E.g. plugin-trpc, plugin-stripe, etc.

Yeah sure 👍 The only thing that made me think, is that the packages are living not in a nested monorepo, but just in a subdirectory, but that's fine I guess 👍

@Cahllagerfeld
Copy link
Member Author

There seems to be an issue with the pre-commit hook in husky, caused by a recursive script in packages/plugin-core/web

@@ -29,7 +29,7 @@
"changeset": "changeset && pnpm install",
"clean": "pnpm --recursive --parallel clean",
"clean:nodemodules": "find . -type d -name \"node_modules\" -exec rm -fr {} +",
"dev": "pnpm --recursive --parallel dev",
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed these packages, so they don't start the dev server with all packages, we can remove that filter again though :)

@@ -55,6 +55,24 @@ export const createCliNamespace = (ctx: Ctx) => {
getAppName(ctx.appDir)
)
);
fs.renameSync(
Copy link
Member Author

Choose a reason for hiding this comment

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

forgot to rename the extensions namespace

Copy link
Collaborator

Choose a reason for hiding this comment

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

Moved this to #283.

@@ -7,7 +7,8 @@
"clean": "rimraf build",
"copy-templates": "copyfiles ./src/templates/* ./build/templates",
"format": "prettier --plugin-search-dir . --write .",
"build": "tsc -p tsconfig.json",
"build": "npm run clean && run-s build:cli copy-templates",
Copy link
Member Author

Choose a reason for hiding this comment

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

forgot to copy the templates during the build step

Copy link
Collaborator

Choose a reason for hiding this comment

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

Moved this to #283.

@mikenikles
Copy link
Collaborator

The only thing that made me think, is that the packages are living not in a nested monorepo, but just in a subdirectory, but that's fine I guess +1

Yes I agree, that's fine.

There seems to be an issue with the pre-commit hook in husky, caused by a recursive script in packages/plugin-core/web

Which recursive script?

@Cahllagerfeld
Copy link
Member Author

I believe its the test script inide the /plugin-core/web package

@mikenikles
Copy link
Collaborator

Found it. Modify webstone/packages/plugin-core/web/src/lib/index.js and try to commit.

git commit -a
../.pnpm-store/v3/tmp/dlx-4635           |  +73 +++++++
../.pnpm-store/v3/tmp/dlx-4635           | Progress: resolved 73, reused 73, downloaded 0, added 73, done
✔ Preparing lint-staged...
❯ Running tasks for staged files...
  ❯ package.json — 4 files
    ❯ *.{js,ts} — 1 file
      ✔ pnpm lint
      ✖ pnpm test --filter "...[origin/main]" [FAILED]
    ✔ *.{css,js,md,ts} — 2 files
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ pnpm test --filter "...[origin/main]":
Scope: 5 of 6 workspace projects
packages/cli test$ pnpm test:unit "/workspace/webstone/packages/plugin-core/web/src/lib/index.js"
packages/create-webstone-app test$ pnpm test:unit "/workspace/webstone/packages/plugin-core/web/src/lib/index.js"
packages/plugin-core/web test$ playwright test "/workspace/webstone/packages/plugin-core/web/src/lib/index.js"
packages/cli test: > @webstone/[email protected] test:unit /workspace/webstone/packages/cli
packages/cli test: > c8 --all --include=src --reporter=html pnpm test:unit:only "/workspace/webstone/packages/plugin-core/web/src/lib/index.js"
packages/create-webstone-app test: > [email protected] test:unit /workspace/webstone/packages/create-webstone-app
packages/create-webstone-app test: > c8 --all --include=src --reporter=html pnpm test:unit:only "/workspace/webstone/packages/plugin-core/web/src/lib/index.js"
packages/plugin-core/web test: (node:4805) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
packages/plugin-core/web test: (Use `node --trace-warnings ...` to show where the warning was created)
packages/plugin-core/web test: Running 0 tests using 0 workers
packages/plugin-core/web test: =================
packages/plugin-core/web test:  no tests found.
packages/plugin-core/web test: =================
packages/plugin-core/web test: Failed
undefined
/workspace/webstone/packages/plugin-core/web:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  [email protected] test: `playwright test "/workspace/webstone/packages/plugin-core/web/src/lib/index.js"`
Exit status 1
 ERROR  Command failed with exit code 1: /workspace/.pnpm-store/v3/tmp/dlx-4635/node_modules/.bin/lint-staged

pnpm: Command failed with exit code 1: /workspace/.pnpm-store/v3/tmp/dlx-4635/node_modules/.bin/lint-staged
    at makeError (/home/gitpod/.nvm/versions/node/v16.18.1/lib/node_modules/pnpm/dist/pnpm.cjs:22415:17)
    at handlePromise (/home/gitpod/.nvm/versions/node/v16.18.1/lib/node_modules/pnpm/dist/pnpm.cjs:22986:33)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.handler [as dlx] (/home/gitpod/.nvm/versions/node/v16.18.1/lib/node_modules/pnpm/dist/pnpm.cjs:193613:7)
    at async /home/gitpod/.nvm/versions/node/v16.18.1/lib/node_modules/pnpm/dist/pnpm.cjs:200906:21
    at async main (/home/gitpod/.nvm/versions/node/v16.18.1/lib/node_modules/pnpm/dist/pnpm.cjs:200877:34)
    at async runPnpm (/home/gitpod/.nvm/versions/node/v16.18.1/lib/node_modules/pnpm/dist/pnpm.cjs:201101:5)
    at async /home/gitpod/.nvm/versions/node/v16.18.1/lib/node_modules/pnpm/dist/pnpm.cjs:201093:7

@mikenikles
Copy link
Collaborator

Figured it out.

  1. Add console.log("Testing..."); to webstone/packages/plugin-core/web/src/lib/index.js` to trigger the tests in the pre-commit hook
  2. Delete webstone/packages/plugin-core/web/playwright.config.ts. That's for a SvelteKit app project not a lib project.
  3. Add webstone/packages/plugin-core/web/tests/first.spec.js with the following content:
import { test, expect } from '@playwright/test';

test('homepage has Playwright in title and get started link linking to the intro page', async ({
	page
}) => {
	await page.goto('https://playwright.dev/');

	// Expect a title "to contain" a substring.
	await expect(page).toHaveTitle(/Playwright/);
});

Does SvelteKit have an example of how to write tests for a SvelteKit lib project? I'm not aware of it, so we may have to come up with our own setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recreate Core Package as a Plugin
2 participants