0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-02 04:40:11 -05:00

feat: init penpot integration

This commit is contained in:
Juanfran 2024-02-01 14:08:51 +01:00
parent 927b63c5d1
commit 1082d398a6
20 changed files with 5828 additions and 24 deletions

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
node_modules

35
.eslintrc.json Normal file
View file

@ -0,0 +1,35 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
}

1
.nvmrc Normal file
View file

@ -0,0 +1 @@
v20.11.0

4
.prettierignore Normal file
View file

@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache

3
.prettierrc Normal file
View file

@ -0,0 +1,3 @@
{
"singleQuote": true
}

View file

@ -1,6 +1,7 @@
{
"recommendations": [
"nrwl.angular-console"
"nrwl.angular-console",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}

29
nx.json
View file

@ -1,15 +1,36 @@
{
"pluginsConfig": {
"@nx/js": {
"analyzeSourceFiles": true
}
},
"extends": "nx/presets/npm.json",
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {
"build": {
"cache": true,
"dependsOn": [
"^build"
]
"dependsOn": ["^build"]
},
"lint": {
"cache": true
"cache": true,
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/eslint.config.js"
]
},
"@nx/vite:test": {
"cache": true,
"inputs": ["default", "^default"]
}
},
"generators": {
"@nx/web:application": {
"style": "css",
"linter": "eslint",
"unitTestRunner": "vitest",
"e2eTestRunner": "none"
}
}
}

5490
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,14 +2,40 @@
"name": "penpot-plugins",
"version": "0.0.0",
"license": "MIT",
"scripts": {},
"scripts": {
"start": "npx nx run plugins-runtime:serve",
"build": "npx nx build plugins-runtime --emptyOutDir=true"
},
"private": true,
"dependencies": {},
"devDependencies": {
"@nx/js": "17.2.8",
"nx": "17.2.8"
"@nx/eslint": "17.2.8",
"@nx/eslint-plugin": "17.2.8",
"@nx/js": "17.3.0",
"@nx/vite": "17.2.8",
"@nx/web": "^17.3.0",
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.85",
"@swc/helpers": "~0.5.2",
"@types/node": "20.11.16",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@vitest/coverage-v8": "~0.34.6",
"@vitest/ui": "~0.34.6",
"eslint": "~8.48.0",
"eslint-config-prettier": "^9.0.0",
"jsdom": "~22.1.0",
"nx": "17.2.8",
"prettier": "^2.6.2",
"swc-loader": "0.1.15",
"typescript": "~5.2.2",
"vite": "^5.0.0",
"vite-plugin-dts": "~2.3.0",
"vitest": "~0.34.6"
},
"workspaces": [
"packages/*"
]
],
"dependencies": {
"tslib": "^2.3.0"
}
}

View file

@ -0,0 +1,30 @@
{
"extends": ["../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
}
]
}
}
]
}

23
plugins-runtime/README.md Normal file
View file

@ -0,0 +1,23 @@
# plugins-runtime
Go to to the [this branch](https://github.com/penpot/penpot/tree/niwinz-poc-plugins) in the Penpot local code.
Open `penpot/frontend/resources/templates/index.mustache` and replace the below:
```html
<script type="importmap">
{ "imports": { "plugins-runtime": "/js/plugins-runtime.mjs" } }
</script>
```
New code:
```
<script type="importmap">
{"imports": {"plugins-runtime": "http://localhost:4200/index.mjs"}}
</script>
```
Run the penpot runtime with `npm start`.
Now you can go to penpot and see the `log` of this file `plugins-runtime/src/index.ts`.

View file

@ -0,0 +1,7 @@
{
"name": "plugins-runtime",
"version": "0.0.1",
"dependencies": {},
"module": "./index.mjs",
"typings": "./index.d.ts"
}

View file

@ -0,0 +1,34 @@
{
"name": "plugins-runtime",
"$schema": "../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "plugins-runtime/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/plugins-runtime"
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "../coverage/plugins-runtime"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"serve": {
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "build",
"staticFilePath": "dist/plugins-runtime"
}
}
},
"tags": []
}

View file

@ -0,0 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function initialize(api: any) {
console.log('plugin context');
console.log(api);
}

View file

@ -0,0 +1,5 @@
export class PenpotRuntimeElement extends HTMLElement {
connectedCallback() {}
}
customElements.define('plugins-runtime', PenpotRuntimeElement);

View file

@ -0,0 +1,22 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View file

@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": true,
"types": ["node", "vite/client"]
},
"include": ["src/**/*.ts"],
"exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}

View file

@ -0,0 +1,26 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"vitest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}

View file

@ -0,0 +1,62 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import * as path from 'path';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
export default defineConfig({
root: __dirname,
cacheDir: '../node_modules/.vite/plugins-runtime',
plugins: [
nxViteTsPaths(),
dts({
entryRoot: 'src',
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
skipDiagnostics: true,
}),
],
// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },
// Configuration for building your library.
// See: https://vitejs.dev/guide/build.html#library-mode
build: {
outDir: '../dist/plugins-runtime',
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
lib: {
// Could also be a dictionary or array of multiple entry points.
entry: 'src/index.ts',
name: 'plugins-runtime',
fileName: 'index',
// Change this to the formats you want to support.
// Don't forget to update your package.json as well.
formats: ['es'],
},
rollupOptions: {
// External packages that should not be bundled into your library.
external: [],
},
},
test: {
globals: true,
cache: {
dir: '../node_modules/.vitest',
},
environment: 'node',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../coverage/plugins-runtime',
provider: 'v8',
},
},
});

22
tsconfig.base.json Normal file
View file

@ -0,0 +1,22 @@
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"plugins-runtime": ["plugins-runtime/src/index.ts"]
}
},
"exclude": ["node_modules", "tmp"]
}