Skip to content

Commit 8ad30f8

Browse files
authored
Merge pull request #47 from boazpoolman/release/stable
Release/stable
2 parents df61e0c + 7573a07 commit 8ad30f8

File tree

11 files changed

+91
-55
lines changed

11 files changed

+91
-55
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ npm run build
6666
npm run develop
6767
```
6868

69-
The **Config Sync** plugin should appear in the **Plugins** section of Strapi sidebar after you run app again.
69+
The **Config Sync** plugin should now appear in the **Settings** section of your Strapi app.
70+
71+
To start tracking your config changes you have to make the first export. This will dump all your configuration data to the `/config/sync` directory. To export, run:
72+
73+
```bash
74+
# using yarn
75+
yarn config-sync export
76+
77+
# using npm
78+
npm run config-sync export
79+
```
7080

7181
Enjoy 🎉
7282

@@ -76,7 +86,7 @@ Complete installation requirements are the exact same as for Strapi itself and c
7686

7787
**Supported Strapi versions**:
7888

79-
- Strapi 4.0.7 (recently tested)
89+
- Strapi 4.1.5 (recently tested)
8090
- Strapi ^4.x (use `strapi-plugin-config-sync@^1.0.0`)
8191
- Strapi ^3.4.x (use `[email protected]`)
8292

admin/src/components/ConfigDiff/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer';
33

44
import { ModalLayout, ModalBody, ModalHeader } from '@strapi/design-system/ModalLayout';
5-
import { ButtonText } from '@strapi/design-system/Text';
65
import { Grid, GridItem } from '@strapi/design-system/Grid';
76
import { Typography } from '@strapi/design-system/Typography';
87

@@ -17,9 +16,9 @@ const ConfigDiff = ({ isOpen, onClose, oldValue, newValue, configName }) => {
1716
labelledBy="title"
1817
>
1918
<ModalHeader>
20-
<ButtonText textColor="neutral800" as="h2" id="title">
19+
<Typography variant="omega" fontWeight="bold" textColor="neutral800">
2120
Config changes for {configName}
22-
</ButtonText>
21+
</Typography>
2322
</ModalHeader>
2423
<ModalBody>
2524
<Grid paddingBottom={4} style={{ textAlign: 'center' }}>

admin/src/components/ConfigList/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { isEmpty } from 'lodash';
33
import { useDispatch } from 'react-redux';
44

55
import { Table, Thead, Tbody, Tr, Th } from '@strapi/design-system/Table';
6-
import { TableLabel } from '@strapi/design-system/Text';
6+
import { Typography } from '@strapi/design-system/Typography';
77
import { BaseCheckbox } from '@strapi/design-system/BaseCheckbox';
88
import { Loader } from '@strapi/design-system/Loader';
99

@@ -127,13 +127,13 @@ const ConfigList = ({ diff, isLoading }) => {
127127
/>
128128
</Th>
129129
<Th>
130-
<TableLabel>Config name</TableLabel>
130+
<Typography variant="sigma">Config name</Typography>
131131
</Th>
132132
<Th>
133-
<TableLabel>Config type</TableLabel>
133+
<Typography variant="sigma">Config type</Typography>
134134
</Th>
135135
<Th>
136-
<TableLabel>State</TableLabel>
136+
<Typography variant="sigma">State</Typography>
137137
</Th>
138138
</Tr>
139139
</Thead>

admin/src/components/ConfirmModal/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useIntl } from 'react-intl';
33

44
import { Dialog, DialogBody, DialogFooter } from '@strapi/design-system/Dialog';
55
import { Flex } from '@strapi/design-system/Flex';
6-
import { Text } from '@strapi/design-system/Text';
6+
import { Typography } from '@strapi/design-system/Typography';
77
import { Stack } from '@strapi/design-system/Stack';
88
import { Button } from '@strapi/design-system/Button';
99
import ExclamationMarkCircle from '@strapi/icons/ExclamationMarkCircle';
@@ -22,10 +22,10 @@ const ConfirmModal = ({ isOpen, onClose, onSubmit, type }) => {
2222
<DialogBody icon={<ExclamationMarkCircle />}>
2323
<Stack size={2}>
2424
<Flex justifyContent="center">
25-
<Text id="confirm-description" style={{ textAlign: 'center' }}>
25+
<Typography variant="omega" id="confirm-description" style={{ textAlign: 'center' }}>
2626
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_1` })}<br />
2727
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_2` })}
28-
</Text>
28+
</Typography>
2929
</Flex>
3030
</Stack>
3131
</DialogBody>

admin/src/containers/ConfigPage/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { Map } from 'immutable';
44
import { Box } from '@strapi/design-system/Box';
5+
import { ContentLayout } from '@strapi/design-system/Layout';
56
import { useNotification } from '@strapi/helper-plugin';
67
import { Alert } from '@strapi/design-system/Alert';
78
import { Typography } from '@strapi/design-system/Typography';
@@ -23,7 +24,7 @@ const ConfigPage = () => {
2324
}, []);
2425

2526
return (
26-
<Box paddingLeft={8} paddingRight={8} paddingBottom={8}>
27+
<ContentLayout paddingBottom={8}>
2728
{appEnv === 'production' && (
2829
<Box paddingBottom={4}>
2930
<Alert variant="danger">
@@ -35,7 +36,7 @@ const ConfigPage = () => {
3536
)}
3637
<ActionButtons />
3738
<ConfigList isLoading={isLoading} diff={configDiff.toJS()} />
38-
</Box>
39+
</ContentLayout>
3940
);
4041
};
4142

admin/src/index.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { prefixPluginTranslations } from '@strapi/helper-plugin';
22
import pluginPkg from '../../package.json';
33
import pluginId from './helpers/pluginId';
4-
import pluginIcon from './components/PluginIcon';
54
import pluginPermissions from './permissions';
5+
// import pluginIcon from './components/PluginIcon';
66
// import getTrad from './helpers/getTrad';
77

88
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
@@ -18,22 +18,33 @@ export default {
1818
name,
1919
});
2020

21-
app.addMenuLink({
22-
to: `/plugins/${pluginId}`,
23-
icon: pluginIcon,
24-
intlLabel: {
25-
id: `${pluginId}.plugin.name`,
26-
defaultMessage: 'Config Sync',
21+
app.createSettingSection(
22+
{
23+
id: pluginId,
24+
intlLabel: {
25+
id: `${pluginId}.plugin.name`,
26+
defaultMessage: 'Config Sync',
27+
},
2728
},
28-
Component: async () => {
29-
const component = await import(
30-
/* webpackChunkName: "config-sync-settings-page" */ './containers/App'
31-
);
29+
[
30+
{
31+
intlLabel: {
32+
id: `${pluginId}.Settings.Tool.Title`,
33+
defaultMessage: 'Tools',
34+
},
35+
id: 'config-sync-page',
36+
to: `/settings/${pluginId}`,
37+
Component: async () => {
38+
const component = await import(
39+
/* webpackChunkName: "config-sync-settings-page" */ './containers/App'
40+
);
3241

33-
return component;
34-
},
35-
permissions: pluginPermissions['menu-link'],
36-
});
42+
return component;
43+
},
44+
permissions: pluginPermissions['settings'],
45+
},
46+
],
47+
);
3748
},
3849
bootstrap(app) {},
3950
async registerTrads({ locales }) {

admin/src/translations/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010
"Header.Title": "Config Sync",
1111
"Header.Description": "Manage your database config across environments.",
1212

13+
"Settings.Tool.Title": "Tool",
14+
1315
"plugin.name": "Config Sync"
1416
}

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "strapi-plugin-config-sync",
33
"version": "1.0.0-beta.8",
4-
"description": "CLI & GUI for syncing config data across environments.",
4+
"description": "Migrate your config data across environments using the CLI or Strapi admin panel.",
55
"strapi": {
66
"displayName": "Config Sync",
77
"name": "config-sync",
88
"icon": "sync",
9-
"description": "CLI & GUI for syncing config data across environments.",
9+
"description": "Migrate your config data across environments using the CLI or Strapi admin panel.",
1010
"required": false,
1111
"kind": "plugin"
1212
},
@@ -57,10 +57,10 @@
5757
},
5858
"devDependencies": {
5959
"@fortawesome/react-fontawesome": "^0.1.16",
60-
"@strapi/design-system": "^0.0.1-alpha.75",
61-
"@strapi/helper-plugin": "^4.0.7",
62-
"@strapi/icons": "^0.0.1-alpha.75",
63-
"@strapi/utils": "^4.0.7",
60+
"@strapi/design-system": "^0.0.1-alpha.79",
61+
"@strapi/helper-plugin": "^4.1.5",
62+
"@strapi/icons": "^0.0.1-alpha.79",
63+
"@strapi/utils": "^4.1.5",
6464
"babel-eslint": "9.0.0",
6565
"eslint": "^7.32.0",
6666
"eslint-config-airbnb": "^18.2.1",

playground/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"jest-cli": "^26.0.1"
1616
},
1717
"dependencies": {
18-
"@strapi/plugin-i18n": "^4.0.2",
19-
"@strapi/plugin-users-permissions": "^4.0.2",
20-
"@strapi/strapi": "^4.0.2",
18+
"@strapi/plugin-i18n": "^4.0.0",
19+
"@strapi/plugin-users-permissions": "^4.0.0",
20+
"@strapi/strapi": "^4.0.0",
2121
"sqlite3": "5.0.2",
2222
"strapi-plugin-config-sync": "boazpoolman/strapi-plugin-config-sync"
2323
},

server/cli.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
const fs = require('fs');
34
const { Command } = require('commander');
45
const Table = require('cli-table');
56
const chalk = require('chalk');
@@ -68,6 +69,14 @@ const getConfigState = (diff, configName, syncType) => {
6869

6970
const handleAction = async (syncType, skipConfirm, configType, partials) => {
7071
const app = await strapi().load();
72+
const hasSyncDir = fs.existsSync(app.config.get('plugin.config-sync.syncDir'));
73+
74+
// No import with empty sync dir.
75+
if (!hasSyncDir && syncType === 'import') {
76+
console.log(`${chalk.yellow.bold('[warning]')} You can't import an empty sync directory. Please export before continuing.`);
77+
process.exit(0);
78+
}
79+
7180
const diff = await app.plugin('config-sync').service('main').getFormattedDiff();
7281

7382
// No changes.
@@ -109,7 +118,9 @@ const handleAction = async (syncType, skipConfirm, configType, partials) => {
109118
});
110119

111120
// Print table.
112-
console.log(table.toString(), '\n');
121+
if (hasSyncDir) {
122+
console.log(table.toString(), '\n');
123+
}
113124

114125
// Prompt to confirm.
115126
let answer = {};

0 commit comments

Comments
 (0)