From 559a49308e6022529b44c57dbf4078255d5dfcc1 Mon Sep 17 00:00:00 2001 From: Josep Boix Requesens Date: Thu, 2 May 2024 17:14:01 +0200 Subject: [PATCH] refactor: rename plugins folder Renames the `plugins` folder to `packages`: - Adapted `create` and `preapre-deploymet` scripts. - Adaped workspace configuration for npm, eslint and vitest. --- .eslintrc.json | 2 +- docs/README.md | 22 +++---- package-lock.json | 60 +++++++++---------- package.json | 4 +- {plugins => packages}/skip-button/.babelrc | 0 {plugins => packages}/skip-button/README.md | 0 {plugins => packages}/skip-button/index.html | 0 .../skip-button/package.json | 0 .../skip-button/scss/skip-button.scss | 0 .../skip-button/src/lang/de.json | 0 .../skip-button/src/lang/en.json | 0 .../skip-button/src/lang/fr.json | 0 .../skip-button/src/lang/index.js | 0 .../skip-button/src/lang/it.json | 0 .../skip-button/src/lang/rm.json | 0 .../skip-button/src/skip-button.js | 0 .../skip-button/test/skip-button.spec.js | 0 .../skip-button/vite.config.js | 0 .../skip-button/vite.config.lib.js | 0 scripts/create.js | 2 +- scripts/prepare-deployment.js | 14 ++--- vitest.config.js | 2 +- vitest.workspace.js | 2 +- 23 files changed, 54 insertions(+), 54 deletions(-) rename {plugins => packages}/skip-button/.babelrc (100%) rename {plugins => packages}/skip-button/README.md (100%) rename {plugins => packages}/skip-button/index.html (100%) rename {plugins => packages}/skip-button/package.json (100%) rename {plugins => packages}/skip-button/scss/skip-button.scss (100%) rename {plugins => packages}/skip-button/src/lang/de.json (100%) rename {plugins => packages}/skip-button/src/lang/en.json (100%) rename {plugins => packages}/skip-button/src/lang/fr.json (100%) rename {plugins => packages}/skip-button/src/lang/index.js (100%) rename {plugins => packages}/skip-button/src/lang/it.json (100%) rename {plugins => packages}/skip-button/src/lang/rm.json (100%) rename {plugins => packages}/skip-button/src/skip-button.js (100%) rename {plugins => packages}/skip-button/test/skip-button.spec.js (100%) rename {plugins => packages}/skip-button/vite.config.js (100%) rename {plugins => packages}/skip-button/vite.config.lib.js (100%) diff --git a/.eslintrc.json b/.eslintrc.json index ef8e134..92a78dd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,7 +9,7 @@ "overrides": [ { "files": [ - "plugins/**/test/**" + "packages/**/test/**" ], "plugins": [ "vitest" diff --git a/docs/README.md b/docs/README.md index 2299957..07d6472 100644 --- a/docs/README.md +++ b/docs/README.md @@ -52,24 +52,24 @@ After running the command, you will be prompted to enter the type and name of yo element directory will be generated in the monorepo with the following structure: ``` -/plugins/your-element-name +/packages/ |-- src -| |-- lang # Folder containing localization files (only if selected) -| `-- your-element-name.js # Main JavaScript file for the element +| |-- lang # Folder containing localization files (only if selected) +| `-- .js # Main JavaScript file for the element |-- test -| `-- your-element-name.test.js # A default vitest test for your element -|-- .babelrc # Babel configuration specific to this element -|-- index.html # Demo page to showcase the element -|-- package.json # NPM package file, you might need to install additional dependencies -|-- README.md # Documentation file for the element -|-- vite.config.lib.js # Vite configuration for building the element as a library -`-- vite.config.js # Vite configuration for building the element demo page +| `-- .test.js # A default vitest test for your element +|-- .babelrc # Babel configuration specific to this element +|-- index.html # Demo page to showcase the element +|-- package.json # NPM package file, you might need to install additional dependencies +|-- README.md # Documentation file for the element +|-- vite.config.lib.js # Vite configuration for building the element as a library +`-- vite.config.js # Vite configuration for building the element demo page ``` After the structure is generated, navigate into the element's directory: ```bash -cd plugins/your-element-name +cd packages/your-element-name ``` The README.md file included in your element's directory provides detailed instructions on building diff --git a/package-lock.json b/package-lock.json index 9d55649..c1b3d5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "license": "MIT", "workspaces": [ - "plugins/*", + "packages/*", "themes/*" ], "devDependencies": { @@ -5372,7 +5372,7 @@ } }, "node_modules/@srgssr/skip-button": { - "resolved": "plugins/skip-button", + "resolved": "packages/skip-button", "link": true }, "node_modules/@swc/core": { @@ -5676,9 +5676,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.12.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", - "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", + "version": "20.12.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.8.tgz", + "integrity": "sha512-NU0rJLJnshZWdE/097cdCBbyW1h4hEg0xpovcoAQYHl8dnEyp/NAOiE45pvc+Bd1Dt+2r94v2eGFpQJ4R7g+2w==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -6982,9 +6982,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001614", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001614.tgz", - "integrity": "sha512-jmZQ1VpmlRwHgdP1/uiKzgiAuGOfLEJsYFP4+GBou/QQ4U6IOJCB4NP1c+1p9RGLpwObcT94jA5/uO+F1vBbog==", + "version": "1.0.30001615", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001615.tgz", + "integrity": "sha512-1IpazM5G3r38meiae0bHRnPhz+CBQ3ZLqbQMtrg+AsTPKAXgW38JNsXkyZ+v8waCsDmPq87lmfun5Q2AGysNEQ==", "dev": true, "funding": [ { @@ -8237,9 +8237,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.751", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.751.tgz", - "integrity": "sha512-2DEPi++qa89SMGRhufWTiLmzqyuGmNF3SK4+PQetW1JKiZdEpF4XQonJXJCzyuYSA6mauiMhbyVhqYAP45Hvfw==", + "version": "1.4.754", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.754.tgz", + "integrity": "sha512-7Kr5jUdns5rL/M9wFFmMZAgFDuL2YOnanFH4OI4iFzUqyh3XOL7nAGbSlSMZdzKMIyyTpNSbqZsWG9odwLeKvA==", "dev": true }, "node_modules/emoji-regex": { @@ -12467,15 +12467,15 @@ } }, "node_modules/mlly": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.6.1.tgz", - "integrity": "sha512-vLgaHvaeunuOXHSmEbZ9izxPx3USsk8KCQ8iC+aTlp5sKRSoZvwhHh5L9VbKSaVC6sJDqbyohIS76E2VmHIPAA==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.0.tgz", + "integrity": "sha512-U9SDaXGEREBYQgfejV97coK0UL1r+qnF2SyO9A3qcI8MzKnsIFKHNVEkrDyNncQTKQQumsasmeq84eNMdBfsNQ==", "dev": true, "dependencies": { "acorn": "^8.11.3", "pathe": "^1.1.2", - "pkg-types": "^1.0.3", - "ufo": "^1.3.2" + "pkg-types": "^1.1.0", + "ufo": "^1.5.3" } }, "node_modules/mpd-parser": { @@ -14886,9 +14886,9 @@ "dev": true }, "node_modules/sass": { - "version": "1.75.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.75.0.tgz", - "integrity": "sha512-ShMYi3WkrDWxExyxSZPst4/okE9ts46xZmJDSawJQrnte7M1V9fScVB+uNXOVKRBt0PggHOwoZcn8mYX4trnBw==", + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.76.0.tgz", + "integrity": "sha512-nc3LeqvF2FNW5xGF1zxZifdW3ffIz5aBb7I7tSvOoNu7z1RQ6pFt9MBuiPtjgaI62YWrM/txjWlOCFiGtf2xpw==", "dev": true, "dependencies": { "chokidar": ">=3.0.0 <4.0.0", @@ -15648,9 +15648,9 @@ "dev": true }, "node_modules/stylelint": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.4.0.tgz", - "integrity": "sha512-uSx7VMuXwLuYcNSIg+0/fFNv0WinsfLAqsVVy7h7p80clKOHiGE8pfY6UjqwylTHiJrRIahTl6a8FPxGezhWoA==", + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.5.0.tgz", + "integrity": "sha512-IlCBtVrG+qTy3v+tZTk50W8BIomjY/RUuzdrDqdnlCYwVuzXtPbiGfxYqtyYAyOMcb+195zRsuHn6tgfPmFfbw==", "dev": true, "dependencies": { "@csstools/css-parser-algorithms": "^2.6.1", @@ -17521,9 +17521,9 @@ "dev": true }, "node_modules/update-browserslist-db": { - "version": "1.0.13", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", - "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.14.tgz", + "integrity": "sha512-JixKH8GR2pWYshIPUg/NujK3JO7JiqEEUiNArE86NQyrgUuZeTlZQN3xuS/yiV5Kb48ev9K6RqNkaJjXsdg7Jw==", "dev": true, "funding": [ { @@ -17540,7 +17540,7 @@ } ], "dependencies": { - "escalade": "^3.1.1", + "escalade": "^3.1.2", "picocolors": "^1.0.0" }, "bin": { @@ -17771,9 +17771,9 @@ } }, "node_modules/vite": { - "version": "5.2.10", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.10.tgz", - "integrity": "sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==", + "version": "5.2.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.11.tgz", + "integrity": "sha512-HndV31LWW05i1BLPMUCE1B9E9GFbOu1MbenhS58FuK6owSO5qHm7GiCotrNY1YE5rMeQSFBGmT5ZaLEjFizgiQ==", "dev": true, "dependencies": { "esbuild": "^0.20.1", @@ -18270,7 +18270,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "plugins/skip-button": { + "packages/skip-button": { "name": "@srgssr/skip-button", "version": "0.0.1", "peerDependencies": { diff --git a/package.json b/package.json index 5ad8a1e..1a4ee46 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,12 @@ "url": "git+https://github.com/SRGSSR/pillarbox-web-suite.git" }, "workspaces": [ - "plugins/*", + "packages/*", "themes/*" ], "scripts": { "create": "plop --plopfile scripts/create.js", - "eslint": "eslint {plugins/**/{src,test}/**/*.{js,jsx},scripts/*.{js,jsx}}", + "eslint": "eslint {packages/**/{src,test}/**/*.{js,jsx},scripts/*.{js,jsx}}", "outdated": "npm outdated", "prepare": "husky", "stylelint": "stylelint **/*.{css,scss} --allow-empty-input", diff --git a/plugins/skip-button/.babelrc b/packages/skip-button/.babelrc similarity index 100% rename from plugins/skip-button/.babelrc rename to packages/skip-button/.babelrc diff --git a/plugins/skip-button/README.md b/packages/skip-button/README.md similarity index 100% rename from plugins/skip-button/README.md rename to packages/skip-button/README.md diff --git a/plugins/skip-button/index.html b/packages/skip-button/index.html similarity index 100% rename from plugins/skip-button/index.html rename to packages/skip-button/index.html diff --git a/plugins/skip-button/package.json b/packages/skip-button/package.json similarity index 100% rename from plugins/skip-button/package.json rename to packages/skip-button/package.json diff --git a/plugins/skip-button/scss/skip-button.scss b/packages/skip-button/scss/skip-button.scss similarity index 100% rename from plugins/skip-button/scss/skip-button.scss rename to packages/skip-button/scss/skip-button.scss diff --git a/plugins/skip-button/src/lang/de.json b/packages/skip-button/src/lang/de.json similarity index 100% rename from plugins/skip-button/src/lang/de.json rename to packages/skip-button/src/lang/de.json diff --git a/plugins/skip-button/src/lang/en.json b/packages/skip-button/src/lang/en.json similarity index 100% rename from plugins/skip-button/src/lang/en.json rename to packages/skip-button/src/lang/en.json diff --git a/plugins/skip-button/src/lang/fr.json b/packages/skip-button/src/lang/fr.json similarity index 100% rename from plugins/skip-button/src/lang/fr.json rename to packages/skip-button/src/lang/fr.json diff --git a/plugins/skip-button/src/lang/index.js b/packages/skip-button/src/lang/index.js similarity index 100% rename from plugins/skip-button/src/lang/index.js rename to packages/skip-button/src/lang/index.js diff --git a/plugins/skip-button/src/lang/it.json b/packages/skip-button/src/lang/it.json similarity index 100% rename from plugins/skip-button/src/lang/it.json rename to packages/skip-button/src/lang/it.json diff --git a/plugins/skip-button/src/lang/rm.json b/packages/skip-button/src/lang/rm.json similarity index 100% rename from plugins/skip-button/src/lang/rm.json rename to packages/skip-button/src/lang/rm.json diff --git a/plugins/skip-button/src/skip-button.js b/packages/skip-button/src/skip-button.js similarity index 100% rename from plugins/skip-button/src/skip-button.js rename to packages/skip-button/src/skip-button.js diff --git a/plugins/skip-button/test/skip-button.spec.js b/packages/skip-button/test/skip-button.spec.js similarity index 100% rename from plugins/skip-button/test/skip-button.spec.js rename to packages/skip-button/test/skip-button.spec.js diff --git a/plugins/skip-button/vite.config.js b/packages/skip-button/vite.config.js similarity index 100% rename from plugins/skip-button/vite.config.js rename to packages/skip-button/vite.config.js diff --git a/plugins/skip-button/vite.config.lib.js b/packages/skip-button/vite.config.lib.js similarity index 100% rename from plugins/skip-button/vite.config.lib.js rename to packages/skip-button/vite.config.lib.js diff --git a/scripts/create.js b/scripts/create.js index 304ad0c..8db8f99 100644 --- a/scripts/create.js +++ b/scripts/create.js @@ -32,7 +32,7 @@ export default function(plop) { actions: data => [ { type: 'addMany', - destination: '../plugins/{{kebabCase name}}', + destination: '../packages/{{kebabCase name}}', base: './template', templateFiles: './template/**', globOptions: { diff --git a/scripts/prepare-deployment.js b/scripts/prepare-deployment.js index af31744..a511a0c 100644 --- a/scripts/prepare-deployment.js +++ b/scripts/prepare-deployment.js @@ -1,7 +1,7 @@ import fs from 'fs'; import path from 'path'; -const packagesDir = path.join(process.cwd(), 'plugins'); +const packagesDir = path.join(process.cwd(), 'packages'); const deploymentDir = path.join(process.cwd(), 'dist'); // Ensure the deployment directory exists @@ -10,7 +10,7 @@ if (!fs.existsSync(deploymentDir)) { } // Read all package directories -const plugins = fs.readdirSync(packagesDir); +const packages = fs.readdirSync(packagesDir); const indexContent = ` @@ -24,17 +24,17 @@ const indexContent = ` -

Available Plugins

+

Available Packages

    - ${plugins.map(plugin => { - const distDir = path.join(packagesDir, plugin, 'dist'); - const targetDir = path.join(deploymentDir, plugin); + ${packages.map(packageName => { + const distDir = path.join(packagesDir, packageName, 'dist'); + const targetDir = path.join(deploymentDir, packageName); // Copy if the dist directory exists if (fs.existsSync(distDir)) { fs.cpSync(distDir, targetDir, { recursive: true }); - return `
  • ${plugin}
  • `; + return `
  • ${packageName}
  • `; } })}
diff --git a/vitest.config.js b/vitest.config.js index 3ab63a4..8db1dee 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -6,7 +6,7 @@ export default defineConfig({ reporter: ['text', 'json-summary', 'json'], reportOnFailure: true, clean: true, - include: ['plugins/**/src/**'] + include: ['packages/**/src/**'] } } }); diff --git a/vitest.workspace.js b/vitest.workspace.js index abac7bf..ab8a7cf 100644 --- a/vitest.workspace.js +++ b/vitest.workspace.js @@ -1,5 +1,5 @@ import { defineWorkspace } from 'vitest/config'; export default defineWorkspace([ - 'plugins/*', + 'packages/*', ]);