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

feat(cli): ability to disable plugins from shopware instance #1668

Merged
merged 1 commit into from
Sep 15, 2021
Merged
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
55 changes: 55 additions & 0 deletions docs/landing/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,61 @@ module.exports = {
yarn dev
```

### shopware-pwa.config.js config file

Available settings inside the `shopware-pwa.config.js` file:

```ts
export interface ShopwarePwaConfigFile {
/**
* list of allowed domains for this pwa instance from saleschannel configuration
*/
shopwareDomainsAllowList?: string[];
/**
* default domain prefix
*/
fallbackDomain?: string;
/**
* Shopware6 URL
*/
shopwareEndpoint: string;
/**
* id specific for each sales channel
*/
shopwareAccessToken: string;
/**
* theme code: npm package name or local one (directory name)
*/
theme: string;
/**
* default locale used in application
*/
defaultLanguageCode?: string;
/**
* {ShopwareApiClientConfig}
*/
shopwareApiClient?: ShopwareApiClientConfig;
/**
* List of the plugins that are installed on Shopware instance but should not be loaded.
*/
disabledPlugins?: string[];
}

export interface ShopwareApiClientConfig {
/**
* value of timeout limit for the requests (ms)
*/
timeout?: number;
/**
* credentials for HTTP basic auth
*/
auth?: {
username: string;
password: string;
};
}
```

### How do I move on?

What about...
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/commands/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { GluegunToolbox } from "gluegun";
import { ShopwarePwaToolbox } from "src/types";

module.exports = {
name: "plugins",
hidden: true,
run: async (toolbox: GluegunToolbox) => {
run: async (toolbox: ShopwarePwaToolbox) => {
const {
template: { generate },
print: { success, spin },
Expand Down Expand Up @@ -98,8 +98,10 @@ module.exports = {
toolbox.debug("plugins config", pluginsConfig);
const shopwarePluginsTrace = await toolbox.buildPluginsTrace({
pluginsConfig,
disabledPlugins: toolbox.config.disabledPlugins,
});
toolbox.debug("plugins trace", shopwarePluginsTrace);
toolbox.debug("disabled plugins", toolbox.config.disabledPlugins);
// extend plugins trace from local project
const localPluginsConfig = await toolbox.plugins.getPluginsConfig({
localPlugins: true,
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/extensions/plugins-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ module.exports = (toolbox: GluegunToolbox) => {
pluginsConfig,
rootDirectory,
pluginsTrace,
disabledPlugins,
}: any = {}) => {
const pluginsRootDirectory =
rootDirectory || ".shopware-pwa/pwa-bundles-assets";
const pluginsMap = Object.assign({}, pluginsTrace);
if (pluginsConfig) {
const pluginNames = Object.keys(pluginsConfig);
const pluginNames = Object.keys(pluginsConfig).filter(
(pluginName) => !disabledPlugins?.includes(pluginName) // filter out disabled plugins
);
pluginNames.forEach((pluginName) => {
if (!pluginsConfig[pluginName]) return;
const pluginDirectory = `${pluginsRootDirectory}/${pluginName}`;
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { ShopwarePwaConfigFile } from "@shopware-pwa/commons";
import { GluegunToolbox } from "gluegun";
// export types

export interface ShopwarePwaToolbox {
export interface ShopwarePwaToolbox extends GluegunToolbox {
isProduction: boolean;
config: ShopwarePwaConfigFile & { loadConfig?: () => void };
}
4 changes: 4 additions & 0 deletions packages/commons/src/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export interface ShopwarePwaConfigFile {
* {ShopwareApiClientConfig}
*/
shopwareApiClient?: ShopwareApiClientConfig;
/**
* List of the plugins that are installed on Shopware instance but should not be loaded.
*/
disabledPlugins?: string[];
}

export interface CompatibilityTable {
Expand Down