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
Draft
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
plugins: ["@typescript-eslint"],
root: true,
rules: {
"require-yield": "off",
"@typescript-eslint/ban-ts-comment": [
"error",
{
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ coverage
node_modules
package-lock.json
packages/**/dist
packages/**/build
tests/e2e/test-results
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 :)

"dev": "pnpm --recursive --parallel --filter=!./packages/plugin-core/** dev",
"lint": "eslint . --fix --ignore-path .gitignore --max-warnings 0",
"preinstall": "npx only-allow pnpm",
"prepare": "husky install",
Expand Down
18 changes: 18 additions & 0 deletions packages/create-webstone-app/src/tasks/2-setup-project/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

path.join(
ctx.appDir,
"packages",
"cli",
"src",
"extensions",
"placeholder"
),
path.join(
ctx.appDir,
"packages",
"cli",
"src",
"extensions",
getAppName(ctx.appDir)
)
);
};

const setWebPackagePrivateTrue = (ctx: Ctx) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

"build:cli": "tsc -p tsconfig.json",
"dev": "pnpm clean && pnpm copy-templates && run-p dev:watch-src dev:watch-templates",
"dev:watch-src": "tsc -p tsconfig.json --watch",
"dev:watch-templates": "npm-watch copy-templates"
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-core/cli/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100
}
49 changes: 49 additions & 0 deletions packages/plugin-core/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "webstone-plugin-cli-core",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"private": true,
"files": [
"build",
"dist"
],
"scripts": {
"clean": "rimraf build dist",
"copy-templates": "copyfiles ./src/templates/* ./build/templates",
"format": "prettier --plugin-search-dir . --write .",
"build": "npm run clean && run-p build:cli build:lib copy-templates",
"build:lib": "tsup src/lib/index.ts --format cjs --dts --clean --minify",
"build:cli": "tsc -p tsconfig.json",
"dev": "pnpm clean && pnpm copy-templates && run-p dev:watch-src dev:watch-templates dev:lib",
"dev:watch-src": "tsc -p tsconfig.json --watch",
"dev:watch-templates": "npm-watch copy-templates",
"dev:lib": "npm run build:lib -- --watch src/lib"
},
"keywords": [
"webstone",
"plugin",
"template"
],
"watch": {
"copy-templates": {
"patterns": [
"src/templates"
],
"extensions": "ejs"
}
},
"author": "Cahllagerfeld",
"license": "MIT",
"devDependencies": {
"copyfiles": "^2.4.1",
"gluegun": "^5.1.2",
"npm-run-all": "^4.1.5",
"npm-watch": "^0.11.0",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"tsup": "^6.2.3",
"typescript": "^4.7.4"
}
}
16 changes: 16 additions & 0 deletions packages/plugin-core/cli/src/commands/core/hello-world.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GluegunCommand } from 'gluegun';

const command: GluegunCommand = {
name: 'hello',
alias: ['h'],
description: 'Hello World Command',
hidden: false,
dashed: false,
run: async (toolbox) => {
const { print } = toolbox;

print.info(`Hello World`);
}
};

export default command;
11 changes: 11 additions & 0 deletions packages/plugin-core/cli/src/extensions/core/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GluegunToolbox } from 'gluegun';

const extension = (toolbox: GluegunToolbox) => {
const { print } = toolbox;

toolbox.sayhello = () => {
print.info('Hello from an extension!');
};
};

export default extension;
1 change: 1 addition & 0 deletions packages/plugin-core/cli/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const test = 'dummy';
1 change: 1 addition & 0 deletions packages/plugin-core/cli/src/templates/template.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Template</h1>
18 changes: 18 additions & 0 deletions packages/plugin-core/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES6",
"outDir": "./build",
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"declaration": true,
"moduleResolution": "Node",
"rootDir": "src",
"declarationDir": "./build/types"
},
"include": ["src/**/*.ts"],
"exclude": ["src/fixtures", "src/**/*.test.ts", "src/lib"]
}
13 changes: 13 additions & 0 deletions packages/plugin-core/web/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
20 changes: 20 additions & 0 deletions packages/plugin-core/web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
settings: {
'svelte3/typescript': () => require('typescript')
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
env: {
browser: true,
es2017: true,
node: true
}
};
8 changes: 8 additions & 0 deletions packages/plugin-core/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
1 change: 1 addition & 0 deletions packages/plugin-core/web/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
13 changes: 13 additions & 0 deletions packages/plugin-core/web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
9 changes: 9 additions & 0 deletions packages/plugin-core/web/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
38 changes: 38 additions & 0 deletions packages/plugin-core/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
34 changes: 34 additions & 0 deletions packages/plugin-core/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "webstone-plugin-web-core",
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
"build": "svelte-kit sync && svelte-package",
"test": "playwright test",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@playwright/test": "^1.25.0",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"@sveltejs/package": "next",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"svelte": "^3.44.0",
"svelte-check": "^2.7.1",
"svelte-preprocess": "^4.10.6",
"tslib": "^2.3.1",
"typescript": "^4.7.4",
"vite": "^3.1.0"
},
"type": "module",
"private": true
}
10 changes: 10 additions & 0 deletions packages/plugin-core/web/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
}
};

export default config;
11 changes: 11 additions & 0 deletions packages/plugin-core/web/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="@sveltejs/kit" />

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
// interface Locals {}
// interface PageData {}
// interface Error {}
// interface Platform {}
}
12 changes: 12 additions & 0 deletions packages/plugin-core/web/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>
</html>
1 change: 1 addition & 0 deletions packages/plugin-core/web/src/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Reexport your entry components here
3 changes: 3 additions & 0 deletions packages/plugin-core/web/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>Welcome to your library project</h1>
<p>Create your package using @sveltejs/package and preview/showcase your work with SvelteKit</p>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
Binary file added packages/plugin-core/web/static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/plugin-core/web/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),

kit: {
adapter: adapter()
}
};

export default config;
17 changes: 17 additions & 0 deletions packages/plugin-core/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}
8 changes: 8 additions & 0 deletions packages/plugin-core/web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { sveltekit } from '@sveltejs/kit/vite';
import type { UserConfig } from 'vite';

const config: UserConfig = {
plugins: [sveltekit()]
};

export default config;
Loading