Skip to content

Commit

Permalink
fix: generate plugins that work for v5 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
innerdvations authored May 20, 2024
1 parent c43b741 commit 80d6ab4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-trees-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@strapi/sdk-plugin': patch
---

Fix build for v5 plugins
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
"watch": "pack-up watch"
},
"dependencies": {
"@strapi/pack-up": "5.0.0",
"@strapi/pack-up": ">=5.0.1-alpha.1 <6.0.0",
"@types/prompts": "2.4.9",
"boxen": "5.1.2",
"chalk": "4.1.2",
"commander": "8.3.0",
"commander": "12.1.0",
"concurrently": "^8.2.2",
"get-latest-version": "5.1.0",
"git-url-parse": "13.1.1",
Expand Down
20 changes: 13 additions & 7 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions src/cli/commands/plugin/init/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const USE_BETA_VERSIONS: string[] = [
'@strapi/icons',
'@strapi/strapi',
'@strapi/sdk-plugin',
'@strapi/typescript-utils',
] as const;

export default async (
Expand Down Expand Up @@ -310,6 +311,7 @@ const PLUGIN_TEMPLATE = defineTemplate(async ({ logger, gitConfig, packagePath }
...pkgJson.dependencies,
'@strapi/design-system': '*',
'@strapi/icons': '*',
'react-intl': '*',
};

pkgJson.devDependencies = {
Expand Down
46 changes: 12 additions & 34 deletions src/cli/commands/plugin/init/files/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,20 @@ const TYPESCRIPT = (pluginName: string): TemplateFile[] => [
/**
* Application methods
*/
import bootstrap from './bootstrap';
import destroy from './destroy';
import register from './register';
export * as bootstrap from './bootstrap';
export * as destroy from './destroy';
export * as register from './register';
/**
* Plugin server methods
*/
import config from './config';
import contentTypes from './content-types';
import controllers from './controllers';
import middlewares from './middlewares';
import policies from './policies';
import routes from './routes';
import services from './services';
export default {
bootstrap,
destroy,
register,
config,
controllers,
contentTypes,
middlewares,
policies,
routes,
services,
};
export * as config from './config';
export * as contentTypes from './content-types';
export * as controllers from './controllers';
export * as middlewares from './middlewares';
export * as policies from './policies';
export * as routes from './routes';
export * as services from './services';
`,
},
{
Expand Down Expand Up @@ -93,11 +79,7 @@ const TYPESCRIPT = (pluginName: string): TemplateFile[] => [
{
name: 'server/src/controllers/index.ts',
contents: outdent`
import controller from './controller';
export default {
controller,
};
export * as controller from './controller';
`,
},
{
Expand Down Expand Up @@ -149,11 +131,7 @@ const TYPESCRIPT = (pluginName: string): TemplateFile[] => [
{
name: 'server/src/services/index.ts',
contents: outdent`
import service from './service';
export default {
service,
};
export * as service from './service';
`,
},
{
Expand Down

0 comments on commit 80d6ab4

Please sign in to comment.