Skip to content

Commit 75e9f4c

Browse files
committed
Merge branch 'master' of github.com:pluginpal/strapi-plugin-config-sync
2 parents 5fc0aea + 748a31a commit 75e9f4c

File tree

33 files changed

+219
-185
lines changed

33 files changed

+219
-185
lines changed

playground/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ coverage
108108
# Strapi
109109
############################
110110

111-
# .env
112111
license.txt
113112
exports
114-
*.cache
113+
.strapi
114+
dist
115115
build
116116
.strapi-updater.json
117+
.strapi-cloud.json
117118

118119
# yalc
119120
.yalc

playground/.strapi/client/app.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

playground/.strapi/client/index.html

Lines changed: 0 additions & 63 deletions
This file was deleted.

playground/__tests__/cli.test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,47 @@ describe('Test the config-sync CLI', () => {
5858
}
5959
expect(error).toHaveProperty('code', 1);
6060
});
61+
62+
test('Import build project', async () => {
63+
// First we make sure the dist folder is deleted.
64+
await exec('mv dist .tmp');
65+
66+
await exec('yarn cs import -y');
67+
68+
const { stdout: buildOutput } = await exec('ls dist');
69+
expect(buildOutput).toContain('config');
70+
expect(buildOutput).toContain('src');
71+
expect(buildOutput).toContain('tsconfig.tsbuildinfo');
72+
73+
// We restore the dist folder.
74+
await exec('rm -rf dist');
75+
await exec('mv .tmp/dist ./dist');
76+
77+
});
78+
test('Import project already built', async () => {
79+
80+
81+
// First we make sure the dist folder exists by doing an import.
82+
await exec('yarn cs import -y');
83+
84+
const { stdout: lsDist } = await exec('ls dist');
85+
expect(lsDist).toContain('config');
86+
expect(lsDist).toContain('src');
87+
expect(lsDist).toContain('tsconfig.tsbuildinfo');
88+
89+
// We remove on file from the dist folder
90+
await exec('mv dist/tsconfig.tsbuildinfo .tmp');
91+
92+
// The new import should not rebuild the project.
93+
await exec('yarn cs import -y');
94+
95+
const { stdout: buildOutput } = await exec('ls dist');
96+
expect(buildOutput).toContain('config');
97+
expect(buildOutput).toContain('src');
98+
expect(buildOutput).not.toContain('tsconfig.tsbuildinfo');
99+
100+
// We restore the tsconfig.tsbuildinfo file.
101+
await exec('mv .tmp/tsconfig.tsbuildinfo dist/tsconfig.tsbuildinfo');
102+
103+
});
61104
});

playground/__tests__/import-on-boostrap.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jest.setTimeout(20000);
77

88
afterEach(async () => {
99
// Disable importOnBootstrap
10-
await exec('sed -i "s/importOnBootstrap: true/importOnBootstrap: false/g" config/plugins.js');
10+
await exec('sed -i "s/importOnBootstrap: true/importOnBootstrap: false/g" config/plugins.ts');
1111

1212
await cleanupStrapi();
1313
await exec('rm -rf config/sync');
@@ -19,8 +19,8 @@ describe('Test the importOnBootstrap feature', () => {
1919
await exec('yarn cs export -y');
2020
await exec('rm -rf .tmp');
2121

22-
// Manually change the plugins.js to enable importOnBoostrap.
23-
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.js');
22+
// Manually change the plugins.ts to enable importOnBoostrap.
23+
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.ts');
2424

2525
// Start up Strapi to initiate the importOnBootstrap function.
2626
await setupStrapi();
@@ -33,8 +33,8 @@ describe('Test the importOnBootstrap feature', () => {
3333
await exec('rm -rf .tmp');
3434
await exec('yarn cs export -y');
3535

36-
// Manually change the plugins.js to enable importOnBoostrap.
37-
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.js');
36+
// Manually change the plugins.ts to enable importOnBoostrap.
37+
await exec('sed -i "s/importOnBootstrap: false/importOnBootstrap: true/g" config/plugins.ts');
3838

3939
// Remove a config file to make sure the importOnBoostrap
4040
// function actually attempts to import.

playground/config/admin.js renamed to playground/config/admin.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = ({ env }) => ({
1+
export default ({ env }) => ({
22
auth: {
33
secret: env('ADMIN_JWT_SECRET'),
44
},
@@ -19,6 +19,5 @@ module.exports = ({ env }) => ({
1919
},
2020
watchIgnoreFiles: [
2121
'!**/.yalc/**/server/**',
22-
'**/config/sync/**',
23-
]
22+
],
2423
});

playground/config/api.js renamed to playground/config/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
rest: {
33
defaultLimit: 25,
44
maxLimit: 100,

playground/config/database.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

playground/config/database.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import path from 'path';
2+
3+
export default ({ env }) => {
4+
5+
return {
6+
connection: {
7+
client: 'sqlite',
8+
connection: {
9+
filename: path.join(__dirname, '..', '..', env('DATABASE_FILENAME', '.tmp/data.db')),
10+
},
11+
useNullAsDefault: true,
12+
},
13+
};
14+
15+
};

playground/config/middlewares.js renamed to playground/config/middlewares.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = [
1+
export default [
22
'strapi::logger',
33
'strapi::errors',
44
'strapi::security',

0 commit comments

Comments
 (0)