Skip to content

Commit

Permalink
refactor: rename plugins folder
Browse files Browse the repository at this point in the history
Renames the `plugins` folder to `packages`:

- Adapted `create` and `preapre-deploymet` scripts.
- Adaped workspace configuration for npm, eslint and vitest.
  • Loading branch information
jboix committed May 6, 2024
1 parent 1877dfa commit 559a493
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"overrides": [
{
"files": [
"plugins/**/test/**"
"packages/**/test/**"
],
"plugins": [
"vitest"
Expand Down
22 changes: 11 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<your-element-name>
|-- 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)
| `-- <your-element-name>.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
| `-- <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
```

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
Expand Down
60 changes: 30 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
14 changes: 7 additions & 7 deletions scripts/prepare-deployment.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,7 +10,7 @@ if (!fs.existsSync(deploymentDir)) {
}

// Read all package directories
const plugins = fs.readdirSync(packagesDir);
const packages = fs.readdirSync(packagesDir);
const indexContent = `
<!DOCTYPE html>
<html>
Expand All @@ -24,17 +24,17 @@ const indexContent = `
</style>
</head>
<body>
<h1>Available Plugins</h1>
<h1>Available Packages</h1>
<ul>
${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 `<li><a href="${plugin}/index.html">${plugin}</a></li>`;
return `<li><a href="${packageName}/index.html">${packageName}</a></li>`;
}
})}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig({
reporter: ['text', 'json-summary', 'json'],
reportOnFailure: true,
clean: true,
include: ['plugins/**/src/**']
include: ['packages/**/src/**']
}
}
});
2 changes: 1 addition & 1 deletion vitest.workspace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineWorkspace } from 'vitest/config';

export default defineWorkspace([
'plugins/*',
'packages/*',
]);

0 comments on commit 559a493

Please sign in to comment.